none
VS Shell / Package: GoTo Line is not working in custom editor.

    Question

  • Hello,

    I am creating a new custom WPF Editor in VS2010 and I noticed that the GoTo line / menu's is not working. When my editor first opens then the menu is enabled but the line count in the menu shows that i can go to line 1 (only 1 line in the document), but as soon as I click cancel all of the goto menu's and keyboard shortcuts are disabled. I set a breakpoint on any code that returns a line count and it still has this same behavior. I really don't want to implement this using a custom goto dialog and this code:

    addCommand(mcs, VSConstants.GUID_VSStandardCommandSet97, (intVSConstants.VSStd97CmdID.Goto, OnGoto, OnQueryGoto);

    Has anyone else run into this behavior?

     

        [ComSourceInterfaces(typeof (IVsTextViewEvents))]
        [ComVisible(true)]
        public abstract class EditorPaneBase :
            WindowPane,
            IPersistFileFormat//to Enable persistence functionality for document data.
            IVsPersistDocData2//to Enable persistence functionality for document data.
            IVsFileChangeEvents//to notify the client when file changes on disk
            IVsDocDataFileChangeControl//to Determine whether changes to files made outside of the editor should be ignored
            IVsFileBackup//to support backup of files. Visual Studio File Recovery backs up all objects in the Running Document Table that support IVsFileBackup and have unsaved changes.
            IVsStatusbarUser//support updating the status bar
            IVsFindTarget//to implement find and replace capabilities within the editor
            IVsTextImage//to support find and replace in a text image
            IVsTextSpanSet//needed for Find and Replace to work appropriately
            IVsTextView//Manages the text view of an editor window. Contains methods to manage the text view. The view is essentially the editor window shown in the UI.
            IVsCodeWindow//needed for Find and Replace to work appropriately
            IVsTextLines//needed for Find and Replace to work appropriately
            IVsToolboxUser//Sends notification about Toolbox items to the owner of these items
            IExtensibleObject,  //so we can get the atuomation object
            Document

     

    I've checked the following methods and this doesn't alter this behavior:

            /// <summary>
            /// To return the number of lines in the text image
            /// </summary>
            /// <param name="pcLines">pointer to the number of lines in the text image</param>
            /// <returns>S_OK</returns>
            int IVsTextImage.GetLineSize(out int pcLines)
            {
                //get the number of the lines in the control
                pcLines = GetTotalLineCount();
                return VSConstants.S_OK;
            }
    	public int GetLineCount(out int piLineCount)
            {
                piLineCount = GetTotalLineCount();
                return VSConstants.S_OK;
            }

    Thanks

    -Blake Niemyjski

    Friday, May 20, 2011 6:41 PM

Answers

  • The Goto line dialog is owned by the built in editor, if you are replacing the built in editor you would need to provide your own Goto line dialog.  The dialog the editor raises could technically be raised by your editor, but it isn't an official public extension point so I don't know how much advice I can offer as to how to go about that, being a Microsoft employee and all.

    Ryan

    • Marked as answer by Victor_Chen Tuesday, May 31, 2011 7:47 AM
    Wednesday, May 25, 2011 11:33 PM
    Moderator

All replies

  • Can you grab a callstack of who is raising the goto dialog in this case?  Both managed + native code and the Microsoft symbol servers on your path.  Looking at the product it looks like the editor itself handles Goto, so it isn't clear to me WHO is bringing up this dialog if you are the one implementing the editor....is it you?  If so, how are you going about it?

    Ryan

    Friday, May 20, 2011 8:02 PM
    Moderator
  • Hello,

    I can't even get the goto menu item to be enabled (now), I confirmed that our editor is not subscribing to the control+g key binding as well. Neither the goto menu or the keyboard shortcut is enabled or working. Do you have any ideas? I can't bring this dialog up in our editor so I can't get you a stack trace. The only way I can get the menu enabled is to add this line to my EditorPane:

     

    addCommand(mcs, VSConstants.GUID_VSStandardCommandSet97, (intVSConstants.VSStd97CmdID.Goto, OnGoto, OnQueryGoto);

    This causes the OnGoTo Event to be fired in code and the menu to be enabled. But then I'm stuck with creating this dialog and doing all the logic which I don't want todo.


    -Blake Niemyjski (Software Development Engineer)
    Monday, May 23, 2011 5:57 PM
  • Hello,

    Does anyone have any ideas on this issue?

    Thanks

    -Blake


    -Blake Niemyjski (Software Development Engineer)
    Wednesday, May 25, 2011 11:02 PM
  • The Goto line dialog is owned by the built in editor, if you are replacing the built in editor you would need to provide your own Goto line dialog.  The dialog the editor raises could technically be raised by your editor, but it isn't an official public extension point so I don't know how much advice I can offer as to how to go about that, being a Microsoft employee and all.

    Ryan

    • Marked as answer by Victor_Chen Tuesday, May 31, 2011 7:47 AM
    Wednesday, May 25, 2011 11:33 PM
    Moderator
  • Hello,

    I just wanted to follow up with you and let you know that I was able to accomplish this using the following method.

    Thanks

    -Blake Niemyjski


    -Blake Niemyjski (Software Development Engineer)
    Thursday, June 02, 2011 9:11 PM
  • That is the non-public way I was alluding to :)  It is of course subject to change, but I can't see it changing in the near term...then again I am not an editor dev.  If we do end up changing it I will try and see if I can expose it as a service type interface for others to call, so you don't have to do what you did above :)

    Ryan

    Thursday, June 02, 2011 10:00 PM
    Moderator
  • Hello,

    That would be great if this exposed. Thanks again :).

    Thanks

    -Blake Niemyjski


    -Blake Niemyjski (Software Development Engineer)
    Friday, June 03, 2011 12:16 PM
  • I've added a feature request here: https://connect.microsoft.com/VisualStudio/feedback/details/743584/add-built-in-support-for-go-to-line-and-its-dialog

    -Blake Niemyjski (Software Development Engineer)


    Thursday, May 24, 2012 4:16 PM
  • I wanted to follow up and let everyone know that this method was broken sometime in VS2012 and 2013. I've logged the issue here: https://connect.microsoft.com/VisualStudio/feedback/details/798015/gotoline-is-no-longer-working-in-2012-2013-when-calling-the-internal-methods-to-show-the-go-to-line-dialog#tabs

    If anyone has a workaround please let me know.


    -Blake Niemyjski (Software Development Engineer)

    Wednesday, August 21, 2013 2:24 PM