From 4e1056fe66fd523d05fdf330bdaae521b895b898 Mon Sep 17 00:00:00 2001 From: hairyf Date: Tue, 13 Oct 2026 23:13:00 +0800 Subject: [PATCH] fix(git): drop the redundant untracked note, square the count pill, pin the footer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The U badge already says a row is untracked, so the extra 新文件 note is a second label for the same fact; git never diffs those rows and the binary mark still covers blobs. The group count pill now takes the kit's sm control radius (--dsw-radius-sm) instead of a 20px circle. The branch/sync footer keeps its flex docking and is additionally sticky bottom:0, so a host tab body that scrolls the whole tab cannot carry the branch control off the bottom of the pane (#941). --- src/client/changes/GitLens.tsx | 19 +++++++------------ src/client/changes/changes.module.css | 11 ++++++++--- tests/changes-tab.spec.tsx | 8 ++++++-- tests/git-view-worktree.spec.tsx | 6 +++--- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/client/changes/GitLens.tsx b/src/client/changes/GitLens.tsx index f37bd00d..3d16a409 100644 --- a/src/client/changes/GitLens.tsx +++ b/src/client/changes/GitLens.tsx @@ -142,18 +142,13 @@ function PlusMinus(props: { additions: number; deletions: number; note?: string ) } -/** One row's line counts (#131): the numbers for a text change, the binary - * mark when git has none for a blob, and "new file" for an untracked entry — - * git never diffs those, so there is no numstat row and `+0 −0` would be an - * invented number. An entry with no counts that is NOT untracked (a status - * answer whose numstat read failed) shows nothing at all. */ -function LineCounts(props: { counts?: GitLineCounts; untracked: boolean }): ReactNode { +/** One row's line counts (#131): the numbers for a text change and the binary + * mark when git has none for a blob. git never diffs an untracked entry (its + * `U` badge already says so), and an entry whose numstat read failed must not + * show an invented `+0 −0` — both render nothing. */ +function LineCounts(props: { counts?: GitLineCounts }): ReactNode { const { counts } = props - if (counts === undefined) { - return props.untracked - ? {t('changesNewFile')} - : null - } + if (counts === undefined) return null if (!('additions' in counts)) return {t('diffBinary')} return } @@ -206,7 +201,7 @@ const FileRow = memo(function FileRow(props: { {node.status.letter} {/* The row's own line counts (#131): read straight off the node, so a poll that answered different numbers re-renders this row with them. */} - + { } }) - it('keeps one inner scroller and docks the footer without sticky positioning (#194, #941)', () => { + it('keeps one inner scroller and pins the footer to the bottom (#194, #941)', () => { // jsdom has no layout engine, so the sheet itself is the docking evidence. const sheet = readFileSync('src/client/changes/changes.module.css', 'utf8') const rule = (selector: string): string => { @@ -583,8 +583,12 @@ describe('ChangesTab', () => { expect(rule('.gitScroll')).toContain('overflow-y: auto') expect(rule('.gitScroll')).toContain('overflow-x: hidden') expect(rule('.gitScroll')).toContain('flex: 1') + // Docked by flex, and sticky so a host-scrolled tab body cannot carry the + // branch control off the bottom of the pane either. expect(rule('.gitFooter')).toContain('flex: none') - expect(rule('.gitFooter')).not.toMatch(/position|sticky|z-index|overflow/) + expect(rule('.gitFooter')).toContain('position: sticky') + expect(rule('.gitFooter')).toContain('bottom: 0') + expect(rule('.gitFooter')).not.toContain('overflow') expect(rule('.messageBox')).not.toMatch(/position|sticky|overflow/) expect(sheet).not.toMatch(/\.(?:selectors|select|branchLabel|commitBar|commitRow)\s*\{/) // The retained group headers still park on the inner body's top edge. diff --git a/tests/git-view-worktree.spec.tsx b/tests/git-view-worktree.spec.tsx index 492740fb..ee5bd593 100644 --- a/tests/git-view-worktree.spec.tsx +++ b/tests/git-view-worktree.spec.tsx @@ -768,7 +768,7 @@ describe('GitLens (changes tab, git lens) change tree', () => { } }) - it('says "new file" for an untracked entry and "binary" for a blob, inventing no numbers', async () => { + it('marks a binary blob and invents no numbers for what git never diffs', async () => { const { container, root } = makeRoot() try { await mountTree(container, root, [ @@ -776,10 +776,10 @@ describe('GitLens (changes tab, git lens) change tree', () => { { path: 'blob.bin', xy: ' M', counts: { binary: true } }, ]) - expect(container.querySelector('[data-path="new.txt"] [data-lines="new"]')?.textContent) - .toBe(t('changesNewFile')) expect(container.querySelector('[data-path="blob.bin"] [data-lines="binary"]')?.textContent) .toBe(t('diffBinary')) + // An untracked row already says so with its `U` badge — no second note. + expect(container.querySelector('[data-path="new.txt"] [data-lines]')).toBeNull() // Neither row claims a count... expect(container.querySelector('[data-path="new.txt"] [data-lines="count"]')).toBeNull() expect(container.querySelector('[data-path="blob.bin"] [data-lines="count"]')).toBeNull()