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

Commit 2450e58

Browse files
committed
Move MatchLinesAboveTarget const out of FindMatchingLine
1 parent c37a57e commit 2450e58

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/GitHub.App/Services/NavigationService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public IVsTextView NavigateToEquivalentPosition(IVsTextView sourceView, string t
3434

3535
var fromLines = ReadLines(text1);
3636
var toLines = ReadLines(text2);
37-
var matchingLine = FindMatchingLine(fromLines, toLines, line);
37+
var matchingLine = FindMatchingLine(fromLines, toLines, line, matchLinesAbove: MatchLinesAboveTarget);
3838
if (matchingLine == -1)
3939
{
4040
// If we can't match line use orignal as best guess.
@@ -68,11 +68,11 @@ public IVsTextView FindActiveView()
6868
/// <param name="toLines">The document we're navigating to.</param>
6969
/// <param name="line">The 0-based line we're navigating from.</param>
7070
/// <returns>The best matching line in <see cref="toLines"/></returns>
71-
public int FindMatchingLine(IList<string> fromLines, IList<string> toLines, int line)
71+
public int FindMatchingLine(IList<string> fromLines, IList<string> toLines, int line, int matchLinesAbove = 0)
7272
{
7373
var matchingLine = -1;
7474
var minMatchedLines = -1;
75-
for (var offset = 0; offset <= MatchLinesAboveTarget; offset++)
75+
for (var offset = 0; offset <= matchLinesAbove; offset++)
7676
{
7777
var targetLine = line - offset;
7878
if (targetLine < 0)

test/UnitTests/GitHub.App/Services/NavigationServiceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void FindNearestMatchingLine(IList<string> fromLines, IList<string> toLin
3939
{
4040
var target = CreateNavigationService();
4141

42-
var nearestLine = target.FindMatchingLine(fromLines, toLines, line);
42+
var nearestLine = target.FindMatchingLine(fromLines, toLines, line, matchLinesAbove: 1);
4343

4444
Assert.That(nearestLine, Is.EqualTo(matchingLine));
4545
}

0 commit comments

Comments
 (0)