Public buffer getChars and translateToString truncate multi-codepoint graphemes
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 76/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript, wasm
调研方向
Start with Buffer.getLine(), BufferCell.getChars(), and translateToString(), then compare their scalar-cell handling with the existing viewport and scrollback grapheme accessors. Reproduce the examples with Bun 1.4.2 and verify that exported buffer text preserves each complete grapheme while retaining existing line snapshot behavior and empty wide-character spacer cells.
由索引模型根据 Issue 内容生成。
描述
Problem
[email protected] public buffer getChars() and translateToString() truncate multi-codepoint graphemes. The real WASM core retains the complete text; this report is specifically about buffer export, not visible canvas rendering or parsing.
Minimal reproduction
After bun add [email protected], run with Bun 1.4.2:
import { Ghostty, Terminal } from 'ghostty-web'
const ghostty = await Ghostty.load()
for (const input of ['ASCII', 'é', '👩💻', '👋🏽', '🇺🇸']) {
const core = ghostty.createTerminal(24, 2)
const terminal = new Terminal({ ghostty, cols: 24, rows: 2 })
// Headless setup only: attach the real WASM core to the public buffer wrapper.
terminal.wasmTerm = core
core.write(input)
const line = terminal.buffer.active.getLine(0)
console.log({ input, buffer: line.translateToString(true),
firstCell: line.getCell(0).getChars(), core: core.getGraphemeString(0, 0) })
// Do not dispose these instances: teardown corruption is separately tracked in #141.
}
Expected: buffer export equals input. Actual: ASCII matches, but é becomes e, 👩💻 becomes 👩, 👋🏽 becomes 👋, and 🇺🇸 becomes 🇺. The low-level grapheme lookup returns complete text in every case. Reproduced on Linux x64.
Root cause / proposed fix
Buffer.getLine() only forwards scalar cells to BufferLine; BufferCell.getChars() uses String.fromCodePoint(cell.codepoint) without consulting grapheme_len or the existing viewport/scrollback grapheme accessors. translateToString() concatenates these truncated values.
Snapshot complete grapheme text alongside the scalar cells when creating a buffer line, using the appropriate viewport or scrollback lookup. This preserves existing line snapshot behavior and empty wide-character spacer cells.
Repeated open/closed issue and PR searches found no matching buffer-export report. Related but distinct: #141 tracks memory corruption when freeing terminals containing these graphemes; this is not a duplicate report for that teardown bug.
Posted on behalf of @schickling
| field | value |
|---|---|
agent_identity |
unknown |
session |
dev5.01a09047 |
agent_persona |
generalist |
agent_supervisor |
unavailable |
agent_tool |
OMP |
agent_tool_version |
18.4.4 |
agent_runtime |
OMP 18.4.4 |
agent_model |
anthropic/claude-opus-5-5 |
worktree |
dotfiles/main |
tooling_profile |
dotfiles@7a9494a |
- 主要语言
- TypeScript
- 星标
- 2.9k
- 派生
- 182
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
coder/ghostty-web 的其他 Issue
-
buffer translateToString()/getChars() return '' for empty cells, collapsing cursor-positioned text未关闭
难度 2/5 1-3 小时 新手友好度 75/100
coder/ghostty-web#205 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
coder/ghostty-web#204 ·
-
Alt+<printable key> sends the bare key with no ESC prefix (readline/emacs/tmux meta bindings lost)未关闭
难度 2/5 1-3 小时 新手友好度 72/100
coder/ghostty-web#203 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
coder/ghostty-web#199 ·
-
难度 3/5 1-2 天 新手友好度 72/100
coder/ghostty-web#198 ·
查看 coder/ghostty-web 的全部 Issue
相似的 Issue
-
bug help wanted
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
agent-task risk:low
难度 1/5 1-3 小时 新手友好度 88/100
guyellis/http-status-check#512 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
microsoft/playwright#43327 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/TypeScript#64758 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 65/100
opensearch-project/OpenSearch-Dashboards#12937 ·
维护者通常 2 天内回复