Skip to content

Commit

Permalink
Fixed silent exceptions in taggers
Browse files Browse the repository at this point in the history
  • Loading branch information
madskristensen committed Sep 25, 2024
1 parent 9bc3a3b commit 9d0db95
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
7 changes: 4 additions & 3 deletions demo/VSSDK.TestExtension/VSSDK.TestExtension.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DeployExtension>True</DeployExtension>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down Expand Up @@ -134,16 +135,16 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.SDK.Analyzers">
<Version>16.10.10</Version>
<Version>17.7.41</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers">
<Version>17.0.64</Version>
<Version>17.11.20</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="17.0.5232">
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="17.11.435">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
6 changes: 4 additions & 2 deletions demo/VSSDK.TestExtension/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
<Description>Empty VSIX Project.</Description>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[16.0, 17.0)" />
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[16.0, 18.0)">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
</Dependencies>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[16.0,17.0)" DisplayName="Visual Studio core editor" />
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[16.0,18.0)" DisplayName="Visual Studio core editor" />
</Prerequisites>
<Assets>
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public IEnumerable<ITagSpan<TextMarkerTag>> GetTags(NormalizedSnapshotSpanCollec

if (spans[0].Snapshot != currentChar.Snapshot)
{
currentChar = currentChar.TranslateTo(spans[0].Snapshot, PointTrackingMode.Positive);
yield break;
//currentChar = currentChar.TranslateTo(spans[0].Snapshot, PointTrackingMode.Positive);
}

char currentText = currentChar.Position == currentChar.Snapshot.Length ? '\0' : currentChar.GetChar();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public ITagger<T> CreateTagger<T>(ITextView textView, ITextBuffer buffer) where
{
ITextStructureNavigator? navigator = _textStructureNavigatorSelector?.GetTextStructureNavigator(textView.TextBuffer);

var tagger = buffer.Properties.GetOrCreateSingletonProperty(() =>
new SameWordHighlighterTagger(textView, buffer, _textSearchService, navigator, this));
SameWordHighlighterTagger tagger = buffer.Properties.GetOrCreateSingletonProperty(() =>
new SameWordHighlighterTagger(textView, _textSearchService, navigator, this));
tagger.RegisterEvents(textView);

return (ITagger<T>)tagger;
Expand All @@ -72,16 +72,12 @@ internal class SameWordHighlighterTagger : ITagger<HighlightWordTag>
private NormalizedSnapshotSpanCollection _wordSpans;
private SnapshotSpan? _currentWord;
private SnapshotPoint _requestedPoint;
private bool _isDisposed;
private string _fileName="";
private readonly object _syncLock = new();

public SameWordHighlighterTagger(ITextView view, ITextBuffer sourceBuffer, ITextSearchService? textSearchService,
public SameWordHighlighterTagger(ITextView view, ITextSearchService? textSearchService,
ITextStructureNavigator? textStructureNavigator, SameWordHighlighterBase tagger)
{
_fileName = sourceBuffer.GetFileName();
//System.Diagnostics.Debug.WriteLine("Create new tagger for "+_fileName);
_buffer = sourceBuffer;
_buffer = view.TextBuffer;
_textSearchService = textSearchService;
_textStructureNavigator = textStructureNavigator;
_tagger = tagger;
Expand All @@ -92,7 +88,6 @@ public SameWordHighlighterTagger(ITextView view, ITextBuffer sourceBuffer, IText

internal void RegisterEvents(ITextView textView)
{

textView.Caret.PositionChanged += CaretPositionChanged;
textView.LayoutChanged += ViewLayoutChanged;
textView.Closed += TextView_Closed;
Expand All @@ -111,7 +106,7 @@ private void ViewLayoutChanged(object sender, TextViewLayoutChangedEventArgs e)
{
if (e.NewSnapshot != e.OldSnapshot)
{
var view = (ITextView)sender;
ITextView view = (ITextView)sender;
UpdateAtCaretPosition(view.Caret.Position);
}
}
Expand Down

0 comments on commit 9d0db95

Please sign in to comment.