Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Public buffer getChars and translateToString truncate multi-codepoint graphemes

未关闭
#200 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@schickling-assistant 已经在做这个了。

开始于 2026年10月1日。

  • #201 来自 @schickling-assistant —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript, wasm
领域
frontend, web-dev

调研方向

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,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

coder/ghostty-web 的其他 Issue

查看 coder/ghostty-web 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。