Skip to content

Trim file paths in the discard dialog, and cut trimmed paths flush by measurement - #84

Merged
danipen merged 2 commits into
mainfrom
fix-discard-dialog-path-trim
Jul 23, 2026
Merged

Trim file paths in the discard dialog, and cut trimmed paths flush by measurement#84
danipen merged 2 commits into
mainfrom
fix-discard-dialog-path-trim

Conversation

@danipen

@danipen danipen commented Jul 23, 2026

Copy link
Copy Markdown
Owner

What

Two path-display fixes, one visible in the discard confirmation and one across every file list:

  1. Discard dialog file names were invisible. The confirmation list showed full paths clipped from the right, so deep trees rendered every row as Modules/AssetBundle/Tests/UTFTests/AssetBundles/R…. Rows now use the same dir/name trimming as the pending-changes list: the directory gives way, the file name always stays visible.

  2. The ragged gap between the trimmed directory and the file name is gone. CSS text-overflow: ellipsis drops the whole partially-clipped character and draws where the last full one ended, leaving a row-varying blank between the dimmed directory and the name. The new TrimmedPath primitive measures the text instead (canvas measureText, binary search in pathTrim.ts) and cuts the directory string itself, so the name sits flush after the ellipsis in every row.

How

  • pathTrim.ts — pure cut logic (measurer injected, bisects over code points so surrogate pairs never split), unit-tested including a linear-search cross-check.
  • TrimmedPath.tsx — dim dir + strong name spans; fits before paint on mount/path change and re-fits via ResizeObserver; drops the tooltip layer's data-tip-overflow gate while trimmed (nothing CSS-clips once the text is cut to size, so the gate would suppress the full-path tip).
  • Adopted by WorkingFileList rows (Changes, History, Graph and stash lists) and the discard dialog list; .tpath lives in primitives.css per the reuse rule.

Diff/conflict headers keep plain CSS ellipsis: their containers' widths are content-dependent, so measured trimming there needs its own layout rework (and the artifact is a single line, at most one character wide).

Verification

  • lint, typecheck, test green (832 tests).
  • Driven on screen via Playwright against a repo with 10 deep Unity-style paths: changes list and discard dialog render flush seams at multiple window sizes, zero console errors.

🤖 Generated with Claude Code

danipen added 2 commits July 23, 2026 11:12
…ipsis

CSS text-overflow drops the whole partially-clipped character and draws the
ellipsis where the last full one ended, leaving a ragged, row-varying gap
between the dimmed directory and the file name. The new TrimmedPath primitive
measures the text (canvas measureText, binary-searched in pathTrim.ts) and
cuts the directory string itself, so the name always sits directly after the
ellipsis. Adopted by the changes-list rows (WorkingFileList, also serving
History/Graph/stash lists) and the discard dialog's file list.
@danipen
danipen merged commit af04618 into main Jul 23, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant