We have a VS Package that has a custom editor. We want to show the native go-to line dialog that visual
studio uses. We have had this implemented in 2010 using the following code:
[CommandExecMethod]
[VsCommandId(VSConstants.VSStd97CmdID.Goto)]
protected void ExecuteGoTo()
{
var lineNumber = GetGoToLineNumberFromDialog();
if (lineNumber < 0)
return;
NavigateTo(new TextSpan[]
{
new TextSpan
{
iStartLine = lineNumber,
iStartIndex = 0,
iEndLine = lineNumber,
iEndIndex = 0
}
});
}
protected int GetGoToLineNumberFromDialog()
{
var dataSource = new Microsoft.Internal.VisualStudio.PlatformUI.UIDataSource();
dataSource.AddBuiltInProperty("MinimumLine",
1);
dataSource.AddBuiltInProperty("MaximumLine",
TemplateEditorControl.LineCount);
dataSource.AddBuiltInProperty("CurrentLine",
TemplateEditorControl.CurrentLine);
Microsoft.Internal.VisualStudio.PlatformUI.WindowHelper.AddHelpTopic(dataSource,"vs.gotoline");
if (Microsoft.Internal.VisualStudio.PlatformUI.WindowHelper.ShowModalElement(VSConstants.GUID_VSStandardCommandSet97,
231, dataSource) == 1)
{
var result
= new Microsoft.Internal.VisualStudio.PlatformUI.UIObject(dataSource["CurrentLine"]);
return
(((int)result.Data) - 1);
}
return -1;
}
I recently noticed that this stopped working and is not working in 2012 or 2013.
-Blake Niemyjski (Software Development Engineer)