microsoft / VSExtensibility

A repo for upcoming changes to extensibility in Visual Studio, the new extensibility model, and language server protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TextViewChangedAsync never called?

znakeeye opened this issue · comments

Using VS 17.9.2 and Microsoft.VisualStudio.Extensibility.Sdk 17.9.2092. Trying to get a simple TextViewEventListener to signal when I edit any opened document. So far, I'm only able to get into the constructor.

What am I missing?

[VisualStudioContribution]
internal class TextViewEventListener : ExtensionPart, ITextViewOpenClosedListener, ITextViewChangedListener
{
  public TextViewEventListener(MyTestExtension extension, VisualStudioExtensibility extensibility)
      : base(extension, extensibility)
  {
  }

  public TextViewExtensionConfiguration TextViewExtensionConfiguration => new()
  {
      AppliesTo = new[]
      {
          DocumentFilter.FromDocumentType(DocumentType.KnownValues.Text)
      },
  };

  public Task TextViewChangedAsync(TextViewChangedArgs args, CancellationToken cancellationToken)
  {
      throw new NotImplementedException("Never called...");
  }

  public async Task TextViewClosedAsync(ITextViewSnapshot textViewSnapshot, CancellationToken cancellationToken)
  {
      throw new NotImplementedException("Never called...");
  }

  public Task TextViewOpenedAsync(ITextViewSnapshot textViewSnapshot, CancellationToken cancellationToken)
  {
      throw new NotImplementedException("Never called...");
  }

@znakeeye, off hand I don't see any outstanding issues, it should work, the issue is likely in other parts of your extension. Are you still blocked by this? Please describe it a bit more details how you create this. Thanks!
Additionally, the new Diagnostic Explorer extension can help you spot the issue: https://marketplace.visualstudio.com/items?itemName=vsext.VisualStudio-Extensibility-Diagnostics-Explorer

I'll create a sample project and get back to you soon.