Repository navigation
deps: Update uucode to latest - #9678
Merged
Merged
Conversation
mitchellh
added a commit
that referenced
this pull request
Nov 24, 2025
This PR builds on #9678 ~so the diff from there is included here (it's not possible to stack PRs unless it's a PR against my own fork)--review that one first!~ This PR fixes an issue with the VS15/VS16 handling in terminal `print`, where before we didn't check for valid sequences if the base code point is an emoji. This meant that a VS15 after an emoji that isn't part of a valid sequence would narrow the cell, despite that the emoji doesn't have a text presentation. This PR also uses a single `is_emoji_vs_base` instead of the `is_emoji_vs_emoji` and `is_emoji_vs_text`. See the [uucode comment](https://github.com/jacobsandlund/uucode/blob/215ff097303ab19e0f3a0a4e66ab3cd38c2c86ae/src/config.zig#L239-L254) for why I'm recommending this. AI was used in some of the uucode changes in #9678 (Amp--primarily for tests), but everything was carefully vetted and much of it done by hand. This PR was made without AI.
mitchellh
added a commit
that referenced
this pull request
Jan 20, 2026
…ec (#9680) This PR builds on #9678 ~so the diff from there is included here (it's not possible to stack PRs unless it's a PR against my own fork)--review that one first!~ This PR updates the `graphemeBreak` calculation to use `uucode`'s `computeGraphemeBreakNoControl`, which has [tests in uucode](https://github.com/jacobsandlund/uucode/blob/215ff097303ab19e0f3a0a4e66ab3cd38c2c86ae/src/x/grapheme.zig#L753) that confirm it passes the `GraphemeBreakTest.txt` (minus some exceptions). Note that the `grapheme_break` (and `grapheme_break_no_control`) property in `uucode` incorporates `emoji_modifier` and `emoji_modifier_base`, diverging from UAX #29 but matching UTS #51. See [this comment in uucode](https://github.com/jacobsandlund/uucode/blob/215ff097303ab19e0f3a0a4e66ab3cd38c2c86ae/src/grapheme.zig#L420-L434) for details. The `grapheme_break_no_control` property and `computeGraphemeBreakNoControl` both assume `control`, `cr`, and `lf` have been filtered out, matching the current grapheme break logic in Ghostty. This PR keeps the `Precompute.data` logic mostly equivalent, since the `uucode` `precomputedGraphemeBreak` lacks benchmarks in the `uucode` repository (it was benchmarked in [the original PR adding `uucode` to Ghostty](#8757)). Note however, that due to `grapheme_break` being one bit larger than `grapheme_boundary_class` and the new `BreakState` also being one bit larger, the state jumps up by a factor of 8 (u10 -> u13), to 8KB. ## Benchmarks ~I benchmarked the old `main` version versus this PR for `+grapheme-break` and surprisingly this PR is 2% faster (?). Looking at the assembly though, I'm thinking something else might be causing that. Once I get to the bottom of that I'll remove the below TODO and include the benchmark results here.~ When seeing the speedup with `data.txt` and maybe a tiny speedup on English wiki, I was surprised given the 1KB -> 8KB tables. Here's what AI said when I asked it to inspect the assembly: https://ampcode.com/threads/T-979b1743-19e7-47c9-8074-9778b4b2a61e, and here's what it said when I asked it to predict the faster version: https://ampcode.com/threads/T-3291dcd3-7a21-4d24-a192-7b3f6e18cd31 It looks like two loads got reordered and that put the load that depended on stage1 -> stage2 -> stage3 second, "hiding memory latency". So that makes the new one faster when looking up the `grapheme_break` property. These gains go away with the Japanese and Arabic benchmarks, which spend more time processing utf8, and may even have more grapheme clusters too. ### with data.txt (200 MB ghostty-gen random utf8) <img width="1822" height="464" alt="CleanShot 2025-11-26 at 08 42 03@2x" src="https://github.com/user-attachments/assets/56d4ee98-21db-4eab-93ab-a0463a653883" /> ### with English wiki dump <img width="2012" height="506" alt="CleanShot 2025-11-26 at 08 43 15@2x" src="https://github.com/user-attachments/assets/230fbfb7-272d-4a2a-93e7-7268962a9814" /> ### with Japanese wiki dump <img width="2008" height="518" alt="CleanShot 2025-11-26 at 08 43 49@2x" src="https://github.com/user-attachments/assets/edb408c8-a604-4a8f-bd5b-80f19e3d65ee" /> ### with Arabic wiki dump <img width="2010" height="512" alt="CleanShot 2025-11-26 at 08 44 25@2x" src="https://github.com/user-attachments/assets/81a29ac8-0586-4e82-8276-d7fa90c31c90" /> TODO: * [x] Take a closer look at the assembly and understand why this PR (8 KB vs 1 KB table) is faster on my machine. * [x] _(**edit**: checking this off because it seems unnecessary)_ If this turns out to actually be unacceptably slower, one possibility is to switch to `uucode`'s `precomputedGraphemeBreak` which uses a 1445 byte table since it uses a dense table (indexed using multiplication instead of bitCast, though, which did show up in the initial benchmarks from #8757 a small amount.) AI was used in some of the uucode changes in #9678 (Amp--primarily for tests), but everything was carefully vetted and much of it done by hand. This PR was made without AI with the exception of consulting AI about whether the "Prepend + ASCII" scenario is common (hopefully it's right about that being uncommon).
mitchellh
added a commit
that referenced
this pull request
Feb 23, 2026
This PR updates the logic in Terminal `print` to include more cases of changing a cell to be wide due to a grapheme cluster that needs to be wide but starts off narrow. The existing case of this is a text-presentation code point followed by VS16 to make it emoji presentation. This PR handles more cases that are found in scripts such as Devanagari where the correct grapheme width calculation sums up multiple code points of non-zero widths. An example, as seen from [uucode's issue #1](jacobsandlund/uucode#1) is `क्ष`, which now with #9680 merged is one grapheme cluster instead of two, but the U+0915 (first code point) is width one and U+0937 (final code point) is also width one, and the whole cluster should be width 1 + 1 = 2. This is important to address with the grapheme break change otherwise these scripts would show with narrow cells, incorrectly. Before: <img width="680" height="124" alt="CleanShot 2026-01-27 at 10 31 24@2x" src="https://github.com/user-attachments/assets/4ff5959d-9c14-4062-8280-83004af38495" /> After: <img width="646" height="118" alt="CleanShot 2026-01-27 at 10 29 10@2x" src="https://github.com/user-attachments/assets/3ad11afd-2141-46fb-b22b-9fa7b2546366" /> --- Note that the logic here just takes `width_zero_in_grapheme` and if it's not zero width, makes the cell wide. This is actually wrong for graphemes with `prepend` (usually/always? zero width) followed by a character that should be narrow width, but that's affecting a much smaller number of graphemes. To address that, we would need to run the full `wcwidth` from `uucode` on the grapheme, and compare the width output with the current cell's `Wide`. I figured it'd be better to incrementally just handle the bulk of the cases with the `width_zero_in_grapheme` check. This also adds tests to make sure moving the cell is handled correctly, which was not the case for the existing VS16 logic. There's a lot of code here to handle transferring the graphemes when the narrow cell should wrap to the next line to become wide. I'd like feedback on the approach here before attempting to clean anything up, if desired (pull it out into a separate method?). AI was used in some of the uucode changes in #9678 (Amp--primarily for tests), but everything was carefully vetted and much of it done by hand. This PR was made without AI.
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.
This updates uucode to the latest version, with the following changes: jacobsandlund/uucode@b309dfb...31655fb
For this PR, the new
uucodeversion has two changes that contribute to the diff:grapheme_breaknow includesemoji_modifierandemoji_modifier_base, so we don't need to grab those fromis_emoji_modifierandis_emoji_modifier_base.wcwidthcalculation has been split intowcwidth_standalone(width of a code point when it's the only code point in a grapheme) andwcwidth_zero_in_grapheme(whether the code point is not contributing to the width of a multi-code-point grapheme). To keep the current Ghostty behavior for this PR, this setswidthto 0 ifwcwidth_zero_in_grapheme, but with the exception ofis_emoji_modifier(see comment).PRs will follow this in a moment to also take advantage of the new
uucodeversion for:Edit: AI was used in some of the
uucodechanges (Amp), but everything was carefully vetted and much of it hand rolled. Primarily AI helped with tests.