@@ -123,7 +123,7 @@ async Task DoOpenLiveFile(IPullRequestFileNode file)
123123 {
124124 try
125125 {
126- var activeView = FindActiveView ( ) ;
126+ var activeView = Utilities . FindActiveView ( ) ;
127127 if ( activeView == null )
128128 {
129129 ShowErrorInStatusBar ( "Couldn't find active view" ) ;
@@ -133,9 +133,13 @@ async Task DoOpenLiveFile(IPullRequestFileNode file)
133133 int line ;
134134 int column ;
135135 activeView . GetCaretPos ( out line , out column ) ;
136+ var text1 = Utilities . GetText ( activeView ) ;
136137
137138 var fullPath = ViewModel . GetLocalFilePath ( file ) ;
138- IVsTextView view = OpenDocument ( fullPath ) ;
139+ IVsTextView view = Utilities . OpenDocument ( fullPath ) ;
140+ var text2 = VsShellUtilities . GetRunningDocumentContents ( Services . GitHubServiceProvider , fullPath ) ;
141+
142+ var equivalentLine = Utilities . FindEquivalentLine ( text1 , text2 , line ) ;
139143
140144 view . SetCaretPos ( line , column ) ;
141145 view . CenterLines ( line , 1 ) ;
@@ -149,23 +153,45 @@ async Task DoOpenLiveFile(IPullRequestFileNode file)
149153 }
150154 }
151155
152- static IVsTextView OpenDocument ( string fullPath )
156+ public static class Utilities
153157 {
154- var logicalView = VSConstants . LOGVIEWID . TextView_guid ;
155- IVsUIHierarchy hierarchy ;
156- uint itemID ;
157- IVsWindowFrame windowFrame ;
158- IVsTextView view ;
159- VsShellUtilities . OpenDocument ( Services . GitHubServiceProvider , fullPath , logicalView , out hierarchy , out itemID , out windowFrame , out view ) ;
160- return view ;
161- }
158+ public static object FindEquivalentLine ( string text1 , string text2 , int line )
159+ {
160+ return line ;
161+ }
162162
163- static IVsTextView FindActiveView ( )
164- {
165- var textManager = Services . GitHubServiceProvider . GetService < SVsTextManager , IVsTextManager2 > ( ) ;
166- IVsTextView view ;
167- var hresult = textManager . GetActiveView2 ( 1 , null , ( uint ) _VIEWFRAMETYPE . vftCodeWindow , out view ) ;
168- return hresult == VSConstants . S_OK ? view : null ;
163+ internal static string GetText ( IVsTextView textView )
164+ {
165+ IVsTextLines buffer ;
166+ ErrorHandler . ThrowOnFailure ( textView . GetBuffer ( out buffer ) ) ;
167+
168+ int line ;
169+ int index ;
170+ ErrorHandler . ThrowOnFailure ( buffer . GetLastLineIndex ( out line , out index ) ) ;
171+
172+ string text ;
173+ ErrorHandler . ThrowOnFailure ( buffer . GetLineText ( 0 , 0 , line , index , out text ) ) ;
174+ return text ;
175+ }
176+
177+ internal static IVsTextView OpenDocument ( string fullPath )
178+ {
179+ var logicalView = VSConstants . LOGVIEWID . TextView_guid ;
180+ IVsUIHierarchy hierarchy ;
181+ uint itemID ;
182+ IVsWindowFrame windowFrame ;
183+ IVsTextView view ;
184+ VsShellUtilities . OpenDocument ( Services . GitHubServiceProvider , fullPath , logicalView , out hierarchy , out itemID , out windowFrame , out view ) ;
185+ return view ;
186+ }
187+
188+ internal static IVsTextView FindActiveView ( )
189+ {
190+ var textManager = Services . GitHubServiceProvider . GetService < SVsTextManager , IVsTextManager2 > ( ) ;
191+ IVsTextView view ;
192+ var hresult = textManager . GetActiveView2 ( 1 , null , ( uint ) _VIEWFRAMETYPE . vftCodeWindow , out view ) ;
193+ return hresult == VSConstants . S_OK ? view : null ;
194+ }
169195 }
170196
171197 async Task DoDiffFile ( IPullRequestFileNode file , bool workingDirectory )
0 commit comments