diff --git a/Codist/Classifiers/CodeTagger.cs b/Codist/Classifiers/CodeTagger.cs index dd32f7a6..b3a87c9b 100644 --- a/Codist/Classifiers/CodeTagger.cs +++ b/Codist/Classifiers/CodeTagger.cs @@ -106,18 +106,25 @@ public IEnumerable> GetTags(NormalizedSnapshotSpanCo yield break; } IEnumerable> tagSpans; - if (_Tags.LastParsed == 0) { - // perform a full parse for the first time - Debug.WriteLine("Full parse"); - tagSpans = _Aggregator.GetTags(new SnapshotSpan(snapshot, 0, snapshot.Length)); - _Tags.LastParsed = snapshot.Length; - } - else { - var start = spans[0].Start; - var end = spans[spans.Count - 1].End; - Debug.WriteLine($"Get tag [{start.Position}..{end.Position})"); + try { + if (_Tags.LastParsed == 0) { + // perform a full parse for the first time + Debug.WriteLine("Full parse"); + tagSpans = _Aggregator.GetTags(new SnapshotSpan(snapshot, 0, snapshot.Length)); + _Tags.LastParsed = snapshot.Length; + } + else { + var start = spans[0].Start; + var end = spans[spans.Count - 1].End; + Debug.WriteLine($"Get tag [{start.Position}..{end.Position})"); - tagSpans = _Aggregator.GetTags(spans); + tagSpans = _Aggregator.GetTags(spans); + } + } + catch (ObjectDisposedException ex) { + // HACK: TagAggregator could be disposed during editing, to be investigated further + Debug.WriteLine(ex.Message); + yield break; } foreach (var tagSpan in tagSpans) { diff --git a/Codist/Margins/CodeMarginElement.cs b/Codist/Margins/CodeMarginElement.cs index b6ec1457..279dc1b6 100644 --- a/Codist/Margins/CodeMarginElement.cs +++ b/Codist/Margins/CodeMarginElement.cs @@ -256,6 +256,7 @@ private void DrawMarkers(DrawingContext drawingContext) { } if (b == ClassNameBrush || b == InterfaceNameBrush || b == StructNameBrush || b == EnumNameBrush) { if (tag.Length > 0) { + // the tag could be zero-lengthed, so we have to check DrawDeclarationMark(drawingContext, b, y, c, snapshot.GetText(tag.Start, tag.Length)); } continue; diff --git a/Codist/Properties/AssemblyInfo.cs b/Codist/Properties/AssemblyInfo.cs index beda4f86..199e7484 100644 --- a/Codist/Properties/AssemblyInfo.cs +++ b/Codist/Properties/AssemblyInfo.cs @@ -30,4 +30,4 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("2.4.0.0")] -[assembly: AssemblyFileVersion("2.4.2.439")] +[assembly: AssemblyFileVersion("2.4.2.443")] diff --git a/Codist/Views/CSharpTooltip.cs b/Codist/Views/CSharpTooltip.cs index bdc78975..239c96fc 100644 --- a/Codist/Views/CSharpTooltip.cs +++ b/Codist/Views/CSharpTooltip.cs @@ -467,6 +467,7 @@ static StackPanel ToUIText(ImmutableArray parts, string title } static void UpdateSyntaxHighlights(IEditorFormatMap formatMap) { + System.Diagnostics.Trace.Assert(formatMap != null, "format map is null"); _InterfaceBrush = GetFormatBrush(Constants.CodeInterfaceName, formatMap); _ClassBrush = GetFormatBrush(Constants.CodeClassName, formatMap); _TextBrush = GetFormatBrush(Constants.CodeString, formatMap); @@ -480,7 +481,9 @@ static void UpdateSyntaxHighlights(IEditorFormatMap formatMap) { } private void _ConfigUpdated(object sender, EventArgs e) { - UpdateSyntaxHighlights(_FormatMap); + if (_FormatMap != null) { + UpdateSyntaxHighlights(_FormatMap); + } } StackPanel ShowAttributes(ImmutableArray attrs, int position) { var stack = new StackPanel(); diff --git a/Codist/source.extension.vsixmanifest b/Codist/source.extension.vsixmanifest index 9119332d..02c9b8a4 100644 --- a/Codist/source.extension.vsixmanifest +++ b/Codist/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + Codist A plugin which enhances coding experience with advanced syntax highlighting and scrollbar marking. diff --git a/README.md b/README.md index bd53d49b..8f25b031 100644 --- a/README.md +++ b/README.md @@ -30,17 +30,6 @@ ![Syntax highlight](doc/highlight2.png) ![Syntax highlight](doc/highlight3.png) -## Customized comment styles -* The comment tagger highlights comments (actually all editor styles) to your specific styles. - - ![Comment syntax highlight](doc/comment-tagger-options.png) - - Here's the effect of the highlighted comments. - - ![Comment syntax highlight](doc/syntax-highlight-comments.png) - -* The syntax style of comments or C# XML Documentations could be changed too. You can make them semitrasparent to stand behind usual code lines by changing the *Opacity* value of the corresponding syntax parts. - ## Super Quick Info The quick info (the tooltip shown when you hover your mouse pointer to language elements) can be enhanced by *Codist*. @@ -69,6 +58,17 @@ The quick info (the tooltip shown when you hover your mouse pointer to language ![Super Quick Info 6](doc/super-quick-info-6.png) +## Customized comment styles +* The comment tagger highlights comments to your specific styles. + + ![Comment syntax highlight](doc/comment-tagger-options.png) + + Here's the effect of the highlighted comments. + + ![Comment syntax highlight](doc/syntax-highlight-comments.png) + +* The syntax style of comments or C# XML Documentations could be changed too. You can make them semitrasparent to stand behind usual code lines by changing the *Opacity* value of the corresponding syntax parts. + ## Markers on the Scrollbar Margin The scrollbar can mark...