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

Bookmarks

LeeMSilver opened this issue · comments

In the current extension model Bookmarks are accessed/created/deleted via the EditPoint2 Interface in EnvDTE880.

The new extension model has no need for EditPoint2 due to the use of ITextDocumentEditor.

My extension uses Bookmarks in 2 scenarios.

  1. One of its commands iterates thru the source-files opened in VS and Bookmarks those have a different namespace than the first file checked.

  2. Code similar to the following pseudo-code:

     CompilationUnitSyntax root = ...;
    
     EditPoint2 epTop = StartOfDocument();
     EditPoint2 epEnd = EndOfDocumentX();
    
     epTop.Delete(epEnd);
     epTop.Insert(wRoot.ToFullString());
    

causes all Bookmarks in the document to be deleted.
The extension does the following to minimize the effect of the deleted Bookmarks:
a) prior to the above code it saves the line-numbers of all Bookmarked lines
b) following the above code it tries to set Bookmarks on the saved line-numbers

I'm fairly sure the if the content of ITextDocumentEditor is completely replaced all existing Bookmarks in the document will also be deleted.

If by some miracle the above statement is not true, (2) above will no longer be a problem, but (1) still needs to be implemented.
How can I accomplish the above without using EditPoint2 either now or in the future?