fix(git): drop the redundant untracked note, square the count pill, pin the footer
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).
This commit is contained in:
1 parent
1685e10d01
commit
4e1056fe66
4 files changed
+24
-20
No files matched your search
@@ -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
|
||||
? <span className={css.lineNote} data-lines="new">{t('changesNewFile')}</span>
|
||||
: null
|
||||
}
|
||||
if (counts === undefined) return null
|
||||
if (!('additions' in counts)) return <span className={css.lineNote} data-lines="binary">{t('diffBinary')}</span>
|
||||
return <PlusMinus additions={counts.additions} deletions={counts.deletions} />
|
||||
}
|
||||
@@ -206,7 +201,7 @@ const FileRow = memo(function FileRow(props: {
|
||||
<StatusBadge tone={BADGE_TONE[node.status.tone]} title={node.path}>{node.status.letter}</StatusBadge>
|
||||
{/* 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. */}
|
||||
<LineCounts counts={node.counts} untracked={node.status.tone === 'untracked'} />
|
||||
<LineCounts counts={node.counts} />
|
||||
</button>
|
||||
<IconButton
|
||||
size="sm"
|
||||
|
||||
@@ -46,7 +46,10 @@
|
||||
.scmHeader:hover .scmActions, .scmHeader:focus-within .scmActions { opacity: 1; }
|
||||
@media (hover: none) { .scmActions { opacity: 1; } }
|
||||
|
||||
.gitFooter { flex: none; min-width: 0; border-top: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-base); }
|
||||
/* Docked by the flex column above (a sibling of `.gitScroll`), plus sticky so
|
||||
it also survives the case where the host tab body itself scrolls the whole
|
||||
tab — the branch control must never leave the bottom of the pane. */
|
||||
.gitFooter { flex: none; min-width: 0; position: sticky; bottom: 0; z-index: 1; border-top: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-base); }
|
||||
.footerRow { display: flex; align-items: center; min-width: 0; min-height: 28px; }
|
||||
.branchMenu { display: flex; flex: 1; min-width: 0; }
|
||||
.branchButton, .syncButton { display: flex; align-items: center; gap: 5px; min-width: 0; min-height: 28px; padding: 3px 8px; border: none; background: transparent; color: var(--dsw-alias-label-secondary); font: var(--dsw-font-xxxs-11); cursor: pointer; }
|
||||
@@ -75,12 +78,14 @@
|
||||
background: var(--dsw-alias-bg-base);
|
||||
}
|
||||
|
||||
/* Group counts match the action height; directory rows need no badge. */
|
||||
/* Group counts match the action height and the neighbouring header controls'
|
||||
corner radius (the host kit's `size="sm"` buttons use `--dsw-radius-sm`);
|
||||
directory rows need no badge. */
|
||||
.countPill {
|
||||
flex: none;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
border-radius: var(--dsw-radius-sm);
|
||||
background: var(--dsw-alias-interactive-bg-hover);
|
||||
color: var(--dsw-alias-label-secondary);
|
||||
font: var(--dsw-font-xxxs-strong-11);
|
||||
|
||||
@@ -569,7 +569,7 @@ describe('ChangesTab', () => {
|
||||
}
|
||||
})
|
||||
|
||||
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.
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user