Fix some responses from terminal sometimes leaking into shell on after kitten exit

Always do a roundtrip at kitten exit, except for special purpose
kittens. This slows down exit by one round trip time (capped at 2
seconds), however it ensures that we never get terminal response leak.

Fixes #9839
This commit is contained in:
Kovid Goyal
2026-04-10 15:14:38 +05:30
parent 4982173d3a
commit 5e158f90a7
12 changed files with 121 additions and 99 deletions

View File

@@ -26,10 +26,11 @@ func main(cmd *cli.Command, opts *Options, args []string) (rc int, err error) {
queries[i] = x
}
}
lp, err := loop.New(loop.NoAlternateScreen, loop.NoKeyboardStateChange, loop.NoMouseTracking, loop.NoRestoreColors, loop.NoInBandResizeNotifications)
lp, err := loop.New(loop.NoAlternateScreen, loop.NoKeyboardStateChange, loop.NoMouseTracking, loop.NoRestoreColors, loop.NoInBandResizeNotifications, loop.NoFocusTracking)
if err != nil {
return 1, err
}
lp.NoRoundtripToTerminalOnExit = true
timed_out := false
lp.OnInitialize = func() (string, error) {
lp.QueryTerminal(queries...)