on master help sign in
tui: Log keyboard enhancement query time
563ac1aMichael Davis
helix-tui/src/backend/crossterm.rs+12−4
@@ -76,7 +76,18 @@ where
76 #[inline]
76 #[inline]
77 fn supports_keyboard_enhancement_protocol(&self) -> io::Result<bool> {
77 fn supports_keyboard_enhancement_protocol(&self) -> io::Result<bool> {
78 self.supports_keyboard_enhancement_protocol
78 self.supports_keyboard_enhancement_protocol
79+ .get_or_try_init(|| {
80+ use std::time::Instant;
81+
82+ let now = Instant::now();
79− .get_or_try_init(terminal::supports_keyboard_enhancement)
83+ let support = terminal::supports_keyboard_enhancement();
84+ log::debug!(
85+ "The keyboard enhancement protocol is {}supported in this terminal (checked in {:?})",
86+ if matches!(support, Ok(true)) { "" } else { "not " },
87+ Instant::now().duration_since(now)
88+ );
89+ support
90+ })
80 .copied()
91 .copied()
81 }
92 }
82}
93}
@@ -111,7 +122,6 @@ where
111 execute!(self.buffer, EnableMouseCapture)?;
122 execute!(self.buffer, EnableMouseCapture)?;
112 }
123 }
113 if self.supports_keyboard_enhancement_protocol()? {
124 if self.supports_keyboard_enhancement_protocol()? {
114− log::debug!("The enhanced keyboard protocol is supported on this terminal");
115 execute!(
125 execute!(
116 self.buffer,
126 self.buffer,
117 PushKeyboardEnhancementFlags(
127 PushKeyboardEnhancementFlags(
@@ -119,8 +129,6 @@ where
119 | KeyboardEnhancementFlags::REPORT_ALTERNATE_KEYS
129 | KeyboardEnhancementFlags::REPORT_ALTERNATE_KEYS
120 )
130 )
121 )?;
131 )?;
122− } else {
123− log::debug!("The enhanced keyboard protocol is not supported on this terminal");
124 }
132 }
125 Ok(())
133 Ok(())
126 }
134 }