Loading editor contents into a tool window in VS 2010 RRS feed

  • Question

  • I've been trying to find the answer to this to no avail...

    On a company project I am working on, we have a VERY large xml file used in a custom ORM project. It has custom elements and attributes and is very difficult to navigate in the editor. What I am looking to do is:

    • When the xml file is on top, go to "View|Other Windows|Navigator" where "navigator" is my custom tool window.
    • Load the xml string that is in the editor into a buffer. <-- missing step!
    • Extract out custom elements and present in a listview so users can click on an item and have the editor jump to that location.

    I have the basic framework in place so I can call up the tool window and dock it... But I have not been able to find out how to read the contents of the editor. I've seen how to do this for extensions that do not have a tool window but not for this case.

    Does anyone have an example of how to load the editor contents into a string in the Tool window? Thanks Harold

    Harold Chattaway Zoll Inc.
    Friday, July 29, 2011 1:25 AM


  • I've never tried this but...

    Request SVsTextManager and cast it to IVsTextManager.

    Call IVsTextManager.GetActiveView passing in true for 'must have focus' and null for the buffer.

    Take the resultant IVsTextView and call GetBuffer to get the IVsTextLines associated with the editor.

    Extract text from there using something like GetLineText?


    Friday, July 29, 2011 6:40 PM