From 0e7539aa5666bb6ce854a71a22b350d56d4ea6a8 Mon Sep 17 00:00:00 2001 From: Colton Padden Date: Tue, 20 Oct 2026 12:29:33 -0400 Subject: [PATCH] Allow file navigation in focused mode --- src/review/component.ts | 9 ++++++++- test/review/component.test.ts | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/review/component.ts b/src/review/component.ts index 9f4ac97..a086e21 100644 --- a/src/review/component.ts +++ b/src/review/component.ts @@ -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 @@ -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); } diff --git a/test/review/component.test.ts b/test/review/component.test.ts index 57d1584..2fdfd6a 100644 --- a/test/review/component.test.ts +++ b/test/review/component.test.ts @@ -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: {