@@ -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 ) ;
@@ -1056,6 +1060,19 @@ impl Application {
1056
1060
if self . config . load ( ) . editor . mouse {
1057
1061
execute ! ( stdout, EnableMouseCapture ) ?;
1058
1062
}
1063
+ if matches ! ( terminal:: supports_keyboard_enhancement( ) , Ok ( true ) ) {
1064
+ log:: debug!( "The enhanced keyboard protocol is supported on this terminal" ) ;
1065
+ execute ! (
1066
+ stdout,
1067
+ PushKeyboardEnhancementFlags (
1068
+ KeyboardEnhancementFlags :: DISAMBIGUATE_ESCAPE_CODES
1069
+ | KeyboardEnhancementFlags :: REPORT_ALTERNATE_KEYS
1070
+ )
1071
+ ) ?;
1072
+ } else {
1073
+ log:: debug!( "The enhanced keyboard protocol is not supported on this terminal" ) ;
1074
+ }
1075
+
1059
1076
Ok ( ( ) )
1060
1077
}
1061
1078
0 commit comments