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

Commit 0aae4ca

Browse files
committed
Add support for navigating to a range of lines
1 parent 0bed9b2 commit 0aae4ca

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/GitHub.VisualStudio/Commands/OpenFromUrlCommand.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,21 @@ bool TryOpenFile(GitHubContext context, string repositoryDir)
189189

190190
dte.Value.ItemOperations.OpenFile(fullPath);
191191

192-
var lineNumber = context.Line;
193-
if (lineNumber != null)
192+
var line = context.Line;
193+
var lineEnd = context.LineEnd;
194+
if (line != null)
194195
{
195-
var number = lineNumber.Value - 1;
196196
var activeView = pullRequestEditorService.Value.FindActiveView();
197-
ErrorHandler.ThrowOnFailure(activeView.SetCaretPos(number, 0));
198-
ErrorHandler.ThrowOnFailure(activeView.CenterLines(number, 1));
197+
if (lineEnd != null)
198+
{
199+
ErrorHandler.ThrowOnFailure(activeView.SetSelection(line.Value - 1, 0, lineEnd.Value, 0));
200+
ErrorHandler.ThrowOnFailure(activeView.CenterLines(line.Value - 1, lineEnd.Value - line.Value));
201+
}
202+
else
203+
{
204+
ErrorHandler.ThrowOnFailure(activeView.SetCaretPos(line.Value - 1, 0));
205+
ErrorHandler.ThrowOnFailure(activeView.CenterLines(line.Value - 1, 1));
206+
}
199207
}
200208

201209
return true;

0 commit comments

Comments
 (0)