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

buffer translateToString()/getChars() return '' for empty cells, collapsing cursor-positioned text

未关闭 适合新手
#205 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
75/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
api

调研方向

从 lib/buffer.ts 开始,查看 getChars() 对 codepoint === 0 的单元格返回空字符串的逻辑,以及基于它实现的 translateToString。以 TerminalCore.getSelection() 作为参考,因为它已经用空格替代空单元格。当 issue 中的复现步骤通过 translateToString(true) 得到 "a b",并且末尾空白的裁剪仍然有效时,即为完成。

由索引模型根据 Issue 内容生成。

描述

Summary

IBufferLine.translateToString() (and IBufferCell.getChars()) return '' for empty cells (codepoint === 0), so text that an application positioned with cursor movement collapses: every blank run is removed and the remaining characters are glued together. xterm.js returns a space for an empty cell (translateToString(trimRight) keeps the layout). TerminalCore.getSelection() already does the right thing (k += " " for codepoint === 0), so the two disagree on the same screen.

This is separate from #200 (multi-codepoint graphemes truncated); the blank-cell case affects plain ASCII. Seen on [email protected]; lib/buffer.ts on main has the same codepoint === 0 ? '' in getChars().

Minimal reproduction

<div id="t"></div>
<script type="module">
  import { init, Terminal } from 'ghostty-web';
  await init();
  const term = new Terminal({ cols: 40, rows: 5 });
  term.open(document.getElementById('t'));
  // "a", move right 5 columns (CUF), "b": what vim/htop/tmux status bars do all the time
  term.write('a\x1b[5Cb', () => {
    const line = term.buffer.active.getLine(0);
    console.log(JSON.stringify(line.translateToString(true))); // actual: "ab"   expected: "a     b"
    term.select(0, 0, 7);
    console.log(JSON.stringify(term.getSelection()));           // "a     b" (selection is correct)
  });
</script>

Anything built on the public buffer API (search, serialize, accessibility mirrors, "copy line", tests) sees the collapsed text.

Suggested fix

getChars() returns ' ' for codepoint === 0 (width 1), or translateToString substitutes ' ' for empty cells before trimEnd().

Found while comparing renderers for https://github.com/erisera-code/clawser.

主要语言
TypeScript
星标
3k
派生
183
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 摘要。