Repository navigation
rust: measure text with the width method the terminal reports - #1955
Merged
Merged
Conversation
App cached its width method before the terminal's startup replies arrived. When a reply changed it, as ConPTY's DECRPM 2027 "unrecognized" answer switches drawing to wcwidth, native drawing followed but App::width_method() did not. Widgets then measured a ZWJ emoji as 2 cells and drew 4: a right-aligned table cell blanked it, a gutter sign was clipped, and an input created later wrote over part of it. A scrollback writer's detached app and its native session followed only at its next render, so text, Markdown and code built after the reply wrapped as before it. App::width_method() now reads the session's capabilities on each call, as App::hyperlinks() and Core's widthMethod do, and the cached copy is gone. A scrollback writer's detached app copies its parent's terminal state before it reads it or makes a native node, as Core syncs before it builds a scrollback snapshot. NoZwj reads as Unicode, which native draws it with, as Core does. The line-number gutter remembers the method it measured its signs with and measures them again when it changes, as Core's LineNumberRenderable does. Source lines added: the parent session and the copy before reads and new nodes, skipped while a frame runs (14), the NoZwj arm and its comment (4), and the gutter's remembered method (6), against 10 removed with the cache. Issue: 448
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Appcached its width method before the terminal answered the startup queries. When a reply changed it, as ConPTY's DECRPM 2027 "unrecognized" answer switches drawing to wcwidth, native drawing followed butApp::width_method()did not. Widgets then measured a ZWJ emoji as 2 cells and drew 4: a right-aligned table cell blanked it, a gutter sign was clipped, and an input created later wrote over part of the emoji. AScrollback's app and its session followed only at their next render, so text, Markdown and code built after the reply wrapped as before it. WithOPENTUI_FORCE_NOZWJ, it reportedNoZwj, which native draws as Unicode.App::width_method()now reads the session's capabilities on each call, as Core'swidthMethoddoes. AScrollback's app copies its parent's terminal state, hyperlink support included, before it reads it or makes a node, as Core does.NoZwjreads as Unicode, as in Core. The line-number gutter measures its signs again when the method changes, as Core'sLineNumberRenderabledoes.A remote-terminal test covers wcwidth, back to Unicode, Ghostty's wide mode and
NoZwj, checking a table, a gutter sign, scrollback snapshots of text, Markdown, code and a link, an input created after the reply, and the cursor.