Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#205 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
75/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
api

調査の方向性

lib/buffer.ts から始めてください。ここでは codepoint === 0 のセルに対して getChars() が空文字列を返しています。そのうえに構築されている 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
スター
2.9k
フォーク
182
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

coder/ghostty-web のほかの issue

coder/ghostty-web の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。