You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
External editor (Ctrl+G): TUI is not hidden before launching editor, causing screen corruption and lost keystrokes #1092
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
Run cmd in any of the terminals above.
Type a prompt, press Ctrl+G to open the external editor (nvim).
Type text, idle ~5s, type more, idle ~5s, then ZZ.
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:
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.
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.
Activity