Setting cursor position with Visual Studio Extension

前端 未结 1 1675
耶瑟儿~
耶瑟儿~ 2021-02-06 02:47

I\'m writing my own Visual Studio 2010 Extension that should help me navigating a rather large solution.
I already have a dialog based VS Extension that shows me a class nam

相关标签:
1条回答
  • 2021-02-06 03:44

    I finally got it...
    You just have to use the TextSelectioninterface where you have the method MoveToPoint.
    So the code from above is now:

    // open the file in a VS code window and activate the pane
    Window window = requestedItem.Open(Constants.vsViewKindCode);
    window.Activate();
    
    // get the function element and show it
    CodeElement function = CodeElementSearcher.GetFunction(requestedItem, myFunctionName);
    
    // get the text of the document
    TextSelection textSelection = window.Document.Selection as TextSelection;
    
    // now set the cursor to the beginning of the function
    textSelection.MoveToPoint(function.StartPoint);
    
    0 讨论(0)
提交回复
热议问题