Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#205 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
75/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu từ lib/buffer.ts, nơi getChars() trả về chuỗi rỗng cho các ô có codepoint === 0, và từ phần triển khai translateToString được xây dựng trên hàm đó. Hãy dùng TerminalCore.getSelection() làm tham chiếu, vì hàm này đã thay ô trống bằng một khoảng trắng. Công việc được xem là hoàn thành khi bước tái hiện trong issue cho ra "a b" từ translateToString(true) và việc cắt bỏ khoảng trắng cuối dòng vẫn hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
2.9k
Fork
182
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của coder/ghostty-web

Tất cả issue của coder/ghostty-web

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.