Add configurable ambiguous-width policy (narrow/wide)#19864
Add configurable ambiguous-width policy (narrow/wide)#19864unagi wants to merge 3 commits intomicrosoft:mainfrom
Conversation
Reason:\n- Address ambiguous-width rendering requests discussed in microsoft#153 and microsoft#370 without introducing a locale-based default policy.\n\nScope:\n- Add compatibility.ambiguousWidth as narrow|wide and wire it through settings model/schema/UI.\n- Propagate the selected mode through Terminal -> ConPTY -> winconpty -> conhost argument paths.\n- Replace fixed ambiguous width handling in CodepointWidthDetector with policy-based resolution and keep related width paths consistent.\n- Extend regression coverage for ambiguous symbols, DEC special-character alignment, fallback lifecycle stability, and emoji/VS16-adjacent behavior.\n\nBreaking changes:\n- None. Default behavior remains narrow.
|
@microsoft-github-policy-service agree |
src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h
Outdated
Show resolved
Hide resolved
Reason: review pointed out unnecessary newline code changes in PR microsoft#19864. Impact: keep logical changes intact while normalizing edited files to repository line endings. Breaking change: none.
|
Fonts may have an influence. Perhaps this is the reason why you are facing overlapping glyphs, which I was not even able to reproduce (FWIW, Cascadia Mono in my case). Besides of that, my observation is that PowerShell 5.1 in particular bahaves weirdly. As your screenshots seem to demonstrate how it looks like in PS 5.1 only, I'm wondering what this setting does to the experience in other shells? I tried to have the cursor visible in the screen captures, just to show that the "A" is written adjacent to the last arrow, no matter if the cursor has been already advanced to an even farther position in PS 5.1. Other shells (CMD, WSL) do not misplace the cursor. The behavior of PS 5.1 can also be reproduced in a conhost window though. To be clear, I'm not questioning this new setting. And I also don't know how much my observations interact with specifics of CJK scripts in general. However, it might be more reasonable to make it a profile setting
What do you think? |
… policy Reason: when --textMeasurement is omitted, conpty init could leave width recognition mode implicit, causing ambiguity-width related drift. Scope: always initialize VtIo text measurement to graphemes by default and add regression tests for default/explicit textMeasurement+ambiguousWidth propagation. Breaking changes: none.
82d9bad to
4a09610
Compare
|
@german-one In real CJK usage, some users choose fonts that render East Asian Ambiguous characters as width 2 for readability. This PR provides wide as a relief option for that kind of environment. At the same time, the default remains narrow, so compatibility-first behavior is preserved by default (wide is explicit opt-in). We also recognize the side effect that cursor/Backspace behavior can diverge in readline-based environments. That behavior depends on how the receiving application computes character width. We are not hiding this; it is now explicitly documented as a known limitation in both the HelpText and the PR description. So the intent of this PR is to provide an explicit option for readability-focused cases, while clearly disclosing the tradeoff. I also attached reference screenshots (HelpText reinforcement in Settings, plus the known readline-side behavior).
|








Summary of the Pull Request
Add a configurable
compatibility.ambiguousWidthsetting and allow ambiguous-width behavior to be explicitly selected asnarroworwide.The default remains
narrow.References and Relevant Issues
Detailed Description of the Pull Request / Additional comments
Background (#2928)
We understand the rationale in #2928 for favoring fixed/predictable behavior for ambiguous width handling.
This PR keeps that principle by preserving
narrowas the default, while adding an explicit opt-in path for users who needwide.What this PR changes
compatibility.ambiguousWidthwithnarrow|wide(nolocalemode)CodepointWidthDetectorwith policy-based resolution (narrow=1,wide=2)Compatibility
narrow.Localization note
This PR adds new Settings UI strings in
en-USonly.Localized resources will be handled in the subsequent Localization Updates flow after this PR is accepted.
Validation Steps Performed
git diff --checklocale-mode wiring or constants for ambiguous widthPR Checklist
Scope Clarification (added after review feedback)
This PR introduces
compatibility.ambiguousWidthas a global compatibility setting (narrowdefault,wideoptional).Why global-only in this PR:
CodepointWidthDetectorsingleton).What this PR guarantees:
Known limitation:
This is a compatibility/readability trade-off feature:
narrow: prioritize cross-application compatibility.wide: prioritize readability with many CJK fonts.