buffer translateToString()/getChars() return '' for empty cells, collapsing cursor-positioned text
还没有人认领这个 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,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
coder/ghostty-web 的其他 Issue
-
难度 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 ·
-
Public buffer getChars and translateToString truncate multi-codepoint graphemes可能已有人在做 @schickling-assistant 于 13 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 76/100
coder/ghostty-web#200 ·
-
难度 3/5 1-2 天 新手友好度 72/100
coder/ghostty-web#198 ·
查看 coder/ghostty-web 的全部 Issue
相似的 Issue
-
fix(frontend): correct VITE_IS_DEVELPOMENT typo in shared/app.ts and align dev environment flags未关闭
难度 2/5 1-3 小时 新手友好度 75/100
vicharanashala/ajrasakha#1439 ·
维护者通常 1 天内回复
-
approved check:passed streams:add
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
codex-team/editor.js#3037 ·
-
complexity: trivial good first issue impact: low
难度 1/5 1 小时以内 新手友好度 78/100
ueberdosis/tiptap#8522 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
wormhole-foundation/wormhole#5062 ·
维护者通常 1 天内回复