mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-12 19:49:32 +02:00
Dont allow abort while waiting for query response
This commit is contained in:
@@ -131,6 +131,8 @@ func print_error(format string, args ...any) {
|
||||
fmt.Fprintf(os.Stderr, format, args...)
|
||||
fmt.Fprintln(os.Stderr)
|
||||
} else {
|
||||
lp.QueueWriteString("\r")
|
||||
lp.ClearToEndOfLine()
|
||||
lp.QueueWriteString(fmt.Sprintf(format, args...))
|
||||
lp.QueueWriteString("\r\n")
|
||||
}
|
||||
@@ -308,6 +310,21 @@ func on_wakeup() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func on_key_event(event *loop.KeyEvent) error {
|
||||
if event.MatchesPressOrRepeat("ctrl+c") {
|
||||
event.Handled = true
|
||||
if query_in_flight {
|
||||
print_error("Waiting for response from terminal, aborting now could lead to corruption")
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Aborted by user")
|
||||
}
|
||||
if event.MatchesPressOrRepeat("ctrl+z") {
|
||||
event.Handled = true
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main(cmd *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
opts = o
|
||||
err = parse_place()
|
||||
|
||||
Reference in New Issue
Block a user