Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <llsan@microsoft.com>2018-05-05 17:11:21 +0300
committerGitHub <noreply@github.com>2018-05-05 17:11:21 +0300
commit498923ea36d2c7fe440c4e4b8cfb75bd50bbd748 (patch)
tree5f6c0ab97aaa3c6bf8c55b447e6255b86cce0bcd
parente28129bb4236e7f3f2f43bac348b73a284f5fec8 (diff)
parent9eca7e7ce0d49becaaeb53fb705125ef4ed87b94 (diff)
Merge pull request #4729 from mono/dev/kirillo/TryCatchmonodevelop-7.5.0.1254
Prevent crashes and bring back C# highlighting in Razor
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextViewMargin.SpanUpdateListener.cs33
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/VSEditor/TagBasedSyntaxHighlighting.cs7
2 files changed, 26 insertions, 14 deletions
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextViewMargin.SpanUpdateListener.cs b/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextViewMargin.SpanUpdateListener.cs
index f0700ee6ee..3bc3227d5a 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextViewMargin.SpanUpdateListener.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextViewMargin.SpanUpdateListener.cs
@@ -75,10 +75,14 @@ namespace Mono.TextEditor
void Document_TextChanging (object sender, TextChangeEventArgs e)
{
- HasUpdatedMultilineSpan = false;
- foreach (var change in e.TextChanges) {
- var layout = textEditor.TextViewMargin.GetLayout (textEditor.GetLineByOffset (change.Offset));
- lines.Add (layout.HighlightedLine);
+ try {
+ HasUpdatedMultilineSpan = false;
+ foreach (var change in e.TextChanges) {
+ var layout = textEditor.TextViewMargin.GetLayout (textEditor.GetLineByOffset (change.Offset));
+ lines.Add (layout.HighlightedLine);
+ }
+ }
+ catch {
}
}
@@ -86,15 +90,20 @@ namespace Mono.TextEditor
{
int i = 0;
- foreach (var change in e.TextChanges) {
- if (i >= lines.Count)
- break; // should never happen
- var oldHighlightedLine = lines [i++];
- var curLine = textEditor.GetLineByOffset (change.Offset);
- var curLayout = textEditor.TextViewMargin.GetLayout (curLine);
- if (!UpdateLineHighlight (curLine.LineNumber, oldHighlightedLine, curLayout.HighlightedLine))
- break;
+ try {
+ foreach (var change in e.TextChanges) {
+ if (i >= lines.Count)
+ break; // should never happen
+ var oldHighlightedLine = lines[i++];
+ var curLine = textEditor.GetLineByOffset (change.Offset);
+ var curLayout = textEditor.TextViewMargin.GetLayout (curLine);
+ if (!UpdateLineHighlight (curLine.LineNumber, oldHighlightedLine, curLayout.HighlightedLine))
+ break;
+ }
+ }
+ catch {
}
+
lines.Clear ();
}
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/VSEditor/TagBasedSyntaxHighlighting.cs b/main/src/addins/MonoDevelop.SourceEditor2/VSEditor/TagBasedSyntaxHighlighting.cs
index f3c9c1889c..48f4f3166f 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/VSEditor/TagBasedSyntaxHighlighting.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/VSEditor/TagBasedSyntaxHighlighting.cs
@@ -49,8 +49,11 @@ namespace Microsoft.VisualStudio.Platform
public async Task<HighlightedLine> GetHighlightedLineAsync(IDocumentLine line, CancellationToken cancellationToken)
{
- ITextSnapshotLine snapshotLine = (line as Mono.TextEditor.TextDocument.DocumentLineFromTextSnapshotLine)?.Line;
- if (this.classifier == null || snapshotLine == null || snapshotLine.Snapshot != snapshotLine.Snapshot.TextBuffer.CurrentSnapshot)
+ //TODO verify that the snapshot line from this.textBuffer is equivalent to the document line converted to a snapshotline.
+ //Possibly take in a TextDataModel as a parameter and verify the buffers are appropriate.
+ //ITextSnapshotLine snapshotLine = (line as Mono.TextEditor.TextDocument.DocumentLineFromTextSnapshotLine)?.Line;
+ ITextSnapshotLine snapshotLine = textBuffer.CurrentSnapshot.GetLineFromLineNumber (line.LineNumber - 1);
+ if ((this.classifier == null) || (snapshotLine == null))
{
return new HighlightedLine(line, new[] { new ColoredSegment(0, line.Length, ScopeStack.Empty) });
}