External editor (Ctrl+G): TUI is not hidden before launching editor, causing screen corruption and lost keystrokes

Đang mở
#1,092 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
66/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ệ
javascript, neovim
Lĩnh vực
cli

Hướng nghiên cứu

Start by locating openInEditor and openMemoryFileInEditor, then trace how withLegacyKeyboard wraps the editor spawn without stopping the TUI. Compare that path with the referenced pi pattern: this.tui.stop() before spawning, and this.tui.start() plus this.tui.requestRender(true) in a finally block. Reproduce with cmd, Ctrl+G, and nvim; done means the editor owns the terminal cleanly, keystrokes are not lost, the prompt is captured on return, and the TUI redraws fully.

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

Mô tả

Summary

When Command Code launches an external editor via Ctrl+G, it does not stop/hide its TUI first. The TUI's render loop (git-polling statusline, autocomplete/snippet UI) keeps writing to the terminal and reading stdin while the editor (e.g. nvim) is running. This causes screen corruption and intermittent keystroke loss (Escape, ZZ), so the prompt is sometimes not captured on return.

This is not specific to the kitty keyboard protocol — it reproduces in wezterm, ghostty, alacritty, and kitty.

Reproduction

  1. Run cmd in any of the terminals above.
  2. Type a prompt, press Ctrl+G to open the external editor (nvim).
  3. Type text, idle ~5s, type more, idle ~5s, then ZZ.
  4. Observe: typed text often does not appear in nvim; ZZ may not register; nvim can hang ("Save and close the editor to continue...").

Evidence (cmd vs pi, side-by-side)

Captured in tmux (same terminal, same nvim config). pi calls tui.stop() before spawning the editor and tui.start() after; cmd does not.

Tool nvim opened typing registered survived idle ZZ exited text captured
pi (reference) YES YES YES YES YES
cmd YES NO (buffer stayed empty) n/a NO (stuck) NO

Root cause

In openInEditor (and openMemoryFileInEditor), cmd wraps the spawn in withLegacyKeyboard, which only pops/pushes the kitty keyboard protocol. It never stops the TUI render loop or stdin handling. Contrast pi:

this.tui.stop();
try {
  let result = await editInExternalEditor({ command, content });
  ...
} finally {
  this.tui.start();
  this.tui.requestRender(true);
}

Because cmd's TUI keeps rendering and reading stdin, keystrokes are consumed and the screen is corrupted while nvim is active.

Suggested fix

Mirror pi: before spawning the external editor, stop the TUI (stop rendering + release stdin); after the editor exits, restart the TUI and request a full render. This is the same pattern opencode uses.

nvim-side mitigations already applied (insufficient)

  • Disabled folke/noice.nvim (fixed nvim freeze on exit after idle).
  • ttimeout = true, ttimeoutlen = 0 (helps Escape registration).

These address nvim-specific issues but cannot fix a parent TUI that keeps writing to the terminal / reading stdin. Screen corruption and text-capture loss remain until cmd hides its TUI.

Environment

  • Command Code v1.88.2
  • nvim 0.12.6
  • Reproduced in wezterm, ghostty, alacritty, kitty
Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
4.2k
Fork
377
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
6

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 CommandCodeAI/command-code

Tất cả issue của CommandCodeAI/command-code

Issue tương tự

Thêm issue về CLI

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.