public static void NavigateTo(this IServiceProvider serviceProvider, string fileName, int startLine, int startColumn) { Guid logicalViewGuid = new Guid(LogicalViewID.TextView); IVsUIHierarchy hierarchy; uint itemId; IVsWindowFrame frame; bool isOpened = VsShellUtilities.IsDocumentOpen(serviceProvider, fileName, logicalViewGuid, out hierarchy, out itemId, out frame); if (!isOpened) { try { VsShellUtilities.OpenDocument(serviceProvider, fileName, logicalViewGuid, out hierarchy, out itemId, out frame); } catch (Exception) { // TODO: write error to output return; } } frame.Show(); IVsTextLines textBuffer; VsShellUtilities.GetTextView(frame).GetBuffer(out textBuffer); IVsTextManager manager = serviceProvider.GetService <IVsTextManager, SVsTextManager>(); manager.NavigateToLineAndColumn(textBuffer, logicalViewGuid, startLine, startColumn, startLine, startColumn); }
/// <summary> /// Open the file and jump to a line (and optional column) /// </summary> public static void OpenAndNavigateTo(string fileName, int line, int column = 0) { IVsUIShellOpenDocument uishellOpenDocument = Package.GetGlobalService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (uishellOpenDocument != null) { Microsoft.VisualStudio.OLE.Interop.IServiceProvider serviceProvider; IVsWindowFrame frame; IVsUIHierarchy hierarchy; uint itemId; Guid logicalView = VSConstants.LOGVIEWID_Code; if (ErrorHandler.Succeeded(uishellOpenDocument.OpenDocumentViaProject(fileName, ref logicalView, out serviceProvider, out hierarchy, out itemId, out frame))) { object document; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out document); VsTextBuffer buffer = document as VsTextBuffer; if (buffer == null) { IVsTextBufferProvider bufferProvider = document as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; ErrorHandler.ThrowOnFailure(bufferProvider.GetTextBuffer(out lines)); buffer = lines as VsTextBuffer; } } if (buffer != null) { IVsTextManager textManager = Package.GetGlobalService(typeof(VsTextManagerClass)) as IVsTextManager; textManager.NavigateToLineAndColumn(buffer, ref logicalView, line, column, line, column); } } } }
public override bool ShowMethod(EventDescription eventDescription, string methodName) { CodeDomDocDataAdapter adapter = GetDocDataAdapterForXSharpFile(); List <CodeTypeMember> methodsToShow = GetHandlersFromActiveFile(methodName); if (methodsToShow == null || methodsToShow.Count < 1) { return(false); } Point point = new Point(); if (methodsToShow[0] != null) { //We can't navigate to every method, so just take the first one in the list. object pt = methodsToShow[0].UserData[typeof(Point)]; if (pt != null) { point = (Point)pt; } } //Get IVsTextManager to navigate to the code IVsTextManager mgr = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(VsTextManagerClass)) as IVsTextManager; Guid logViewCode = VSConstants.LOGVIEWID_Code; return(ErrorHandler.Succeeded(mgr.NavigateToLineAndColumn(adapter.DocData.Buffer, ref logViewCode, point.Y - 1, point.X, point.Y - 1, point.X))); }
private void OpenDocumentAndNavigateTo(string path, int startLine, int startColumn, int?endLine = null, int?endColumn = null) { IVsUIShellOpenDocument openDoc = Package.GetGlobalService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDoc == null) { return; } Guid logicalView = VSConstants.LOGVIEWID_Code; IVsWindowFrame frame; try { Microsoft.VisualStudio.OLE.Interop.IServiceProvider sp; IVsUIHierarchy hier; uint itemid; openDoc.OpenDocumentViaProject(path, ref logicalView, out sp, out hier, out itemid, out frame); } catch (Exception) { return; } object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); // Get the VsTextBuffer VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; try { bufferProvider.GetTextBuffer(out lines); } catch (Exception) { return; } buffer = lines as VsTextBuffer; Debug.Assert(buffer != null, "IVsTextLines does not implement IVsTextBuffer"); } } IVsTextManager mgr = Package.GetGlobalService(typeof(VsTextManagerClass)) as IVsTextManager; if (mgr == null) { return; } mgr.NavigateToLineAndColumn(buffer, ref logicalView, startLine - 1, startColumn - 1, (endLine ?? startLine) - 1, (endColumn ?? startColumn) - 1); }
public static void OpenDocumentAndNavigateTo(string path, int line, int column) { IVsUIShellOpenDocument openDoc = Package.GetGlobalService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDoc == null) { return; } IVsWindowFrame frame; Microsoft.VisualStudio.OLE.Interop.IServiceProvider sp; IVsUIHierarchy hier; uint itemid; Guid logicalView = VSConstants.LOGVIEWID_Code; if (ErrorHandler.Failed( openDoc.OpenDocumentViaProject(path, ref logicalView, out sp, out hier, out itemid, out frame)) || frame == null) { return; } object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); // Get the VsTextBuffer VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; ErrorHandler.ThrowOnFailure(bufferProvider.GetTextBuffer(out lines)); buffer = lines as VsTextBuffer; Debug.Assert(buffer != null, "IVsTextLines does not implement IVsTextBuffer"); if (buffer == null) { return; } } } // Finally, perform the navigation. IVsTextManager mgr = Package.GetGlobalService(typeof(VsTextManagerClass)) as IVsTextManager; if (mgr == null) { return; } mgr.NavigateToLineAndColumn(buffer, ref logicalView, line, column, line, column); }
/// <include file='doc\TextBuffer.uex' path='docs/doc[@for="TextBuffer.ShowCode2"]/*' /> /// <devdoc> /// If there is a text view associated with this buffer, this will /// attempt to surface this view to the user. The caret will be /// moved to lineNum, columnNum. /// </devdoc> public override void ShowCode(int lineNum, int columnNum) { try { // First get the frame of the code editor. // IVsWindowFrame frame = GetWindowFrame(LOGVIEWID.LOGVIEWID_Code); // Next ask the text manager to navigate to the requested place. // Object obj = null; #if GETPROPERTY_MARSHAL int hr = frame.GetProperty(__VSFPROPID.VSFPROPID_DocView, ref obj); if (!win.Succeeded(hr)) { throw new COMException("Error retrieving document view", hr); } #else obj = frame.GetProperty(__VSFPROPID.VSFPROPID_DocView); #endif IVsCodeWindow codeWindow = (IVsCodeWindow)obj; // Buffer is zero based. if (lineNum > 0) { lineNum--; } if (columnNum > 0) { columnNum--; } Debug.Assert(codeWindow != null, "Cannot get to code editor"); if (codeWindow != null) { IVsTextLines textLines; codeWindow.GetBuffer(out textLines); IVsTextManager mgr = (IVsTextManager)serviceProvider. GetService(typeof(VsTextManager)); if (mgr != null) { mgr.NavigateToLineAndColumn((IVsTextBuffer)textLines, ref LOGVIEWID.LOGVIEWID_Code, lineNum, columnNum, lineNum, columnNum); } } // And finally, show the frame. // // SBurke, Naviagate to position should do the show... //frame.Show(); } catch (Exception ex) { Debug.Fail("Could not show text editor because: " + ex.ToString()); } }
public void GoTo(int line = 0, int column = 0, int length = 0) { Guid logicalView = VSConstants.LOGVIEWID.Primary_guid; var buffer = SelectionPage.TextView.TextBuffer as IVsTextBuffer; IVsTextManager mgr = BabePackage.Current.GetService(typeof(VsTextManagerClass)) as IVsTextManager; mgr.NavigateToLineAndColumn(buffer, ref logicalView, line, column, line, column + length); }
private void NavigateTo(object sender, EventArgs arguments) { Microsoft.VisualStudio.Shell.Task task = sender as Microsoft.VisualStudio.Shell.Task; if (task == null) throw new ArgumentException("sender"); // Get the doc data for the task's document if (String.IsNullOrEmpty(task.Document)) return; IVsUIShellOpenDocument openDoc = serviceProvider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDoc == null) return; IVsWindowFrame frame; IOleServiceProvider sp; IVsUIHierarchy hier; uint itemid; Guid logicalView = VSConstants.LOGVIEWID_Code; if (Microsoft.VisualStudio.ErrorHandler.Failed(openDoc.OpenDocumentViaProject(task.Document, ref logicalView, out sp, out hier, out itemid, out frame)) || frame == null) return; object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); // Get the VsTextBuffer VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(bufferProvider.GetTextBuffer(out lines)); buffer = lines as VsTextBuffer; Debug.Assert(buffer != null, "IVsTextLines does not implement IVsTextBuffer"); if (buffer == null) return; } } // Finally, perform the navigation. IVsTextManager mgr = serviceProvider.GetService(typeof(VsTextManagerClass)) as IVsTextManager; if (mgr == null) return; mgr.NavigateToLineAndColumn(buffer, ref logicalView, task.Line, task.Column, task.Line, task.Column); }
/// <summary> /// Navigate to the file, line and column reported in the task /// </summary> /// <param name="sender">The Task to navigate to</param> /// <param name="arguments">The event arguments</param> private void NavigateTo(object sender, EventArgs arguments) { #if Dev17 var task = sender as TaskListItem; #else var task = sender as Task; #endif if (task == null || string.IsNullOrEmpty(task.Document)) { // nothing to navigate to return; } IVsWindowFrame frame; Microsoft.VisualStudio.OLE.Interop.IServiceProvider sp; IVsUIHierarchy hier; uint itemid; Guid logicalView = VSConstants.LOGVIEWID_Code; if (ErrorHandler.Failed(m_shellOpenDocument.OpenDocumentViaProject(task.Document, ref logicalView, out sp, out hier, out itemid, out frame)) || frame == null) { return; } object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); // Get the VsTextBuffer var buffer = docData as VsTextBuffer; if (buffer == null) { var bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; ErrorHandler.ThrowOnFailure(bufferProvider.GetTextBuffer(out lines)); buffer = lines as VsTextBuffer; if (buffer == null) { return; } } } m_textManager.NavigateToLineAndColumn(buffer, ref logicalView, task.Line, task.Column, task.Line, task.Column); }
internal bool NavigateTo(VirtualSnapshotPoint point) { var tuple = SnapshotPointUtil.GetLineColumn(point.Position); var line = tuple.Item1; var column = tuple.Item2; var vsBuffer = _vsAdapter.EditorAdapter.GetBufferAdapter(point.Position.Snapshot.TextBuffer); var viewGuid = VSConstants.LOGVIEWID_Code; var hr = _textManager.NavigateToLineAndColumn( vsBuffer, ref viewGuid, line, column, line, column); return(ErrorHandler.Succeeded(hr)); }
public override void NavigateToFileAndPosition(string file, int line, int col, int lineEnd = 0, int columnEnd = 0) { IVsUIShellOpenDocument openDoc = AspectPackage.GetGlobalService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; IVsWindowFrame frame; Microsoft.VisualStudio.OLE.Interop.IServiceProvider sp; IVsUIHierarchy hier; uint itemid; Guid logicalView = VSConstants.LOGVIEWID_Code; if (ErrorHandler.Failed(openDoc.OpenDocumentViaProject(file, ref logicalView, out sp, out hier, out itemid, out frame)) || frame == null) { return; } object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); // Get the VsTextBuffer VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; ErrorHandler.ThrowOnFailure(bufferProvider.GetTextBuffer(out lines)); buffer = lines as VsTextBuffer; if (buffer == null) { return; } } } IVsTextManager mgr = AspectPackage.GetGlobalService(typeof(VsTextManagerClass)) as IVsTextManager; if (lineEnd == 0) { lineEnd = line; columnEnd = col; } mgr.NavigateToLineAndColumn(buffer, ref logicalView, line - 1, col, lineEnd - 1, columnEnd); }
private void NavigateTo(object sender, EventArgs arguments) { try { Microsoft.VisualStudio.Shell.Task task = sender as Microsoft.VisualStudio.Shell.Task; if (task == null) { throw new ArgumentException("sender"); } // Get the doc data for the task's document if (String.IsNullOrEmpty(task.Document)) { return; } IVsUIShellOpenDocument openDoc = serviceProvider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDoc == null) { return; } IVsWindowFrame frame; IOleServiceProvider sp; IVsUIHierarchy hier; uint itemid; Guid logicalView = VSConstants.LOGVIEWID_Code; if (Microsoft.VisualStudio.ErrorHandler.Failed(openDoc.OpenDocumentViaProject(task.Document, ref logicalView, out sp, out hier, out itemid, out frame)) || frame == null) { return; } object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); // Get the VsTextBuffer VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(bufferProvider.GetTextBuffer(out lines)); buffer = lines as VsTextBuffer; Debug.Assert(buffer != null, "IVsTextLines does not implement IVsTextBuffer"); if (buffer == null) { return; } } } // Finally, perform the navigation. IVsTextManager mgr = serviceProvider.GetService(typeof(VsTextManagerClass)) as IVsTextManager; if (mgr == null) { return; } // We should use the full span information if we've been given a DocumentTask bool isDocumentTask = task is DocumentTask; int endLine = isDocumentTask ? ((DocumentTask)task).Span.iEndLine : task.Line; int endColumn = isDocumentTask ? ((DocumentTask)task).Span.iEndIndex : task.Column; mgr.NavigateToLineAndColumn(buffer, ref logicalView, task.Line, task.Column, endLine, endColumn); } catch (Exception e) { System.Diagnostics.Debug.Assert(false, "Error thrown from NavigateTo. " + e.ToString()); } }
public static async void Error_Task_Navigate_Handler(object sender, EventArgs arguments) { if (!ThreadHelper.CheckAccess()) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); } Microsoft.VisualStudio.Shell.Task task = sender as Microsoft.VisualStudio.Shell.Task; if (task == null) { throw new ArgumentException("sender parm cannot be null"); } if (string.IsNullOrEmpty(task.Document)) { Output_INFO("AsmDudeToolsStatic:Error_Task_Navigate_Handler: task.Document is empty"); return; } Output_INFO("AsmDudeToolsStatic: Error_Task_Navigate_Handler: task.Document=" + task.Document); IVsUIShellOpenDocument openDoc = Package.GetGlobalService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDoc == null) { Output_INFO("AsmDudeToolsStatic:Error_Task_Navigate_Handler: openDoc is null"); return; } Guid logicalView = VSConstants.LOGVIEWID_Code; int hr = openDoc.OpenDocumentViaProject(task.Document, ref logicalView, out Microsoft.VisualStudio.OLE.Interop.IServiceProvider serviceProvider, out IVsUIHierarchy hierarchy, out uint itemId, out IVsWindowFrame frame); if (ErrorHandler.Failed(hr) || (frame == null)) { Output_INFO("AsmDudeToolsStatic:Error_Task_Navigate_Handler: OpenDocumentViaProject failed"); return; } frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out object docData); VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { if (docData is IVsTextBufferProvider bufferProvider) { ErrorHandler.ThrowOnFailure(bufferProvider.GetTextBuffer(out IVsTextLines lines)); buffer = lines as VsTextBuffer; if (buffer == null) { Output_INFO("INFO: AsmDudeToolsStatic:Error_Task_Navigate_Handler: buffer is null"); return; } } } IVsTextManager mgr = Package.GetGlobalService(typeof(SVsTextManager)) as IVsTextManager; if (mgr == null) { Output_INFO("AsmDudeToolsStatic:Error_Task_Navigate_Handler: IVsTextManager is null"); return; } //Output("INFO: AsmDudeToolsStatic:errorTaskNavigateHandler: navigating to row="+task.Line); int iStartIndex = task.Column & 0xFFFF; int iEndIndex = (task.Column >> 16) & 0xFFFF; mgr.NavigateToLineAndColumn(buffer, ref logicalView, task.Line, iStartIndex, task.Line, iEndIndex); }
private void NavigateToHandler(object sender, System.EventArgs args) { Microsoft.VisualStudio.Shell.Task task = sender as Microsoft.VisualStudio.Shell.Task; if (task == null) { throw new System.ArgumentException("sender"); } // Open the document. if (string.IsNullOrEmpty(task.Document)) { return; } IVsUIShellOpenDocument openDocument = m_serviceProvider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDocument == null) { return; } IVsWindowFrame frame; IOleServiceProvider serviceProvider; IVsUIHierarchy hierarchy; uint itemId; System.Guid logicalView = VSConstants.LOGVIEWID_Code; if (Failed(openDocument.OpenDocumentViaProject(task.Document, ref logicalView, out serviceProvider, out hierarchy, out itemId, out frame)) || frame == null) { return; } // Get the text buffer. object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; ThrowOnFailure(bufferProvider.GetTextBuffer(out lines)); buffer = lines as VsTextBuffer; if (buffer == null) { return; } } } // Perform the navigation. IVsTextManager manager = m_serviceProvider.GetService(typeof(VsTextManagerClass)) as IVsTextManager; if (manager == null) { return; } manager.NavigateToLineAndColumn(buffer, ref logicalView, task.Line, task.Column, task.Line, task.Column); }
/// <include file='doc\TaskProvider.uex' path='docs/doc[@for="Navigate"]/*' /> /// <devdoc> /// Navigates the document in the given task to the given logical view. /// </devdoc> public bool Navigate(Task task, Guid logicalView) { if (task == null) { throw new ArgumentNullException("task"); } // Get the doc data for the task's document if (task.Document == null || task.Document.Length == 0) { return(false); } IVsUIShellOpenDocument openDoc = GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDoc == null) { return(false); } IVsWindowFrame frame; IOleServiceProvider sp; IVsUIHierarchy hier; uint itemid; Guid logView = logicalView; if (NativeMethods.Failed(openDoc.OpenDocumentViaProject(task.Document, ref logView, out sp, out hier, out itemid, out frame)) || frame == null) { return(false); } object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; NativeMethods.ThrowOnFailure(bufferProvider.GetTextBuffer(out lines)); buffer = lines as VsTextBuffer; Debug.Assert(buffer != null, "IVsTextLines does not implement IVsTextBuffer"); if (buffer == null) { return(false); } } } // Finally, perform the navigation. IVsTextManager mgr = GetService(typeof(VsTextManagerClass)) as IVsTextManager; if (mgr == null) { return(false); } int line = task.Line; // Buffer is zero based if (line > 0) { line--; } mgr.NavigateToLineAndColumn(buffer, ref logicalView, line, 0, line, 0); return(true); }
// // Plumbing - an event handler for when a Task is double-clicked, i.e. // to navigate to the code causing a parser error. // internal async void NavigationHandler(object sender, EventArgs args) { var task = sender as Microsoft.VisualStudio.Shell.Task; if (string.IsNullOrEmpty(task.Document)) { return; } await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var serviceProvider = new ParseSession.ErrorListHelper(); var openDoc = serviceProvider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDoc == null) { return; } IVsWindowFrame frame; Microsoft.VisualStudio.OLE.Interop.IServiceProvider sp; IVsUIHierarchy hier; uint itemid; Guid logicalView = VSConstants.LOGVIEWID_Code; if (ErrorHandler.Failed(openDoc.OpenDocumentViaProject(task.Document, ref logicalView, out sp, out hier, out itemid, out frame)) || frame == null) { return; } object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; ErrorHandler.ThrowOnFailure(bufferProvider.GetTextBuffer(out lines)); buffer = lines as VsTextBuffer; if (buffer == null) { return; } } } IVsTextManager mgr = serviceProvider.GetService(typeof(VsTextManagerClass)) as IVsTextManager; if (mgr == null) { return; } // This whole mess could arguably be a lot simpler as a call to ErrorProvider.Navigate(). // Unfortunately that API assumes 1-based column/line indices, whereas our task (in order // to display correctly in the task list) assumes 0-based. This can be worked around with // a trivial addition/substraction, but the kicker is that the column is not used by that // particular API. Therefore to preserve the column we do all this crazy stuff instead. mgr.NavigateToLineAndColumn(buffer, ref logicalView, task.Line, task.Column, task.Line, task.Column); }
private void NavigateHandler(object sender, EventArgs arguments) { Microsoft.VisualStudio.Shell.Task task = sender as Microsoft.VisualStudio.Shell.Task; if (task == null) { throw new ArgumentException("sender parm cannot be null"); } if (String.IsNullOrEmpty(task.Document)) { return; } IVsUIShellOpenDocument openDoc = GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDoc == null) { return; } IVsWindowFrame frame; Microsoft.VisualStudio.OLE.Interop.IServiceProvider serviceProvider; IVsUIHierarchy hierarchy; uint itemId; Guid logicalView = VSConstants.LOGVIEWID_Code; if (ErrorHandler.Failed(openDoc.OpenDocumentViaProject( task.Document, ref logicalView, out serviceProvider, out hierarchy, out itemId, out frame)) || frame == null) { return; } object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; ErrorHandler.ThrowOnFailure(bufferProvider.GetTextBuffer(out lines)); buffer = lines as VsTextBuffer; if (buffer == null) { return; } } } IVsTextManager mgr = GetService(typeof(VsTextManagerClass)) as IVsTextManager; if (mgr == null) { return; } mgr.NavigateToLineAndColumn(buffer, ref logicalView, task.Line, task.Column, task.Line, task.Column); }