Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterate the diffs in each active PR in order #5437

Merged
merged 2 commits into from
Nov 6, 2023
Merged
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
10 changes: 7 additions & 3 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1346,16 +1346,20 @@ ${contents}
}

// Find the next diff in the current file to scroll to
const visibleRange = editor.visibleRanges[0];
const cursorPosition = editor.selection.active;
const iterateThroughDiffs = next ? diffs : diffs.reverse();
for (const diff of iterateThroughDiffs) {
const practicalModifiedEndLineNumber = (diff.modifiedEndLineNumber > diff.modifiedStartLineNumber) ? diff.modifiedEndLineNumber : diff.modifiedStartLineNumber as number + 1;
const diffRange = new vscode.Range(diff.modifiedStartLineNumber ? diff.modifiedStartLineNumber - 1 : diff.modifiedStartLineNumber, 0, practicalModifiedEndLineNumber, 0);
if (next && (visibleRange.end.line < practicalModifiedEndLineNumber) && (visibleRange.end.line !== (editor.document.lineCount - 1))) {

// cursorPosition.line is 0-based, diff.modifiedStartLineNumber is 1-based
if (next && cursorPosition.line + 1 < diff.modifiedStartLineNumber) {
editor.revealRange(diffRange);
editor.selection = new vscode.Selection(diffRange.start, diffRange.start);
return;
} else if (!next && (visibleRange.start.line > diff.modifiedStartLineNumber) && (visibleRange.start.line !== 0)) {
} else if (!next && cursorPosition.line + 1 > diff.modifiedStartLineNumber) {
editor.revealRange(diffRange);
editor.selection = new vscode.Selection(diffRange.start, diffRange.start);
return;
}
}
Expand Down