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

Commit 3b0f306

Browse files
Fixing the tag location logic
1 parent 92c59ff commit 3b0f306

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

src/GitHub.App/Services/PullRequestEditorService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,13 @@ public Task<IDifferenceViewer> OpenDiff(
298298
}
299299

300300
/// <inheritdoc/>
301-
public async Task<IDifferenceViewer> OpenDiff(IPullRequestSession session, string relativePath, string headSha, int fromLine)
301+
public async Task<IDifferenceViewer> OpenDiff(IPullRequestSession session, string relativePath, string headSha, int nextInlineTagFromLine)
302302
{
303303
var diffViewer = await OpenDiff(session, relativePath, headSha, scrollToFirstDraftOrDiff: false);
304304

305305
var param = (object) new InlineCommentNavigationParams
306306
{
307-
FromLine = fromLine,
307+
FromLine = nextInlineTagFromLine,
308308
};
309309

310310
// HACK: We need to wait here for the inline comment tags to initialize so we can find the next inline comment.

src/GitHub.App/ViewModels/GitHubPane/PullRequestFilesViewModel.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ private async Task OpenFirstAnnotation(IPullRequestEditorService editorService,
8383

8484
if (annotationModel != null)
8585
{
86-
await editorService.OpenDiff(pullRequestSession, file.RelativePath, annotationModel.HeadSha, annotationModel.EndLine);
86+
//AnnotationModel.EndLine is a 1-based number
87+
//EditorService.OpenDiff takes a 0-based line number to start searching AFTER and will open the next tag
88+
var nextInlineCommentFromLine = annotationModel.EndLine - 2;
89+
await editorService.OpenDiff(pullRequestSession, file.RelativePath, annotationModel.HeadSha, nextInlineCommentFromLine);
8790
}
8891
}
8992

@@ -247,7 +250,7 @@ async Task<InlineAnnotationModel> GetFirstAnnotation(IPullRequestFileNode file,
247250
var sessionFile = await pullRequestSession.GetFile(file.RelativePath);
248251
var annotations = sessionFile.InlineAnnotations;
249252

250-
return annotations.FirstOrDefault(model => model.AnnotationLevel == annotationLevel);
253+
return annotations.OrderBy(model => model.EndLine).FirstOrDefault(model => model.AnnotationLevel == annotationLevel);
251254
}
252255

253256
/// <summary>

src/GitHub.Exports.Reactive/Models/InlineAnnotationModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ public InlineAnnotationModel(CheckSuiteModel checkSuite, CheckRunModel checkRun,
3535
public string Path => annotation.Path;
3636

3737
/// <summary>
38-
/// Gets the start line of the annotation.
38+
/// Gets the 1-based start line of the annotation.
3939
/// </summary>
4040
public int StartLine => annotation.StartLine;
4141

4242
/// <summary>
43-
/// Gets the end line of the annotation.
43+
/// Gets the 1-based end line of the annotation.
4444
/// </summary>
4545
public int EndLine => annotation.EndLine;
4646

src/GitHub.Exports.Reactive/Services/IPullRequestEditorService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public interface IPullRequestEditorService
5555
/// The commit SHA of the right hand side of the diff. Pass null to compare with the
5656
/// working directory, or "HEAD" to compare with the HEAD commit of the pull request.
5757
/// </param>
58-
/// <param name="fromLine">The line number to open</param>
58+
/// <param name="nextInlineTagFromLine">The 0-based line number to execute NextInlineCommentCommand from</param>
5959
/// <returns>The opened diff viewer.</returns>
60-
Task<IDifferenceViewer> OpenDiff(IPullRequestSession session, string relativePath, string headSha, int fromLine);
60+
Task<IDifferenceViewer> OpenDiff(IPullRequestSession session, string relativePath, string headSha, int nextInlineTagFromLine);
6161

6262
/// <summary>
6363
/// Find the active text view.

src/GitHub.Exports/Models/AnnotationModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
public class CheckRunAnnotationModel
77
{
88
/// <summary>
9-
/// The starting line number (1 indexed).
9+
/// The starting 1-based line number (1 indexed).
1010
/// </summary>
1111
public int StartLine { get; set; }
1212

1313
/// <summary>
14-
/// The ending line number (1 indexed).
14+
/// The ending 1-based line number (1 indexed).
1515
/// </summary>
1616
public int EndLine { get; set; }
1717

0 commit comments

Comments
 (0)