diff --git a/src/GitHub.App/Services/PullRequestEditorService.cs b/src/GitHub.App/Services/PullRequestEditorService.cs index db4889e936..6b9608019b 100644 --- a/src/GitHub.App/Services/PullRequestEditorService.cs +++ b/src/GitHub.App/Services/PullRequestEditorService.cs @@ -298,13 +298,13 @@ public Task OpenDiff( } /// - public async Task OpenDiff(IPullRequestSession session, string relativePath, string headSha, int fromLine) + public async Task OpenDiff(IPullRequestSession session, string relativePath, string headSha, int nextInlineTagFromLine) { var diffViewer = await OpenDiff(session, relativePath, headSha, scrollToFirstDraftOrDiff: false); var param = (object) new InlineCommentNavigationParams { - FromLine = fromLine, + FromLine = nextInlineTagFromLine, }; // HACK: We need to wait here for the inline comment tags to initialize so we can find the next inline comment. diff --git a/src/GitHub.App/ViewModels/GitHubPane/PullRequestFilesViewModel.cs b/src/GitHub.App/ViewModels/GitHubPane/PullRequestFilesViewModel.cs index 6f7ef97e54..e367d9611b 100644 --- a/src/GitHub.App/ViewModels/GitHubPane/PullRequestFilesViewModel.cs +++ b/src/GitHub.App/ViewModels/GitHubPane/PullRequestFilesViewModel.cs @@ -83,7 +83,10 @@ private async Task OpenFirstAnnotation(IPullRequestEditorService editorService, if (annotationModel != null) { - await editorService.OpenDiff(pullRequestSession, file.RelativePath, annotationModel.HeadSha, annotationModel.EndLine); + //AnnotationModel.EndLine is a 1-based number + //EditorService.OpenDiff takes a 0-based line number to start searching AFTER and will open the next tag + var nextInlineCommentFromLine = annotationModel.EndLine - 2; + await editorService.OpenDiff(pullRequestSession, file.RelativePath, annotationModel.HeadSha, nextInlineCommentFromLine); } } @@ -247,7 +250,7 @@ async Task GetFirstAnnotation(IPullRequestFileNode file, var sessionFile = await pullRequestSession.GetFile(file.RelativePath); var annotations = sessionFile.InlineAnnotations; - return annotations.FirstOrDefault(model => model.AnnotationLevel == annotationLevel); + return annotations.OrderBy(model => model.EndLine).FirstOrDefault(model => model.AnnotationLevel == annotationLevel); } /// diff --git a/src/GitHub.Exports.Reactive/Models/InlineAnnotationModel.cs b/src/GitHub.Exports.Reactive/Models/InlineAnnotationModel.cs index c102614014..cee1391194 100644 --- a/src/GitHub.Exports.Reactive/Models/InlineAnnotationModel.cs +++ b/src/GitHub.Exports.Reactive/Models/InlineAnnotationModel.cs @@ -35,12 +35,12 @@ public InlineAnnotationModel(CheckSuiteModel checkSuite, CheckRunModel checkRun, public string Path => annotation.Path; /// - /// Gets the start line of the annotation. + /// Gets the 1-based start line of the annotation. /// public int StartLine => annotation.StartLine; /// - /// Gets the end line of the annotation. + /// Gets the 1-based end line of the annotation. /// public int EndLine => annotation.EndLine; diff --git a/src/GitHub.Exports.Reactive/Services/IPullRequestEditorService.cs b/src/GitHub.Exports.Reactive/Services/IPullRequestEditorService.cs index 954f0a6e34..53855dc416 100644 --- a/src/GitHub.Exports.Reactive/Services/IPullRequestEditorService.cs +++ b/src/GitHub.Exports.Reactive/Services/IPullRequestEditorService.cs @@ -55,9 +55,9 @@ public interface IPullRequestEditorService /// The commit SHA of the right hand side of the diff. Pass null to compare with the /// working directory, or "HEAD" to compare with the HEAD commit of the pull request. /// - /// The line number to open + /// The 0-based line number to execute NextInlineCommentCommand from /// The opened diff viewer. - Task OpenDiff(IPullRequestSession session, string relativePath, string headSha, int fromLine); + Task OpenDiff(IPullRequestSession session, string relativePath, string headSha, int nextInlineTagFromLine); /// /// Find the active text view. diff --git a/src/GitHub.Exports/Models/AnnotationModel.cs b/src/GitHub.Exports/Models/AnnotationModel.cs index 3f8dc694b6..8981b9d719 100644 --- a/src/GitHub.Exports/Models/AnnotationModel.cs +++ b/src/GitHub.Exports/Models/AnnotationModel.cs @@ -6,12 +6,12 @@ public class CheckRunAnnotationModel { /// - /// The starting line number (1 indexed). + /// The starting 1-based line number (1 indexed). /// public int StartLine { get; set; } /// - /// The ending line number (1 indexed). + /// The ending 1-based line number (1 indexed). /// public int EndLine { get; set; } diff --git a/src/GitHub.InlineReviews/Commands/NextInlineCommentCommand.cs b/src/GitHub.InlineReviews/Commands/NextInlineCommentCommand.cs index e6b4c35f50..42ea92d69a 100644 --- a/src/GitHub.InlineReviews/Commands/NextInlineCommentCommand.cs +++ b/src/GitHub.InlineReviews/Commands/NextInlineCommentCommand.cs @@ -53,7 +53,7 @@ public override Task Execute(InlineCommentNavigationParams parameter) if (tags.Count > 0) { var cursorPoint = GetCursorPoint(textViews[0], parameter); - var next = tags.FirstOrDefault(x => x.Point >= cursorPoint) ?? tags.First(); + var next = tags.FirstOrDefault(x => x.Point > cursorPoint) ?? tags.First(); ShowPeekComments(parameter, next.TextView, next.Tag, textViews); }