Skip to content
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
9 changes: 8 additions & 1 deletion src/review/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,9 @@ export class ReviewComponent {
}

private jumpFile(direction: 1 | -1): void {
const files = this.getVisibleFileSections();
const files = this.focusedFilePath
? this.fileIndex.sections
: this.getVisibleFileSections();
if (files.length === 0) return;
const current = this.getCurrentFileSection();
const currentIndex = current
Expand All @@ -1539,6 +1541,11 @@ export class ReviewComponent {
const next = files[nextIndex];
if (!next) return;
this.navigation.jumpToIndex(next.firstCommentableLineIndex);
if (this.focusedFilePath) {
this.focusedFilePath = next.filePath;
this.highlightedLineCache.clear();
this.invalidateAnnotatedRows();
}
this.tui.requestRender(true);
}

Expand Down
17 changes: 17 additions & 0 deletions test/review/component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,23 @@ describe("ReviewComponent", () => {
assert.equal((component as any).selected, 2);
});

it("jumps between files while keeping file focus", () => {
const component = createComponent(buildMultiFileLines());

(component as any).selected = 2;
component.handleInput("f");
component.handleInput("]");

assert.equal((component as any).selected, 5);
assert.equal((component as any).focusedFilePath, "src/b.ts");

component.handleInput("t");
const output = component.render(100).join("\n");
assert.match(output, /src\/b\.ts/);
assert.doesNotMatch(output, /src\/a\.ts/);
assert.match(output, /\[focused\]/);
});

it("renders a toggleable file sidebar with the current file highlighted", () => {
const component = createComponent(buildMultiFileLines(), {
theme: {
Expand Down
Loading