Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit c07bd16

Browse files
committed
Fix CA errors
1 parent deb07d5 commit c07bd16

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/GitHub.App/Services/NavigationService.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using System;
2-
using System.ComponentModel.Composition;
1+
using System.ComponentModel.Composition;
32
using Microsoft.VisualStudio;
43
using Microsoft.VisualStudio.Shell;
54
using Microsoft.VisualStudio.Shell.Interop;
65
using Microsoft.VisualStudio.TextManager.Interop;
6+
using IServiceProvider = System.IServiceProvider;
77

88
namespace 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

Comments
 (0)