1- using System ;
2- using System . ComponentModel . Composition ;
1+ using System . ComponentModel . Composition ;
32using Microsoft . VisualStudio ;
43using Microsoft . VisualStudio . Shell ;
54using Microsoft . VisualStudio . Shell . Interop ;
65using Microsoft . VisualStudio . TextManager . Interop ;
6+ using IServiceProvider = System . IServiceProvider ;
77
88namespace GitHub . Services
99{
@@ -22,16 +22,16 @@ public IVsTextView NavigateToEquivalentPosition(IVsTextView sourceView, string t
2222 {
2323 int line ;
2424 int column ;
25- sourceView . GetCaretPos ( out line , out column ) ;
25+ ErrorHandler . ThrowOnFailure ( sourceView . GetCaretPos ( out line , out column ) ) ;
2626 var text1 = GetText ( sourceView ) ;
2727
2828 var view = OpenDocument ( targetFile ) ;
2929 var text2 = VsShellUtilities . GetRunningDocumentContents ( serviceProvider , targetFile ) ;
3030
3131 var equivalentLine = FindEquivalentLine ( text1 , text2 , line ) ;
3232
33- view . SetCaretPos ( equivalentLine , column ) ;
34- view . CenterLines ( equivalentLine , 1 ) ;
33+ ErrorHandler . ThrowOnFailure ( view . SetCaretPos ( equivalentLine , column ) ) ;
34+ ErrorHandler . ThrowOnFailure ( view . CenterLines ( equivalentLine , 1 ) ) ;
3535
3636 return view ;
3737 }
@@ -46,6 +46,12 @@ public IVsTextView FindActiveView()
4646
4747 int FindEquivalentLine ( string text1 , string text2 , int line )
4848 {
49+ if ( text1 == text2 )
50+ {
51+ return line ;
52+ }
53+
54+ // TODO: Add best guess line matching when target file has been modified.
4955 return line ;
5056 }
5157
0 commit comments