You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(terminal): opt-in wide East Asian Ambiguous character width - #10078
pnpm exec vitest run --config config/vitest.config.ts src/shared/east-asian-ambiguous-width.test.ts src/shared/terminal-unicode-provider.test.ts src/renderer/src/components/terminal-pane/layout-serialization.test.ts (40/40)
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/lib/pane-manager/pane-lifecycle.test.ts (30/30)
Full pnpm lint / pnpm typecheck / pnpm test / pnpm build
Unit coverage for EAW classification, wide-mode wcwidth, and CJK font insertion order
AI Review Report
Default safety: narrow preserves modern CLI width tables; wide is opt-in only
Consistency: wcwidth and charProperties stay aligned when wide expands ambiguous cells
Font coupling: wide mode alone without CJK fonts would leave ① tiny; both paths wired together as the issue specified
Cross-platform: CJK fallback list covers Windows (Malgun/YaHei/Yu Gothic), macOS (Apple SD/PingFang/Hiragino), Linux (Noto Sans CJK); browsers skip missing fonts
Mobile: not re-wired in this PR — mobile still loads Unicode11 directly; follow-up if settings plumbing is desired there
Headless emulator: continues to use the shared provider (module mode defaults narrow; daemon measurement stays CLI-aligned)
Security Audit
No new IPC, path handling, or command execution
Setting is a local preference only; no network or secrets
Notes
Changing width mid-session affects newly written cells; existing buffer layout is not reflowed (same as other terminals). UI copy notes opening a new pane for a full reflow.
Known trade-off when Wide is on: TUIs that assume ambiguous width 1 can misalign — that is why this stays opt-in and off by default.
ELI5
Some CJK symbols looked too skinny or wrong in the terminal on Windows. There is an optional Wide mode for East Asian Ambiguous characters so shapes like stars and arrows get a full cell width when you want that.
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
Adds a narrow-or-wide setting for East Asian ambiguous characters. Wide mode assigns width two to ambiguous characters with base width one and selects CJK font fallbacks. The setting is available in desktop typography controls and is passed through desktop terminal startup, headless emulators, and mobile WebView initialization. The default is narrow.
Severity of issue fixed: Low
Merge Risk: High · previous review bd9f9
The default narrow mode can mis-measure text with combining marks, and the new settings preview can fail to render. Wide mode makes Powerline/Nerd Font icons double-width and can leave daemon snapshots using different widths from the renderer. The setting also never reaches mobile terminals. Fix these before merging.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Description check
The description clearly explains the purpose, implementation, linked issue, targeted tests, and known limitations. It does not provide actual before-and-after visual attachments for this UI change, an…
Add before-and-after visual attachments, or write N/A with a reason if no visual proof applies. Complete the required template sections and checklist, document manual testing platforms, and report full validation results or CI coverage.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title is concise, specific, and accurately describes the primary change: an opt-in wide East Asian Ambiguous character width mode.
Linked Issues check
The PR meets the coding requirements in [#9958]. It adds the narrow default and opt-in wide mode, applies the mode in wcwidth and charProperties, and adds coverage for classification and provi…
Out of Scope Changes check
The changed files support [#9958]. They implement the setting, width resolution, renderer/headless/mobile activation, coupled CJK font fallback, settings UI, and automated tests. The summaries show no…
Docstring Coverage
Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Full details: Linked Issues check
Explanation
The PR meets the coding requirements in [#9958]. It adds the narrow default and opt-in wide mode, applies the mode in wcwidth and charProperties, and adds coverage for classification and provider behavior. Renderer activation occurs before terminal use in pane-lifecycle.ts. Headless activation accepts the mode before loading Unicode11Addon. Mobile initialization sets the mode before replay writes and selects the matching font family. Wide mode inserts CJK fallback fonts before Consolas. The PR also adds headless width, font-order, and layout-related tests.
Full details: Out of Scope Changes check
Explanation
The changed files support [#9958]. They implement the setting, width resolution, renderer/headless/mobile activation, coupled CJK font fallback, settings UI, and automated tests. The summaries show no unrelated feature, security, IPC, or command-execution changes.
Full details: Description check
Explanation
The description clearly explains the purpose, implementation, linked issue, targeted tests, and known limitations. It does not provide actual before-and-after visual attachments for this UI change, and it omits several required template sections and checklist confirmations.
Resolution
Add before-and-after visual attachments, or write N/A with a reason if no visual proof applies. Complete the required template sections and checklist, document manual testing platforms, and report full validation results or CI coverage.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The test only checks wcwidth; the newly added packed-property path is what buffer writes consume. Assert that an ambiguous code point has width bits 2 after switching to wide mode.
ℹ️ Review info⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0015135e-dae9-4f27-b7f2-fb02d679f6ae
📥 Commits
Reviewing files that changed from the base of the PR and between 8448557 and b280441.
Hi @innocarpe, thanks for picking this up and for the quick PR.
Just checking in on progress — it's been a few days since the last commit, and CodeRabbit's linked-issues check is still flagging that the headless emulator (src/main/daemon/headless-emulator.ts) and mobile (mobile/src/terminal/terminal-webview-html.ts) activation sites from the original issue aren't wired up yet, on top of the docstring coverage warning.
Those two paths matter for the SSH and mobile use cases specifically, so I'd like to see all three activation sites covered before merge. Are you still actively working on this, or would it help to have someone else pick up the remaining wiring? Happy to help if you're stuck on anything.
[Medium impact] This PR is safe to merge with minimal risk
Summary
This PR adds opt-in wide East Asian Ambiguous character width for Windows CJK locales where glyphs like ① ■ ★ → render too small. The implementation is clean and well-tested.
Major changes:
New terminalEastAsianAmbiguousWidth setting ('narrow' | 'wide', default 'narrow') keeps modern CLI alignment by default
Shared EAW range table with binary-search classification drives both wcwidth and charProperties so cell width stays consistent
CJK font fallback insertion in wide mode places full-em fonts (Malgun Gothic, YaHei, Yu Gothic, PingFang, Hiragino, Noto) ahead of Consolas
Cross-platform coverage: desktop renderer, headless emulator, and mobile WebView all read the mode and apply width expansion together with font changes
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Settings: terminalEastAsianAmbiguousWidth] -->|narrow/wide| B[setTerminalEastAsianAmbiguousWidthMode]
B --> C[Process-global mode variable]
A -->|eastAsianAmbiguousWide option| D[buildFontFamily]
D -->|wide=true| E[Insert CJK fonts before Consolas]
D -->|wide=false| F[Standard monospace fallback chain]
C --> G[OrcaUnicodeProvider.wcwidth]
C --> H[OrcaUnicodeProvider.charProperties]
G -->|baseWidth=1 & mode=wide & isEastAsianAmbiguous| I[Return width 2]
G -->|otherwise| J[Return baseWidth]
H -->|mode=wide| K[Align charProperties width field with wcwidth]
I --> L[Terminal cells allocated as double-width]
E --> L
style A fill:#e1f5ff
style C fill:#fff3cd
style L fill:#d4edda
Resolve conflict with upstream wheel-scroll inject (keep both EAW + wheel).
Review (Greptile stablyai#10078):
- Remove BMP PUA U+E000–U+F8FF from ambiguous ranges so Powerline/OMP
icons stay single-cell in wide mode.
- Set process-wide EAW mode once before the appearance pane loop.
- Extract HeadlessEmulatorOptions to stay under max-lines.
Evidence: east-asian-ambiguous-width PUA tests + width suites.
setTerminalEastAsianAmbiguousWidthMode called once per pane inside the loopsrc/renderer/src/components/terminal-pane/terminal-appearance.ts:183▶
setTerminalEastAsianAmbiguousWidthMode is placed inside the for (const pane of ...) loop and sets the same process-global value on every iteration. More importantly, if manager.getPanes() returns an empty array (no open panes when the user changes the setting), the global mode is never updated by this call. A new pane opened afterward will read the correct value from the store in openTerminal, so there is no immediate regression - but the redundant per-pane call makes this code misleading about the intended call site. Moving the call (and the eastAsianAmbiguousWide local) to just before the loop clarifies intent and removes the dead execution case.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
MobileSessionActiveContent passes no width setting to TerminalPaneView, and TerminalPaneView omits eastAsianAmbiguousWidth when it renders TerminalWebView. The controller then defaults to 'narrow'. Pass the host’s terminalEastAsianAmbiguousWidth value through the session caller as eastAsianAmbiguousWidth.
set -o pipefail
printf'%s\n''--- terminal WebView ref owner ---'
nl -ba mobile/src/session/use-mobile-session-terminal-webview.ts | sed -n '1,155p'printf'%s\n''--- terminal subscription init blocks ---'
nl -ba mobile/src/session/use-mobile-session-terminal-subscription.ts | sed -n '170,310p'
Repository: stablyai/orca
Length of output: 13229
Apply width-mode changes to a live terminal.
When a caller changes eastAsianAmbiguousWidth after initialization, useTerminalWebViewController rebuilds the handle but does not send a width-mode update. The wrappers do not reinitialize the document when the handle changes. The document handles this value only during init, where it sets the Unicode mode and font family. Later output can therefore use the old mode and font until another initialization occurs.
Add a live document command that updates the Unicode mode and scope.term.options.fontFamily. Existing buffer content need not reflow.
TerminalPaneView currently does not accept or pass eastAsianAmbiguousWidth, so this path is not reachable from the current mobile session and is a minor issue until a non-default value is wired.
Synchronize terminalEastAsianAmbiguousWidth with the daemon.
The setting setter runs in the main process only. The daemon is launched through its own daemon-entry process, whose startup arguments and startDaemon options contain no width mode or settings synchronization.
SessionOutputPlane and replayTerminalSnapshot construct HeadlessEmulator without eastAsianAmbiguousWidth. Their daemon-local provider therefore starts in its default narrow mode. In wide mode, seeded history and live writes can use different cell widths from the renderer, which can misplace subsequent characters in snapshots.
Pass the mode to the daemon before emulator construction and history replay, then synchronize it when the setting changes.
@xterm/xterm 6.1.0-beta.304 Unicode service set versiոն 11 unregistered Unicode11Addon
Result:
<source_evidence>
<source kind="search">
<title>@xterm/addon-unicode11 - npm</title>
<location>https://www.npmjs.com/package/%40xterm/addon-unicode11?activeTab=versions</location>
<excerpt>citeturn1search0 [wordlim: 200] Crawled: 2 days ago; npm install --save @xterm/addon-unicode11 ... 0.10.0-beta.304 | 1 | 14 days ago
# @xterm/addon-unicode11
Image: This package contains built-in TypeScript declarations
0.9.0 • Public • Published 10 months ago
## @xterm/addon-unicode11
An addon providing Unicode version 11 rules for xterm.js.
### Install
npm install --save @xterm/addon-unicode11
### Usage
import { Terminal } from '@xterm/xterm';
import { Unicode11Addon } from '@xterm/addon-unicode11';
const terminal = new Terminal();
const unicode11Addon = new Unicode11Addon();
terminal.loadAddon(unicode11Addon);
// activate the new version
terminal.unicode.activeVersion = '11';
## Versions
### Current Tags
Version | Downloads (Last 7 Days) | Tag
--- | --- | ---
0.9.0 | 641,080 | latest
0.10.0-beta.310 | 3,725 | beta
### Version History
Version | Downloads (Last 7 Days) | Published
--- | --- | ---
0.10.0-beta.310 | 3,725 | 14 days ago
0.10.0-beta.309 | 208 | 14 days ago
0.10.0-beta.308 | 1 | 14 days ago
0.10.0-beta.307 | 1 | 14 days ago
0.10.0-beta.306 | 1 | 14 days ago
0.10.0-beta.305 | 1 | 14 days ago
0.10.0-beta.304 | 1 | 14 days ago
0.10.0-beta.303 | 2 | 14 days ago
0.10.0-beta.302 | 1 | 14 days ago
0.10.0-beta.301 | 107,202 | 2 months ago
0.10.0-beta.300 | 15,536 | 2 months ago
0.10.0-beta.299 | 1,417 | 3 months ago
0.10.0-beta.298 | 7 | 3 months ago
0.10.0-beta.297 | 0 | 3 months ago
0.10.0-beta.296 | 0 | 3 months ago
0.10.0-beta.295 | 0 | 3 months ago
0.10.0-beta.294 | 0 | 3 months ago
0.10.0-beta.293 | 0 | 3 months ago
0.10.0-beta.292 | 1,224 | 3 months ago
0.10.0-beta.291 | 14,264 | 3 months ago
0.10.0-beta.290 | 180 | 3 months ago
0.10.0-beta.289 | 808 | 3 months ago
0.10.0-beta.288 | 5,927 | 4 months ago
0.10.0-beta.287 | 6,019 | 4 months ago
## Package Sidebar
### Install
`npm i @xterm/addon-unicode11`
### Repository
github.com/xtermjs/xterm.js/tree/master
### Homepage
github.com/xtermjs/xterm.js/tree/master#readme
### Weekly Downloads
871,359
### Version
0.9.0
### License
MIT
### Last publish
14 days ago</excerpt>
</source>
<source kind="search">
<title>@xterm/xterm - npm</title>
<location>https://www.npmjs.com/package/%40xterm/xterm?activeTab=versions</location>
<excerpt>citeturn0search0 [wordlim: 200] Crawled: 2 days ago; The recommended way to load xterm.js is via the ES6 module syntax: ... npm i -S @xterm/addon-web-links ... 6.1.0-beta.304 | 112,491 | 2 months ago
### Importing
The recommended way to load xterm.js is via the ES6 module syntax:
import { Terminal } from '@xterm/xterm';
### Addons
⚠️ This section describes the new addon format introduced in v3.14.0, see here for the instructions on the old format
Addons are separate modules that extend the `Terminal` by building on the xterm.js API. To use an addon, you first need to install it in your project:
npm i -S @xterm/addon-web-links
Then import the addon, instantiate it and call `Terminal.loadAddon`:
import { Terminal } from '@xterm/xterm';
import { WebLinksAddon } from '@xterm/addon-web-links';
const terminal = new Terminal();
// Load WebLinksAddon on terminal, this is all that's needed to get web links
// working in the terminal.
terminal.loadAddon(new WebLinksAddon());
The xterm.js team maintains the following addons, but anyone can build them:
* `@xterm/addon-attach`: Attaches to a server running a process via a websocket
* `@xterm/addon-clipboard`: Access the browser's clipboard
* `@xterm/addon-fit`: Fits the terminal to the containing element
* `@xterm/addon-image`: Adds image support
* `@xterm/addon-search`: Adds search functionality
* `@xterm/addon-serialize`: Serializes the terminal's buffer to a VT sequences or HTML
* `@xterm/addon-unicode11`: Updates character widths to their unicode11 values
* `@xterm/addon-web-links`: Adds web link detection and interaction
* `@xterm/addon-webgl`: Renders xterm.js using a `canvas` element's webgl2 context
## Versions
### Current Tags
Version | Downloads (Last 7 Days) | Tag
--- | --- | ---
6.0.0 | 2,451,350 | latest
6.1.0-beta.315 | 14,836 | beta
### Version History
Version | Downloads (Last 7 Days) | Published
--- | --- | ---
6.1.0-beta.315 | 14,836 | 14 days ago
6.1.0-beta.314 | 218 | 14 days ago
6.1.0-beta.313 | 3 | 14 days ago
6.1.0-beta.312 | 1 | 14 days ago
6.1.0-beta.311 | 1 | 14 days ago
6.1.0-beta.310 | 1 | 14 days ago
6.1.0-beta.309 | 1 | 14 days ago
6.1.0-beta.308 | 0 | 14 days ago
6.1.0-beta.307 | 0 | 14 days ago
6.1.0-beta.306 | 0 | 14 days ago
6.1.0-beta.305 | 2 | 14 days ago
6.1.0-beta.304 | 112,491 | 2 months ago
6.1.0-beta.303 | 21,008 | 2 months ago
6.1.0-beta.302 | 2,001 | 3 months ago
6.1.0-beta.301 | 1 | 3 months ago
6.1.0-beta.300 | 6 | 3 months ago
6.1.0-beta.299 | 0 | 3 months ago
6.1.0-beta.298 | 0 | 3 months ago
6.1.0-beta.297 | 1 | 3 months ago
6.1.0-beta.296 | 16 | 3 months ago
6.1.0-beta.295 | 0 | 3 months ago
6.1.0-beta.294 | 6 | 3 months ago
6.1.0-beta.293 | 0 | 3 months ago
6.1.0-beta.292 | 24,454 | 3 months ago
6.1.0-beta.291 | 17,824 | 3 months ago
6.1.0-beta.290 | 1,948 | 3 months ago
6.1.0-beta.289 | 796 | 3 months ago
6.1.0-beta.288 | 1,459 | 4 months ago
6.1.0-beta.287 | 35,893 | 4 months ago
6.1.0-beta.286 | 0 | 4 months ago
6.1.0-beta.285 | 7,538 | 5 months ago
6.1.0-beta.284 | 0 | 5 months ago
6.1.0-beta.283 | 0 | 5 months ago
6.1.0-beta.282 | 2 | 5 months ago
6.1.0-beta.281 | 0 | 5 months ago
6.1.0-beta.280 | 0 | 5 months ago
6.1.0-beta.279 | 0 | 5 months ago
6.1.0-beta.278 | 0 | 5 months ago
6.1.0-beta.277 | 0 | 5 months ago
6.1.0-beta.276 | 3 | 5 months ago
6.1.0-beta.275 | 0 | 5 months ago
6.1.0-beta.274 | 0 | 5 months ago
6.1.0-beta.273 | 0 | 5 months ago
6.1.0-beta.272 | 0 | 5 months ago
6.1.0-beta.271 | 0 | 5 months ago
6.1.0-beta.270 | 0 | 5 months ago
6.1.0-beta.269 | 0 | 5 months ago
6.1.0-beta.268 | 0 | 5 months ago
6.1.0-beta.267 | 0 | 5 months ago
6.1.0-beta.266 | 0 | 5 months ago
6.1.0-beta.265 | 0 | 5 months ago
6.1.0-beta.264 | 0 | 5 months ago
6.1.0-beta.263 | 0 | 5 months ago
6.1.0-beta.262 | 0 | 5 months ago
6.1.0-beta.261 | 0 | 5 months ago
6.1.0-beta.260 | 0 | 5 months ago
6.1.0-beta.259 | 0 | 5 months ago
6.1.0-beta.258 | 0 | 5 months ago
6.1.0-beta.257 | 7 | 5 months ago
6.1.0-beta.256 | 475 | 5 months ago
6.1.0-beta.255 | 1 | 5 months ago
6.1.0-beta.254 | 0 | 5 months ago
6.1.0-beta.253 | 0 | 5 months ago
6.1.0-beta.94 | 0 | 10 months ago
6.1.0-beta.93 | 0 | 10 months ago
6.1.0-beta.92 | 0 | 10 months ago
6.1.0-beta.91 | 1,269 | 10 months ago
6.1.0-beta.90 | 0 | 10 months ago
6.1.0-beta.89 | 5 | 10 months ago
6.1.0-beta.88 | 0 | 10 months ago
6.1.0-beta.87 | 0 | 10 months ago
6.1.0-beta.86 | 0 | 10 months ago
6.1.0-beta.85 | 0 | 10 months ago
6.1.0-beta.84 | 0 | 10 months ago
6.1.0-beta.83 | 0 | 10 months ago
6.1.0-beta.82 | 0 | 10 months ago
6.1.0-beta.81 | 0 | 10 months ago
6.1.0-beta.80 | 0 | 10 months ago
6.1.0-beta.79 | 0 | 10 months ago
6.1.0-beta.78 | 0 | 10 months ago
6.1.0-beta.77 | 9 | 10 months ago
6.1.0-beta.76 | 0 | 10 months ago
6.1.0-beta.75 | 0 | 10 months ago
6.1.0-beta.74 | 0 | 10 months ago
6.1.0-beta.73 | 0 | 10 months ago
6.1.0-beta.72 | 2 | 10 months ago
6.1.0-beta.71 | 0 | 10 months ago
6.1.0-beta.70 | 0 | 10 months ago
6.1.0-beta.69 | 0 | 10 months ago
6.1.0-beta.68 | 0 | 10 months ago
6.1.0-beta.67 | 0 | 10 months ago
6.1.0-beta.66 | 0 | 10 months ago
6.1.0-beta.65 | 0 | 10 months ago
6.1.0-beta.64 | 0 | 10 months ago
6.1.0-beta.63 | 0 | 10 months ago
6.1.0-beta.62 | 0 | 10 months ago
6.1.0-beta.61 | 0 | 10 months ago
6.1.0-beta.60 | 1 | 10 months ago
6.1.0-beta.59 | 0 | 10 months ago
6.1.0-beta.58 | 0 | 10 months ago
6.1.0-beta.57 | 0 | 10 months ago
6.1.0-beta.56 | 9 | 10 months ago
6.1.0-beta.55 | 0 | 10 months ago
6.1.0-beta.54 | 0 | 10 months ago
6.1.0-beta.53 | 0 | 10 months ago
6.1.0-beta.52 | 0 | 10 months ago
6.1.0-beta.51 | 0 | 10 months ago
6.1.0-beta.50 | 0 | 10 months ago
6.1.0-beta.49 | 0 | 10 months ago
6.1.0-beta.48 | 0 | 10 months ago
6.1.0-beta.47 | 0 | 10 months ago
6.1.0-beta.46 | 0 | 10 months ago
6.1.0-beta.45 | 0 | 10 months ago
6.1.0-beta.44 | 0 | 10 months ago
6.1.0-beta.43 | 0 | 10 months ago
6.1.0-beta.42 | 0 | 10 months ago
6.1.0-beta.41 | 0 | 10 months ago
6.1.0-beta.40 | 1 | 10 months ago
6.1.0-beta.39 | 1 | 10 months ago
6.1.0-beta.38 | 1 | 10 months ago
6.1.0-beta.37 | 1 | 10 months ago
6.1.0-beta.36 | 1 | 10 months ago
6.1.0-beta.35 | 1 | 10 months ago
6.1.0-beta.12 | 1 | 10 months ago
6.1.0-beta.11 | 1 | 10 months ago
6.1.0-beta.10 | 1 | 10 months ago
6.1.0-beta.9 | 1 | 10 months ago
6.1.0-beta.8 | 1 | 10 months ago
6.1.0-beta.7 | 1 | 10 months ago
6.1.0-beta.6 | 1 | 10 months ago
6.1.0-beta.5 | 2 | 10 months ago
6.1.0-beta.4 | 1 | 10 months ago
6.1.0-beta.3 | 1 | 10 months ago
6.1.0-beta.2 | 1 | 10 months ago
6.1.0-beta.1 | 3 | 10 months ago
6.0.0 | 2,451,350 | 10 months ago
5.6.0-beta.143 | 604 | 10 months ago
5.6.0-beta.142 | 0 | 10 months ago
5.6.0-beta.141 | 1 | 10 months ago
5.6.0-beta.140 | 15 | a year ago
5.6.0-beta.139 | 0 | a year ago
5.6.0-beta.138 | 0 | a year ago
5.6.0-beta.137 | 34 | a year ago
5.6.0-beta.136 | 365 | a year ago
5.6.0-beta.135 | 33 | a year ago
5.6.0-beta.134 | 1 | a year ago
5.6.0-beta.133 | 0 | a year ago
5.6.0-beta.132 | 0 | a year ago
5.6.0-beta.131 | 32 | a year ago
5.6.0-beta.130 | 0 | a year ago
5.6.0-beta.129 | 14 | a year ago
5.6.0-beta.128 | 0 | a year ago
5.6.0-beta.127 | 12 | a year ago
5.6.0-beta.126 | 2 | a year ago
5.6.0-beta.125 | 0 | a year ago
5.6.0-beta.124 | 0 | a year ago
5.6.0-beta.123 | 0 | a year ago
5.6.0-beta.122 | 0 | a year ago
5.6.0-beta.121 | 0 | a year ago
5.6.0-beta.120 | 0 | a year ago
5.6.0-beta.119 | 339 | a year ago
</excerpt>
</source>
<source kind="search">
<title>xterm.js 的 @xterm/addon-unicode11 详解:为 Web 终端接入 Unicode 11 字符宽度规则 - AtomGit | GitCode博客</title>
<location>https://blog.gitcode.com/e338a9e8661ecc8f2cc4c37393855ba8.html</location>
<excerpt>citeturn0search1 [wordlim: 200] Published: 4 weeks ago; Crawled: 3 weeks ago; xterm.js 在浏览器中渲染终端文本时,必须精确知道每个字符在等宽栅格中占据的单元格宽度(0、1 或 2 列)。 ... 为此,xterm.js 将"Unicode 版本"抽象为一套可注册、可切换的规则提供者(`IUnicodeVersionProvider`),默认内置 UnicodeV6(版本号 `'6'`),而 @xterm/addon-unicode11 则以官方 Addon 的形式提供 Unicode 11 版本的实现,覆盖从 xterm.js 5.0 开始引入的 `Terminal.unicode` API。
## 基本使用
在创建 `Terminal` 实例后,实例化 `Unicode11Addon` 并通过 `loadAddon` 加载,随后将 `terminal.unicode.activeVersion` 设置为 `'11'` 即可生效(原文档完整示例,可直接运行):
`import { Terminal } from '@xterm/xterm';
import { Unicode11Addon } from '@xterm/addon-unicode11';
const terminal = new Terminal();
const unicode11Addon = new Unicode11Addon();
terminal.loadAddon(unicode11Addon);
// activate the new version
terminal.unicode.activeVersion = '11';
`
关键点说明:
* `loadAddon(unicode11Addon)` 会调用 Addon 的 `activate(terminal)` 方法,由 Addon 内部将 `UnicodeV11` 规则注册到 `terminal.unicode`(详见下文"注册与激活机制");
* `activeVersion` 必须在 Addon 加载之后设置。若设置尚未注册的版本,会抛出 `unknown Unicode version "..."` 错误(见 UnicodeService.ts);
* 如果当前尚未激活任何版本,`register` 会自动把新注册的版本设为激活版本(UnicodeService.ts)。
</excerpt>
</source>
<source kind="search">
<title>@xterm/headless - npm</title>
<location>https://www.npmjs.com/package/%40xterm/headless?activeTab=versions</location>
<excerpt>citeturn0search2 [wordlim: 200] Crawled: 6 days ago; 6.1.0-beta.304 | 156 | 10 days ago
## Versions
### Current Tags
Version | Downloads (Last 7 Days) | Tag
--- | --- | ---
6.0.0 | 1,149,013 | latest
6.1.0-beta.313 | 840 | beta
### Version History
Version | Downloads (Last 7 Days) | Published
--- | --- | ---
6.1.0-beta.313 | 840 | 9 days ago
6.1.0-beta.312 | 283 | 10 days ago
6.1.0-beta.311 | 132 | 10 days ago
6.1.0-beta.310 | 129 | 10 days ago
6.1.0-beta.309 | 122 | 10 days ago
6.1.0-beta.308 | 125 | 10 days ago
6.1.0-beta.307 | 142 | 10 days ago
6.1.0-beta.306 | 131 | 10 days ago
6.1.0-beta.305 | 138 | 10 days ago
6.1.0-beta.304 | 156 | 10 days ago
6.1.0-beta.303 | 59,525 | 2 months ago
6.1.0-beta.302 | 36,378 | 2 months ago
6.1.0-beta.301 | 895 | 2 months ago
6.1.0-beta.300 | 9 | 2 months ago
6.1.0-beta.299 | 3 | 2 months ago
6.1.0-beta.298 | 2 | 2 months ago
6.1.0-beta.297 | 3 | 2 months ago
</excerpt>
</source>
<source kind="search">
<title>Visual Studio Code : .../node/ptyService.ts | Fossies</title>
<location>https://fossies.org/linux/vscode/src/vs/platform/terminal/node/ptyService.ts</location>
<excerpt>citeturn0search3 [wordlim: 200] Crawled: 6 days ago; 1118 async setUnicodeVersion(version: '6' | '11'): Promise<void> { ... 1141 SerializeAddon = (await import('@xterm/addon-serialize')).
</excerpt>
</source>
<omitted_sources count="33">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>
Citations:
- 1: https://www.npmjs.com/package/%40xterm/addon-unicode11?activeTab=versions&utm_source=openai
- 2: https://www.npmjs.com/package/%40xterm/addon-unicode11?activeTab=versions&utm_source=openai
Web query:
site:github.com/xtermjs/xterm.js/blob/6.1.0-beta.304 UnicodeService.ts activeVersion unknown Unicode version
Result:
<source_evidence>
<source kind="search">
<title>xterm.js/src/common/CoreTerminal.ts at master · xtermjs/xterm.js · GitHub</title>
<location>https://github.com/xtermjs/xterm.js/blob/master/src/common/CoreTerminal.ts</location>
<excerpt>citeturn0search0 [wordlim: 200] Crawled: 4 weeks ago; # CoreTerminal.ts ... * Copyright (c) 2014-2020 The xterm.js authors. ... * Copyright (c) 2011 Fabrice Bellard ... this.unicodeService.register(new UnicodeV6());
# CoreTerminal.ts
# CoreTerminal.ts
Copy path
Top
## File metadata and controls
* Code
* Blame
307 lines (270 loc) · 13.6 KB
/**
* Copyright (c) 2014-2020 The xterm.js authors. All rights reserved.
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
* @license MIT
*
* Originally forked from (with the author's permission):
* Fabrice Bellard's javascript vt100 for jslinux:
* http://bellard.org/jslinux/
* Copyright (c) 2011 Fabrice Bellard
* The original design remains. The terminal itself
* has been extended to include xterm CSI codes, among
* other features.
*
* Terminal Emulation References:
* http://vt100.net/
* http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt
* http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
* http://invisible-island.net/vttest/
* http://www.inwap.com/pdp10/ansicode.txt
* http://linux.die.net/man/4/console_codes
* http://linux.die.net/man/7/urxvt
*/
import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService, IMouseStateService, IUnicodeService, LogLevelEnum, IOscLinkService } from './services/Services';
import { InstantiationService } from './services/InstantiationService';
import { LogService } from './services/LogService';
import { BufferService, BufferServiceConstants } from './services/BufferService';
import { OptionsService } from './services/OptionsService';
import { IDisposable, IScrollEvent, ITerminalOptions, IParams } from './Types';
import { IAttributeData, IBufferSet } from './buffer/Types';
import { CoreService } from './services/CoreService';
import { MouseStateService } from './services/MouseStateService';
import { UnicodeV6 } from './input/UnicodeV6';
import { UnicodeService } from './services/UnicodeService';
import { CharsetService } from './services/CharsetService';
import { updateWindowsModeWrappedState } from './WindowsMode';
import { IFunctionIdentifier } from './parser/Types';
import { InputHandler } from './InputHandler';
import { WriteBuffer } from './input/WriteBuffer';
import { OscLinkService } from './services/OscLinkService';
import { Emitter, EventUtils, type IEvent } from './Event';
import { Disposable, MutableDisposable, toDisposable } from './Lifecycle';
// Only trigger this warning a single time per session
let hasWriteSyncWarnHappened = false;
export interface ICoreTerminal {
mouseStateService: IMouseStateService;
coreService: ICoreService;
optionsService: IOptionsService;
unicodeService: IUnicodeService;
buffers: IBufferSet;
options: Required<ITerminalOptions>;
registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise<boolean>): IDisposable;
registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise<boolean>): IDisposable;
registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise<boolean>): IDisposable;
registerOscHandler(ident: number, callback: (data: string) => boolean | Promise<boolean>): IDisposable;
registerApcHandler(id: IFunctionIdentifier, callback: (data: string) => boolean | Promise<boolean>): IDisposable;
}
export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
protected readonly _instantiationService: IInstantiationService;
protected readonly _bufferService: IBufferService;
protected readonly _logService: ILogService;
protected readonly _charsetService: ICharsetService;
protected readonly _oscLinkService: IOscLinkService;
public readonly mouseStateService: IMouseStateService;
public readonly coreService: ICoreService;
public readonly unicodeService: IUnicodeService;
public readonly optionsService: IOptionsService;
protected _inputHandler: InputHandler;
private _writeBuffer: WriteBuffer;
private _windowsWrappingHeuristics = this._register(new MutableDisposable());
private readonly _onBinary = this._register(new Emitter<string>());
public readonly onBinary = this._onBinary.event;
private readonly _onData = this._register(new Emitter<string>());
public readonly onData = this._onData.event;
protected _onLineFeed = this._register(new Emitter<void>());
public readonly onLineFeed = this._onLineFeed.event;
protected readonly _onRender = this._register(new Emitter<{ start: number, end: number }>());
public readonly onRender = this._onRender.event;
private readonly _onResize = this._register(new Emitter<{ cols: number, rows: number }>());
this.optionsService.options[key] = options[key];
}
}
constructor(
options: Partial<ITerminalOptions>
) {
super();
// Setup and initialize services
this._instantiationService = new InstantiationService();
this.optionsService = this._register(new OptionsService(options));
this._instantiationService.setService(IOptionsService, this.optionsService);
this._logService = this._register(this._instantiationService.createInstance(LogService));
this._instantiationService.setService(ILogService, this._logService);
this._bufferService = this._register(this._instantiationService.createInstance(BufferService));
this._instantiationService.setService(IBufferService, this._bufferService);
this.coreService = this._register(this._instantiationService.createInstance(CoreService));
this._instantiationService.setService(ICoreService, this.coreService);
this.mouseStateService = this._register(this._instantiationService.createInstance(MouseStateService));
this._instantiationService.setService(IMouseStateService, this.mouseStateService);
this.unicodeService = this._register(this._instantiationService.createInstance(UnicodeService));
this.unicodeService.register(new UnicodeV6());
this._instantiationService.setService(IUnicodeService, this.unicodeService);
this._charsetService = this._instantiationService.createInstance(CharsetService);
this._instantiationService.setService(ICharsetService, this._charsetService);
</excerpt>
</source>
<source kind="search">
<title>xterm.js/src/common/CoreTerminal.ts at master · xtermjs/xterm.js · GitHub</title>
<location>https://github.com/xtermjs/xterm.js/blob/master/src/common/CoreTerminal.ts</location>
<excerpt>citeturn2search0 [wordlim: 200] Crawled: 4 weeks ago; * Copyright (c) 2014-2020 The xterm.js authors. ... import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService, IMouseStateService, IUnicodeService, LogLevelEnum, IOscLinkService } from './services/Services';
# CoreTerminal.ts
# CoreTerminal.ts
Copy path
Top
## File metadata and controls
* Code
* Blame
307 lines (270 loc) · 13.6 KB
/**
* Copyright (c) 2014-2020 The xterm.js authors. All rights reserved.
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
* @license MIT
*
* Originally forked from (with the author's permission):
* Fabrice Bellard's javascript vt100 for jslinux:
* http://bellard.org/jslinux/
* Copyright (c) 2011 Fabrice Bellard
* The original design remains. The terminal itself
* has been extended to include xterm CSI codes, among
* other features.
*
* Terminal Emulation References:
* http://vt100.net/
* http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt
* http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
* http://invisible-island.net/vttest/
* http://www.inwap.com/pdp10/ansicode.txt
* http://linux.die.net/man/4/console_codes
* http://linux.die.net/man/7/urxvt
*/
import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService, IMouseStateService, IUnicodeService, LogLevelEnum, IOscLinkService } from './services/Services';
import { InstantiationService } from './services/InstantiationService';
import { LogService } from './services/LogService';
import { BufferService, BufferServiceConstants } from './services/BufferService';
import { OptionsService } from './services/OptionsService';
import { IDisposable, IScrollEvent, ITerminalOptions, IParams } from './Types';
import { IAttributeData, IBufferSet } from './buffer/Types';
import { CoreService } from './services/CoreService';
import { MouseStateService } from './services/MouseStateService';
import { UnicodeV6 } from './input/UnicodeV6';
import { UnicodeService } from './services/UnicodeService';
import { CharsetService } from './services/CharsetService';
import { updateWindowsModeWrappedState } from './WindowsMode';
import { IFunctionIdentifier } from './parser/Types';
import { InputHandler } from './InputHandler';
</excerpt>
</source>
<source kind="search">
<title>@xterm/xterm - npm</title>
<location>https://www.npmjs.com/package/%40xterm/xterm?activeTab=versions</location>
<excerpt>citeturn2search1 [wordlim: 200] Crawled: 2 days ago; The recommended way to load xterm.js is via the ES6 module syntax: ... 6.1.0-beta.304 | 112,491 | 2 months ago
## Versions
### Current Tags
Version | Downloads (Last 7 Days) | Tag
--- | --- | ---
6.0.0 | 2,451,350 | latest
6.1.0-beta.315 | 14,836 | beta
### Version History
Version | Downloads (Last 7 Days) | Published
--- | --- | ---
6.1.0-beta.315 | 14,836 | 14 days ago
6.1.0-beta.314 | 218 | 14 days ago
6.1.0-beta.313 | 3 | 14 days ago
6.1.0-beta.312 | 1 | 14 days ago
6.1.0-beta.311 | 1 | 14 days ago
6.1.0-beta.310 | 1 | 14 days ago
6.1.0-beta.309 | 1 | 14 days ago
6.1.0-beta.308 | 0 | 14 days ago
6.1.0-beta.307 | 0 | 14 days ago
6.1.0-beta.306 | 0 | 14 days ago
6.1.0-beta.305 | 2 | 14 days ago
6.1.0-beta.304 | 112,491 | 2 months ago
6.1.0-beta.303 | 21,008 | 2 months ago
6.1.0-beta.302 | 2,001 | 3 months ago
6.1.0-beta.301 | 1 | 3 months ago
6.1.0-beta.300 | 6 | 3 months ago
</excerpt>
</source>
<source kind="search">
<title>xterm.js/addons/addon-unicode-graphemes/README.md at master · xtermjs/xterm.js · GitHub</title>
<location>https://github.com/xtermjs/xterm.js/blob/master/addons/addon-unicode-graphemes/README.md</location>
<excerpt>citeturn0search1 [wordlim: 200] Crawled: 2 months ago; An addon providing enhanced Unicode support (include grapheme clustering) for xterm.js.
The file `src/UnicodeProperties.ts` is generated and depends on the Unicode version.
# README.md
Copy path
Top
## @xterm/addon-unicode-graphemes
⚠️ This addon is currently experimental and may introduce unexpected and non-standard behavior
An addon providing enhanced Unicode support (include grapheme clustering) for xterm.js.
The file `src/UnicodeProperties.ts` is generated and depends on the Unicode version. See the unicode-properties project for credits and re-generation instructions.
### Install
This addon is not yet published to npm
### Usage
import { Terminal } from '@xterm/xterm';
import { UnicodeGraphemesAddon } from '@xterm/addon-unicode-graphemes';
const terminal = new Terminal();
const unicodeGraphemesAddon = new UnicodeGraphemesAddon();
terminal.loadAddon(unicodeGraphemesAddon);</excerpt>
</source>
<source kind="search">
<title>Unchanged links repeatedly fire leave and hover during unrelated row updates · Issue #6213 · xtermjs/xterm.js · GitHub</title>
<location>GitHub issue 6213 in xtermjs/xterm.js (link omitted to avoid creating a cross-reference)</location>
<excerpt>citeturn0search2 [wordlim: 200] Published: 2 weeks ago; Crawled: 2 days ago; <script src="https://cdn.jsdelivr.net/npm/@xterm/[email protected]/lib/xterm.js"></script>
# Unchanged links repeatedly fire leave and hover during unrelated row updates #6213
Open
Unchanged links repeatedly fire leave and hover during unrelated row updates#6213
## Description
redblackbst
opened on Oct 11, 2026
Issue body actions
First noticed while using Codex CLI with animations enabled inside tmux in VS Code’s integrated terminal, both locally and over Remote SSH.
Updating unrelated terminal rows repeatedly fires `leave` and `hover` for an unchanged hovered link. This cancels a delayed tooltip before it can appear.
## Details
* Browser: Microsoft Edge 155.0.4283.45 (headless validation)
* VS Code: 1.141.0 (Electron `43.7.7`, Chromium `150.0.7871.250`)
* OS: Arch Linux x86_64, kernel `7.2.9-arch1-1`
* xterm.js: 6.1.0-beta.304
* Terminal: 80 columns, 14 rows; fixed-provider and native OSC 8 links
### Steps to reproduce
1. Save the HTML below as `xterm-repro.html`.
2. Serve its directory with `python3 -m http.server 8000 --bind 127.0.0.1` and open `http://127.0.0.1:8000/xterm-repro.html`.
</excerpt>
</source>
<omitted_sources count="19">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>
Citations:
- 1: https://github.com/xtermjs/xterm.js/blob/master/src/common/CoreTerminal.ts?utm_source=openai
- 2: https://www.npmjs.com/package/%40xterm/xterm?activeTab=versions&utm_source=openai
Script executed:
set -eu
url='https://raw.githubusercontent.com/xtermjs/xterm.js/6.1.0-beta.304/src/common/services/UnicodeService.ts'
curl -fsSL "$url"| nl -ba | sed -n '1,180p']
Load Unicode11Addon before activating the preview provider.
The preview does not register Unicode version 11. activateOrcaTerminalUnicodeProvider(terminal) then selects that version, and xterm throws unknown Unicode version "11" before the preview can render. Load Unicode11Addon before this call, as the live terminal path does.
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Quick win
Exclude BMP private-use characters from wide mode.
When wide mode is enabled, this range makes single-cell private-use icons such as Powerline glyphs occupy two cells. Shell prompts and TUI decorations can then lose alignment. Remove this range from AMBIGUOUS_RANGES and test a private-use icon in both modes. The PR objective explicitly requires these icons to stay single-cell, even though Unicode classifies the range as Ambiguous. (unicode.org)
@xterm/xterm 6.1.0-beta.304 UnicodeV11 charProperties combining mark inherited width
Result:
<source_evidence>
<source kind="search">
<title>IUnicodeVersionProvider</title>
<location>https://xtermjs.org/docs/api/terminal/interfaces/iunicodeversionprovider/</location>
<excerpt>citeturn0search0 [wordlim: 200] Crawled: 6 months ago; Defined in xterm.d.ts:1875 ... ▸ charProperties(`codepoint`: number, `preceding`: number): number ... Unicode version dependent wcwidth implementation.
# Interface: IUnicodeVersionProvider
(EXPERIMENTAL) Unicode version provider. Used to register custom Unicode versions with `Terminal.unicode.register`.
## Hierarchy
* IUnicodeVersionProvider
## Index
### Properties
* version
### Methods
* charProperties
* wcwidth
## Properties
### `Readonly` version
• version: string
Defined in xterm.d.ts:1875
String indicating the Unicode version provided.
## Methods
### charProperties
▸ charProperties(`codepoint`: number, `preceding`: number): number
Defined in xterm.d.ts:1881
Parameters:
Name | Type
--- | ---
`codepoint` | number
`preceding` | number
Returns: number
### wcwidth
▸ wcwidth(`codepoint`: number): *0 | 1 | 2*
Defined in xterm.d.ts:1880
Unicode version dependent wcwidth implementation.
Parameters:
Name | Type
--- | ---
`codepoint` | number
Returns: *0 | 1 | 2*</excerpt>
</source>
<source kind="search">
<title>IUnicodeVersionProvider</title>
<location>https://xtermjs.org/docs/api/terminal/interfaces/iunicodeversionprovider/</location>
<excerpt>citeturn1search0 [wordlim: 200] Crawled: 6 months ago; * charProperties ... Defined in xterm.d.ts:1881
# Interface: IUnicodeVersionProvider
(EXPERIMENTAL) Unicode version provider. Used to register custom Unicode versions with `Terminal.unicode.register`.
## Hierarchy
* IUnicodeVersionProvider
## Index
### Properties
* version
### Methods
* charProperties
* wcwidth
## Properties
### `Readonly` version
• version: string
Defined in xterm.d.ts:1875
String indicating the Unicode version provided.
## Methods
### charProperties
▸ charProperties(`codepoint`: number, `preceding`: number): number
Defined in xterm.d.ts:1881
Parameters:
Name | Type
--- | ---
`codepoint` | number
`preceding` | number
Returns: number
### wcwidth
▸ wcwidth(`codepoint`: number): *0 | 1 | 2*
Defined in xterm.d.ts:1880
Unicode version dependent wcwidth implementation.
Parameters:
Name | Type
--- | ---
`codepoint` | number
Returns: *0 | 1 | 2*</excerpt>
</source>
<source kind="search">
<title>xterm.js/addons/addon-unicode11/README.md at master · xtermjs/xterm.js · GitHub</title>
<location>https://github.com/xtermjs/xterm.js/blob/master/addons/addon-unicode11/README.md</location>
<excerpt>citeturn1search1 [wordlim: 200] Crawled: 2 months ago; An addon providing Unicode version 11 rules for xterm.js.
# README.md
Copy path
# README.md
Copy path
Top
## @xterm/addon-unicode11
An addon providing Unicode version 11 rules for xterm.js.
### Install
npm install --save @xterm/addon-unicode11
### Usage
import { Terminal } from '@xterm/xterm';
import { Unicode11Addon } from '@xterm/addon-unicode11';
const terminal = new Terminal();
const unicode11Addon = new Unicode11Addon();
terminal.loadAddon(unicode11Addon);
// activate the new version
terminal.unicode.activeVersion = '11';
</excerpt>
</source>
<source kind="search">
<title>xterm.js/typings/xterm.d.ts at master · xtermjs/xterm.js · GitHub</title>
<location>https://github.com/xtermjs/xterm.js/blob/master/typings/xterm.d.ts</location>
<excerpt>citeturn0search1 [wordlim: 200] Crawled: yesterday; * This contains the type declarations for the xterm.js library. ... * src/, that's because this file declares the *public* API which is intended ... * A string containing all characters that are considered word separated by ... * [0]: https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md ... * Resize the text area to given height and width in characters. ... /** Ps=11 Report xterm window state.
*/
export class Terminal implements IDisposable {
/**
* The element containing the terminal.
*/
readonly element: HTMLElement | undefined;
/**
* The screen element containing the terminal's canvas rendering layers and
* decorations, excluding the viewport and the scrollbar.
*/
readonly screenElement: HTMLElement | undefined;
/**
* The textarea that accepts input for the terminal.
*/
readonly textarea: HTMLTextAreaElement | undefined;
/**
* The number of rows in the terminal's viewport. Use
* `ITerminalOptions.rows` to set this in the constructor and
* `Terminal.resize` for when the terminal exists.
*/
readonly rows: number;
/**
* The number of columns in the terminal's viewport. Use
* `ITerminalOptions.cols` to set this in the constructor and
* `Terminal.resize` for when the terminal exists.
*/
readonly cols: number;
/**
* Access to the terminal's normal and alt buffer.
*/
readonly buffer: IBufferNamespace;
/**
* Get all markers registered against the buffer. If the alt buffer is
* active this will always return [].
*/
readonly markers: ReadonlyArray<IMarker>;
/**
* Get the parser interface to register custom escape sequence handlers.
*/
readonly parser: IParser;
/**
* (EXPERIMENTAL) Get the Unicode handling interface to register and switch
* Unicode version.
*/
readonly unicode: IUnicodeHandling;
/**
* Gets the terminal modes as set by SM/DECSET.
*/
readonly modes: IModes;
/**
* The dimensions of the terminal. This will be undefined before
* {@link open} is called.
*/
readonly dimensions: IRenderDimensions | undefined;
/**
* Gets or sets the terminal options. This supports setting multiple
* options.
*
* @example Get a single option
* ```ts
* console.log(terminal.options.fontSize);
* ```
*
* @example Set a single option:
* ```ts
* terminal.options.fontSize = 12;
</excerpt>
</source>
<source kind="search">
<title>@xterm/xterm - npm</title>
<location>https://www.npmjs.com/package/%40xterm/xterm?activeTab=versions</location>
<excerpt>citeturn0search2 [wordlim: 200] Crawled: 2 days ago; Version | Downloads (Last 7 Days) | Tag
## Versions
### Current Tags
Version | Downloads (Last 7 Days) | Tag
--- | --- | ---
6.0.0 | 2,451,350 | latest
6.1.0-beta.315 | 14,836 | beta
### Version History
Version | Downloads (Last 7 Days) | Published
--- | --- | ---
6.1.0-beta.315 | 14,836 | 14 days ago
6.1.0-beta.314 | 218 | 14 days ago
6.1.0-beta.313 | 3 | 14 days ago
6.1.0-beta.312 | 1 | 14 days ago
6.1.0-beta.311 | 1 | 14 days ago
6.1.0-beta.310 | 1 | 14 days ago
6.1.0-beta.309 | 1 | 14 days ago
6.1.0-beta.308 | 0 | 14 days ago
6.1.0-beta.307 | 0 | 14 days ago
6.1.0-beta.306 | 0 | 14 days ago
6.1.0-beta.305 | 2 | 14 days ago
6.1.0-beta.304 | 112,491 | 2 months ago
6.1.0-beta.303 | 21,008 | 2 months ago
6.1.0-beta.302 | 2,001 | 3 months ago
6.1.0-beta.301 | 1 | 3 months ago
6.1.0-beta.300 | 6 | 3 months ago
</excerpt>
</source>
<omitted_sources count="33">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>
Citations:
- 1: https://xtermjs.org/docs/api/terminal/interfaces/iunicodeversionprovider/?utm_source=openai
- 2: https://github.com/xtermjs/xterm.js/blob/master/addons/addon-unicode11/README.md?utm_source=openai
Script executed:
set -eu
printf'%s\n''--- provider with line numbers ---'
nl -ba src/shared/terminal-unicode-provider.ts | sed -n '1,130p'printf'%s\n''--- relevant package and lock excerpts ---'
nl -ba package.json | sed -n '288,308p'
nl -ba pnpm-lock.yaml | sed -n '400,432p'printf'%s\n''--- focused Unicode/provider tests ---'
find src/shared -maxdepth 1 -type f \\( -name '*unicode*test*' -o -name '*ambiguous*test*'\\) -print
rg -n -F --glob 'src/shared/*test*' -e 'charProperties' -e 'combining' -e 'e\\u0301' -e 'ZWJ' -e 'wcwidth' -e 'ambiguous' src/shared ||test"$?" -eq 1
Repository: stablyai/orca
Length of output: 8373
Web query:
raw xtermjs xterm.js 6.1.0-beta.304 addons/addon-unicode11/src/UnicodeV11.ts charProperties preceding combining mark
Result:
<source_evidence>
<source kind="search">
<title>IUnicodeVersionProvider</title>
<location>https://xtermjs.org/docs/api/terminal/interfaces/iunicodeversionprovider/</location>
<excerpt>citeturn0search2 [wordlim: 200] Crawled: 6 months ago; * charProperties ... Defined in xterm.d.ts:1875
# Interface: IUnicodeVersionProvider
(EXPERIMENTAL) Unicode version provider. Used to register custom Unicode versions with `Terminal.unicode.register`.
## Hierarchy
* IUnicodeVersionProvider
## Index
### Properties
* version
### Methods
* charProperties
* wcwidth
## Properties
### `Readonly` version
• version: string
Defined in xterm.d.ts:1875
String indicating the Unicode version provided.
## Methods
### charProperties
▸ charProperties(`codepoint`: number, `preceding`: number): number
Defined in xterm.d.ts:1881
Parameters:
Name | Type
--- | ---
`codepoint` | number
`preceding` | number
Returns: number
### wcwidth
▸ wcwidth(`codepoint`: number): *0 | 1 | 2*
Defined in xterm.d.ts:1880
Unicode version dependent wcwidth implementation.
Parameters:
Name | Type
--- | ---
`codepoint` | number
Returns: *0 | 1 | 2*</excerpt>
</source>
<source kind="search">
<title>xterm.js 的 @xterm/addon-unicode11 详解:为 Web 终端接入 Unicode 11 字符宽度规则 - AtomGit | GitCode博客</title>
<location>https://blog.gitcode.com/e338a9e8661ecc8f2cc4c37393855ba8.html</location>
<excerpt>citeturn0search5 [wordlim: 200] Published: 4 weeks ago; Crawled: 3 weeks ago; 真正的 Unicode 11 规则逻辑全部集中在 UnicodeV11 中,它实现了 `IUnicodeVersionProvider`(接口见 typings/xterm.d.ts),即必须提供 `version`、`wcwidth(codepoint)` 与 `charProperties(codepoint, preceding)` 三个成员。
# xterm.js 的 @xterm/addon-unicode11 详解:为 Web 终端接入 Unicode 11 字符宽度规则
原创2026-09-30 15:57:17 777 阅读
文章标签:前端UI组件
# xterm.js 的 @xterm/addon-unicode11 详解:为 Web 终端接入 Unicode 11 字符宽度规则
本指南围绕 xterm.js 官方 Unicode 版本扩展 addons/addon-unicode11 展开,讲解如何安装、加载并激活 Unicode 11 字符宽度规则,并结合仓库源码剖析其 `wcwidth` 实现、查找表结构与注册机制。读完本文,你将掌握在 xterm.js 应用中切换 Unicode 版本以正确处理 emoji 等宽字符的完整方案,并能读懂该 Addon 与 `UnicodeService` 之间的底层协作关系。
## 为什么 xterm.js 需要"Unicode 版本规则"
xterm.js 在浏览器中渲染终端文本时,必须精确知道每个字符在等宽栅格中占据的单元格宽度(0、1 或 2 列)。这个宽度判断直接决定光标移动、行包裹、删除与选中高亮是否正确。Unicode 标准从 6.0 到 11.0 之间,大量字符的 East Asian Width(东亚宽度)和组合字符(combining character)属性发生了变化——最典型的就是 emoji 从"单列"演进为"双列"。
为此,xterm.js 将"Unicode 版本"抽象为一套可注册、可切换的规则提供者(`IUnicodeVersionProvider`),默认内置 UnicodeV6(版本号 `'6'`),而 @xterm/addon-unicode11 则以官方 Addon 的形式提供 Unicode 11 版本的实现,覆盖从 xterm.js 5.0 开始引入的 `Terminal.unicode` API。
## 安装
该 Addon 作为独立 npm 包发布(当前仓库内版本为 0.9.0,见 package.json),通过 npm 安装:
`npm install --save @xterm/addon-unicode11
`
它属于运行时(runtime)依赖,依赖宿主包 `@xterm/xterm` 提供的 `Terminal` 与 `ITerminalAddon` 类型。仓库内的 demo/client/tsconfig.json 展示了如何在 demo 项目中通过路径映射将 `@xterm/addon-unicode11` 指向本仓库源码目录进行联调:
`"@xterm/addon-unicode11": [
"../../addons/addon-unicode11"
]
`
2. ASCII 可打印字符(32–126):宽度为 1;
3. BMP 区(码点 < 65536,即 `0xFFFF` 以内):直接查懒加载的 `Uint8Array` 查找表 `table`;
4. BMP 之外(增补平面):先用二分查找 `bisearch` 匹配 `HIGH_COMBINING`(宽度 0),再匹配 `HIGH_WIDE`(宽度 2),否则为 1。
`bisearch`(UnicodeV11.ts)是对已排序的"起始码点/结束码点"区间数组做标准二分查找,复杂度为 O(log n),不会遍历整张表。
### 三张静态区间表 + 一张查找表
文件顶部定义了四组数据(UnicodeV11.ts):
* `BMP_COMBINING`:BMP 内的组合字符区间,例如 `[0x0300, 0x036F]`(拉丁文附加符号)、`[0x1160, 0x11FF]`(谚文韵母)、`[0x20D0, 0x20F0]`(组合用符号);
* `HIGH_COMBINING`:增补平面上的组合字符区间,例如 `[0x1D167, 0x1D169]`(音乐符号)、`[0xE0100, 0xE01EF]`(变体选择符补充区)、`[0x13430, 0x13438]`(埃及象形文字格式化控制符);
* `BMP_WIDE`:BMP 内的宽字符区间,覆盖全部 CJK 统一表意文字 `[0x4E00, 0xA48C]`、谚文音节 `[0xAC00, 0xD7A3]` 等;
* `HIGH_WIDE`:增补平面上的宽字符区间,重点是 emoji:`[0x1F300, 0x1F320]`、`[0x1F337, 0x1F37C]`、`[0x1F680, 0x1F6C5]`、`[0x1F90D, 0x1F971]`,以及 CJK 扩展 B/C/D `[0x20000, 0x2FFFD]`、`[0x30000, 0x3FFFD]`。
`BMP_COMBINING` 与 `BMP_WIDE` 会在首次加载 Addon 时被"编译"进一个 65536 项的 `Uint8Array` 查找表(UnicodeV11.ts):先整体填充 1,控制字符区间填 0,再按 `BMP_COMBINING` 填 0、按 `BMP_WIDE` 填 2。查找表在模块级缓存(`let table: Uint8Array`),因此多个终端实例共享同一份表,只初始化一次。
### `charProperties`:组合字符如何"并入"前一个字符
为了在等宽网格中正确呈现组合字符,`UnicodeV11` 还实现了 `charProperties`(UnicodeV11.ts):当当前码点宽度为 0 且存在前一个字符时,标记"需要并入"(`shouldJoin`),并将宽度继承为前一个字符的宽度;若前一个字符本身宽度为 0,则不并入。最终通过 `UnicodeService.createPropertyValue` 打包成包含宽度与并入标志的属性值,供行渲染与光标推进使用。
</excerpt>
</source>
<source kind="search">
<title>IUnicodeVersionProvider</title>
<location>https://xtermjs.org/docs/api/terminal/interfaces/iunicodeversionprovider/</location>
<excerpt>citeturn2search0 [wordlim: 200] Crawled: 6 months ago; Defined in xterm.d.ts:1875 ... ▸ charProperties(`codepoint`: number, `preceding`: number): number
# Interface: IUnicodeVersionProvider
(EXPERIMENTAL) Unicode version provider. Used to register custom Unicode versions with `Terminal.unicode.register`.
## Hierarchy
* IUnicodeVersionProvider
## Index
### Properties
* version
### Methods
* charProperties
* wcwidth
## Properties
### `Readonly` version
• version: string
Defined in xterm.d.ts:1875
String indicating the Unicode version provided.
## Methods
### charProperties
▸ charProperties(`codepoint`: number, `preceding`: number): number
Defined in xterm.d.ts:1881
Parameters:
Name | Type
--- | ---
`codepoint` | number
`preceding` | number
Returns: number
### wcwidth
▸ wcwidth(`codepoint`: number): *0 | 1 | 2*
Defined in xterm.d.ts:1880
Unicode version dependent wcwidth implementation.
Parameters:
Name | Type
--- | ---
`codepoint` | number
Returns: *0 | 1 | 2*</excerpt>
</source>
<source kind="search">
<title>xterm.js 的 @xterm/addon-unicode11 详解:为 Web 终端接入 Unicode 11 字符宽度规则 - AtomGit | GitCode博客</title>
<location>https://blog.gitcode.com/e338a9e8661ecc8f2cc4c37393855ba8.html</location>
<excerpt>citeturn2search6 [wordlim: 200] Published: 4 weeks ago; Crawled: 3 weeks ago; 真正的 Unicode 11 规则逻辑全部集中在 UnicodeV11 中,它实现了 `IUnicodeVersionProvider`(接口见 typings/xterm.d.ts),即必须提供 `version`、`wcwidth(codepoint)` 与 `charProperties(codepoint, preceding)` 三个成员。
# xterm.js 的 @xterm/addon-unicode11 详解:为 Web 终端接入 Unicode 11 字符宽度规则
原创2026-09-30 15:57:17 777 阅读
文章标签:前端UI组件
# xterm.js 的 @xterm/addon-unicode11 详解:为 Web 终端接入 Unicode 11 字符宽度规则
本指南围绕 xterm.js 官方 Unicode 版本扩展 addons/addon-unicode11 展开,讲解如何安装、加载并激活 Unicode 11 字符宽度规则,并结合仓库源码剖析其 `wcwidth` 实现、查找表结构与注册机制。读完本文,你将掌握在 xterm.js 应用中切换 Unicode 版本以正确处理 emoji 等宽字符的完整方案,并能读懂该 Addon 与 `UnicodeService` 之间的底层协作关系。
## 为什么 xterm.js 需要"Unicode 版本规则"
xterm.js 在浏览器中渲染终端文本时,必须精确知道每个字符在等宽栅格中占据的单元格宽度(0、1 或 2 列)。这个宽度判断直接决定光标移动、行包裹、删除与选中高亮是否正确。Unicode 标准从 6.0 到 11.0 之间,大量字符的 East Asian Width(东亚宽度)和组合字符(combining character)属性发生了变化——最典型的就是 emoji 从"单列"演进为"双列"。
为此,xterm.js 将"Unicode 版本"抽象为一套可注册、可切换的规则提供者(`IUnicodeVersionProvider`),默认内置 UnicodeV6(版本号 `'6'`),而 @xterm/addon-unicode11 则以官方 Addon 的形式提供 Unicode 11 版本的实现,覆盖从 xterm.js 5.0 开始引入的 `Terminal.unicode` API。
## 安装
该 Addon 作为独立 npm 包发布(当前仓库内版本为 0.9.0,见 package.json),通过 npm 安装:
`npm install --save @xterm/addon-unicode11
`
它属于运行时(runtime)依赖,依赖宿主包 `@xterm/xterm` 提供的 `Terminal` 与 `ITerminalAddon` 类型。仓库内的 demo/client/tsconfig.json 展示了如何在 demo 项目中通过路径映射将 `@xterm/addon-unicode11` 指向本仓库源码目录进行联调:
`"@xterm/addon-unicode11": [
"../../addons/addon-unicode11"
]
`
public activate(terminal: Terminal): void {
terminal.unicode.register(new UnicodeV11());
}
public dispose(): void { }
}
`
真正的 Unicode 11 规则逻辑全部集中在 UnicodeV11 中,它实现了 `IUnicodeVersionProvider`(接口见 typings/xterm.d.ts),即必须提供 `version`、`wcwidth(codepoint)` 与 `charProperties(codepoint, preceding)` 三个成员。
### `wcwidth`:三种宽度的判定流程
`UnicodeV11.wcwidth` 是核心方法,输入一个 Unicode 码点,输出 0(组合字符/控制字符)、1(单列)或 2(双列):
`public wcwidth(num: number): UnicodeCharWidth {
if (num < 32) return 0;
if (num < 127) return 1;
if (num < 65536) return table[num] as UnicodeCharWidth;
if (bisearch(num, HIGH_COMBINING)) return 0;
if (bisearch(num, HIGH_WIDE)) return 2;
return 1;
}
`
其判定层次为:
1. ASCII 控制字符(0–31):宽度为 0;
* `BMP_WIDE`:BMP 内的宽字符区间,覆盖全部 CJK 统一表意文字 `[0x4E00, 0xA48C]`、谚文音节 `[0xAC00, 0xD7A3]` 等;
* `HIGH_WIDE`:增补平面上的宽字符区间,重点是 emoji:`[0x1F300, 0x1F320]`、`[0x1F337, 0x1F37C]`、`[0x1F680, 0x1F6C5]`、`[0x1F90D, 0x1F971]`,以及 CJK 扩展 B/C/D `[0x20000, 0x2FFFD]`、`[0x30000, 0x3FFFD]`。
`BMP_COMBINING` 与 `BMP_WIDE` 会在首次加载 Addon 时被"编译"进一个 65536 项的 `Uint8Array` 查找表(UnicodeV11.ts):先整体填充 1,控制字符区间填 0,再按 `BMP_COMBINING` 填 0、按 `BMP_WIDE` 填 2。查找表在模块级缓存(`let table: Uint8Array`),因此多个终端实例共享同一份表,只初始化一次。
### `charProperties`:组合字符如何"并入"前一个字符
为了在等宽网格中正确呈现组合字符,`UnicodeV11` 还实现了 `charProperties`(UnicodeV11.ts):当当前码点宽度为 0 且存在前一个字符时,标记"需要并入"(`shouldJoin`),并将宽度继承为前一个字符的宽度;若前一个字符本身宽度为 0,则不并入。最终通过 `UnicodeService.createPropertyValue` 打包成包含宽度与并入标志的属性值,供行渲染与光标推进使用。
## 底层机制:`UnicodeService` 与 `getStringCellWidth`
`activeVersion` 的赋值最终进入核心层的 UnicodeService:设置前校验版本是否已注册,然后更新 `_activeProvider` 并触发 `onChange` 事件。此后所有宽度计算都路由到当前激活的 provider:
`public set activeVersion(version: string) {
if (!this._providers[version]) {
throw new Error(`unknown Unicode version "${version}"`);
}
this._active = version;
this._activeProvider = this._providers[version];
this._onChange.fire(version);
}
`
UnicodeService 还提供 `getStringCellWidth(s)`(UnicodeService.ts),它对整段字符串逐字符计算总宽度:正确处理 UTF-16 代理对(surrogate pair)合并为增补平面码点、组合字符并入前驱宽度、以及将"并入差值"从总宽度中扣除。这是终端行缓冲、光标定位与文本测量都依赖的核心口径——`Unicode11Addon` 测试也正是通过 `window.term._core.unicodeService.getStringCellWidth('🤣'.repeat(10))` 来断言宽度结果的。
## 在 demo 应用中的真实接入方式
仓库自带的 demo 客户端 demo/client/client.ts 提供了可交互的验证入口:它在 Addon 集合中注册了 `unicode11`(构造器指向 `Unicode11Addon`,见 demo/client/client.ts),并在界面上勾选该 Addon 时执行:
`if (name === 'unicode11' && checkbox.checked) {
term.unicode.activeVersion = '11';
}
`
而取消勾选时则回退到默认版本(demo/client/client.ts):
`} else if (name === 'unicode11' || name === 'unicodeGraphemes') {
term.unicode.activeVersion = '6';
}
`
你可以运行 demo(仓库脚本 `npm start` 会启动 demo/start.js)来直观对比同一串 emoji 在 `'6'` 与 `'11'` 两种规则下的渲染宽度差异。
## 注意事项与延伸阅读
* 接口为实验性:`IUnicodeVersionProvider` 与 `IUnicodeHandling` 在 typings/xterm.d.ts 中均标注为 `(EXPERIMENTAL)`,后续版本可能存在 API 调整;
* 与 grapheme 插件的关系:若需要按字素簇(grapheme cluster,如带肤色修饰符的 emoji)进一步合并字符,可配合 addon-unicode-graphemes 使用(其激活版本号为 `'15-graphemes'`,demo 中的切换逻辑见 demo/client/client.ts);
* 字体依赖:Unicode 11 宽度规则只解决"网格占用列数"问题,实际渲染效果仍取决于终端所用字体是否包含对应字形(emoji 需要 emoji 字体支持);
* 版本含义:`version = '11'` 对应 Unicode 11.0 标准的 East Asian Width 与组合字符属性表(源自 Unicode 官方 UCD 数据,仓库内以区间常量形式固化在 UnicodeV11.ts)。
总之,`@xterm/addon-unicode11` 是让 xterm.js 应用跟上现代 Unicode 宽度语义的最直接手段:安装、加载、切换 `activeVersion` 三步即可生效,而其背后的区间表、查找表与代理对处理逻辑,也为理解终端文本测宽机制提供了完整的可读源码范例。</excerpt>
</source>
<source kind="search">
<title>xterm.js/addons/addon-unicode-graphemes/README.md at master · xtermjs/xterm.js · GitHub</title>
<location>https://github.com/xtermjs/xterm.js/blob/master/addons/addon-unicode-graphemes/README.md</location>
<excerpt>citeturn0search0 [wordlim: 200] Crawled: 2 months ago; An addon providing enhanced Unicode support (include grapheme clustering) for xterm.js.
The file `src/UnicodeProperties.ts` is generated and depends on the Unicode version.
# README.md
Copy path
Top
## @xterm/addon-unicode-graphemes
⚠️ This addon is currently experimental and may introduce unexpected and non-standard behavior
An addon providing enhanced Unicode support (include grapheme clustering) for xterm.js.
The file `src/UnicodeProperties.ts` is generated and depends on the Unicode version. See the unicode-properties project for credits and re-generation instructions.
### Install
This addon is not yet published to npm
### Usage
import { Terminal } from '@xterm/xterm';
import { UnicodeGraphemesAddon } from '@xterm/addon-unicode-graphemes';
const terminal = new Terminal();
const unicodeGraphemesAddon = new UnicodeGraphemesAddon();
terminal.loadAddon(unicodeGraphemesAddon);</excerpt>
</source>
<omitted_sources count="22">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>
Citations:
- 1: https://blog.gitcode.com/e338a9e8661ecc8f2cc4c37393855ba8.html?utm_source=openai
- 2: https://xtermjs.org/docs/api/terminal/interfaces/iunicodeversionprovider/?utm_source=openai
For e\u0301, Unicode11 returns the combining mark with the preceding cell width and the join flag. This branch changes that width to zero whenever the raw width differs, including in narrow mode. getStringCellWidth('e\u0301X') can then subtract the preceding width twice and misplace X.
Rewrite packed properties only for the intended base-width-one to wide expansion.
Suggested fix
--- "a/src/shared/terminal-unicode-provider.ts"+++ "b/src/shared/terminal-unicode-provider.ts"@@ -84,9 +84,9 @@
)
// Why: charProperties packs width into the property word; keep it aligned
// with wcwidth when wide-mode expands East Asian Ambiguous cells.
- if (desiredWidth !== extractWidth(base)) {+ if (desiredWidth === 2 && extractWidth(base) === 1) {
return createProperties(extractCharKind(base), desiredWidth, (base & 1) === 1)
}
return base
}
}
Add a regression test for e\u0301X in both width modes.
Committable suggestion
IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Add terminalEastAsianAmbiguousWidth (narrow|wide, default narrow) so CJK
locales can match conhost double-width ambiguous glyphs (① ■ ★ →) without
changing the modern CLI-aligned default. Wide mode also inserts CJK UI
fonts ahead of Consolas so full-size glyphs fill the two-cell slot.
Closesstablyai#9958
buildFontFamily only adjusts the CJK fallback stack; activate Orca's
unicode provider (and wide ambiguous mode) before writing the sample
buffer so the preview measures like live panes.
DoDAON / stablyai#9958 asked for all three activation sites. Desktop already set
mode + OrcaUnicodeProvider; this pass completes the twins:
- Headless: honor eastAsianAmbiguousWidth (runtime store + settings sync)
- Mobile: bundle Orca unicode into the WebView engine and activate after
Unicode11 (was bypassing Orca entirely); CJK font stack when wide
- Provider as plain object so the Chrome 74 engine floor parses cleanly
Evidence: headless-emulator-unicode-width + mobile engine/html tests
Rebased onto current upstream/main. The startup import conflict keeps the moved applyAppIcon path and this PR's setTerminalEastAsianAmbiguousWidthMode call, so wide East Asian Ambiguous width still applies at launch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Opt-in setting for East Asian Ambiguous character cell width (iTerm2-style escape hatch), requested in #9958.
On Windows CJK locales, characters like
①■●★→render poorly in Orca because:This PR keeps the modern CLI-aligned default (
narrow) and adds Wide mode that:OrcaUnicodeProviderChanges
terminalEastAsianAmbiguousWidth: 'narrow' | 'wide'(defaultnarrow)resolveEastAsianAmbiguousCellWidthbuildFontFamily(..., { eastAsianAmbiguousWide })CJK fallback insertionFixes #9958
Screenshots
Narrow/Wide)Testing
pnpm exec vitest run --config config/vitest.config.ts src/shared/east-asian-ambiguous-width.test.ts src/shared/terminal-unicode-provider.test.ts src/renderer/src/components/terminal-pane/layout-serialization.test.ts(40/40)pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/lib/pane-manager/pane-lifecycle.test.ts(30/30)pnpm lint/pnpm typecheck/pnpm test/pnpm buildAI Review Report
wcwidthandcharPropertiesstay aligned when wide expands ambiguous cellsSecurity Audit
Notes
ELI5
Some CJK symbols looked too skinny or wrong in the terminal on Windows. There is an optional Wide mode for East Asian Ambiguous characters so shapes like stars and arrows get a full cell width when you want that.