@@ -40,7 +40,8 @@ use anyhow::{Context, Error};
40
40
use crossterm:: {
41
41
event:: {
42
42
DisableBracketedPaste , DisableFocusChange , DisableMouseCapture , EnableBracketedPaste ,
43
- EnableFocusChange , EnableMouseCapture , Event as CrosstermEvent ,
43
+ EnableFocusChange , EnableMouseCapture , Event as CrosstermEvent , KeyboardEnhancementFlags ,
44
+ PopKeyboardEnhancementFlags , PushKeyboardEnhancementFlags ,
44
45
} ,
45
46
execute, terminal,
46
47
tty:: IsTty ,
@@ -111,6 +112,9 @@ fn restore_term() -> Result<(), Error> {
111
112
let mut stdout = stdout ( ) ;
112
113
// reset cursor shape
113
114
write ! ( stdout, "\x1B [0 q" ) ?;
115
+ if matches ! ( terminal:: supports_keyboard_enhancement( ) , Ok ( true ) ) {
116
+ execute ! ( stdout, PopKeyboardEnhancementFlags ) ?;
117
+ }
114
118
// Ignore errors on disabling, this might trigger on windows if we call
115
119
// disable without calling enable previously
116
120
let _ = execute ! ( stdout, DisableMouseCapture ) ;
@@ -1013,6 +1017,14 @@ impl Application {
1013
1017
if self . config . load ( ) . editor . mouse {
1014
1018
execute ! ( stdout, EnableMouseCapture ) ?;
1015
1019
}
1020
+ if matches ! ( terminal:: supports_keyboard_enhancement( ) , Ok ( true ) ) {
1021
+ log:: debug!( "Enabling DISAMBIGUATE_ESCAPE_CODES within crossterm" ) ;
1022
+ execute ! (
1023
+ stdout,
1024
+ PushKeyboardEnhancementFlags ( KeyboardEnhancementFlags :: DISAMBIGUATE_ESCAPE_CODES )
1025
+ ) ?;
1026
+ }
1027
+
1016
1028
Ok ( ( ) )
1017
1029
}
1018
1030
0 commit comments