Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/GitHub.App/Services/PullRequestEditorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,13 @@ public Task<IDifferenceViewer> OpenDiff(
}

/// <inheritdoc/>
public async Task<IDifferenceViewer> OpenDiff(IPullRequestSession session, string relativePath, string headSha, int fromLine)
public async Task<IDifferenceViewer> 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -247,7 +250,7 @@ async Task<InlineAnnotationModel> 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);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/GitHub.Exports.Reactive/Models/InlineAnnotationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public InlineAnnotationModel(CheckSuiteModel checkSuite, CheckRunModel checkRun,
public string Path => annotation.Path;

/// <summary>
/// Gets the start line of the annotation.
/// Gets the 1-based start line of the annotation.
/// </summary>
public int StartLine => annotation.StartLine;

/// <summary>
/// Gets the end line of the annotation.
/// Gets the 1-based end line of the annotation.
/// </summary>
public int EndLine => annotation.EndLine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </param>
/// <param name="fromLine">The line number to open</param>
/// <param name="nextInlineTagFromLine">The 0-based line number to execute NextInlineCommentCommand from</param>
/// <returns>The opened diff viewer.</returns>
Task<IDifferenceViewer> OpenDiff(IPullRequestSession session, string relativePath, string headSha, int fromLine);
Task<IDifferenceViewer> OpenDiff(IPullRequestSession session, string relativePath, string headSha, int nextInlineTagFromLine);

/// <summary>
/// Find the active text view.
Expand Down
4 changes: 2 additions & 2 deletions src/GitHub.Exports/Models/AnnotationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
public class CheckRunAnnotationModel
{
/// <summary>
/// The starting line number (1 indexed).
/// The starting 1-based line number (1 indexed).
/// </summary>
public int StartLine { get; set; }

/// <summary>
/// The ending line number (1 indexed).
/// The ending 1-based line number (1 indexed).
/// </summary>
public int EndLine { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down