Summary
Hunk assumes East Asian Ambiguous characters occupy one terminal cell. Terminals configured to render ambiguous characters as two cells can therefore drift from Hunk's geometry, affecting diff separators, wrapping, clipping, horizontal scrolling, selection, notes, and chrome.
Relevant characters include middle dots, Greek letters, symbols, and many box-drawing glyphs:
Why this matters
src/ui/lib/text.ts calls eastAsianWidth and string-width with their default narrow-ambiguous policy. The renderer and user's terminal may use a different policy. Hunk's geometry remains internally consistent, but it can disagree with the cells actually occupied on screen.
This is especially visible in terminals with an “ambiguous width: wide” option, such as iTerm2 and GNOME Terminal. Delta tracks the same class of problem in dandavison/delta#1727.
Reproduction
- Configure a terminal to render East Asian Ambiguous characters as wide.
- Open a split diff containing repeated ambiguous characters near pane boundaries.
- Exercise wrapping, horizontal scrolling, mouse selection, and inline notes.
- Observe borders or content drifting/wrapping relative to Hunk's calculated columns.
Expected behavior
Hunk should have one explicit ambiguous-width policy that agrees with the terminal renderer and is shared by all geometry and interaction paths.
Acceptance criteria
- Provide a documented narrow/wide policy, with a reliable automatic mode only if the terminal can actually be detected or calibrated.
- Use the resolved policy consistently for measurement, slicing, wrapping, tabs, selection, note geometry, menus, sidebar rows, and diff rendering.
- Ensure Hunk's own chrome does not rely on ambiguous-width glyphs when the selected policy would make them unsafe; an ASCII fallback is acceptable.
- Add table-driven tests for both width policies using representative
East_Asian_Width=A characters.
- Add at least one end-to-end terminal check proving rendered cursor/cell positions match Hunk's calculated geometry.
- Document terminal/config limitations where automatic agreement is impossible.
Summary
Hunk assumes East Asian Ambiguous characters occupy one terminal cell. Terminals configured to render ambiguous characters as two cells can therefore drift from Hunk's geometry, affecting diff separators, wrapping, clipping, horizontal scrolling, selection, notes, and chrome.
Relevant characters include middle dots, Greek letters, symbols, and many box-drawing glyphs:
Why this matters
src/ui/lib/text.tscallseastAsianWidthandstring-widthwith their default narrow-ambiguous policy. The renderer and user's terminal may use a different policy. Hunk's geometry remains internally consistent, but it can disagree with the cells actually occupied on screen.This is especially visible in terminals with an “ambiguous width: wide” option, such as iTerm2 and GNOME Terminal. Delta tracks the same class of problem in dandavison/delta#1727.
Reproduction
Expected behavior
Hunk should have one explicit ambiguous-width policy that agrees with the terminal renderer and is shared by all geometry and interaction paths.
Acceptance criteria
East_Asian_Width=Acharacters.