Disable focus reporting on non-tmux again for now

We sometimes leak ^[[I and ^[[O focus reporting events when run from VSCode's
"Run python file" button in the top right corner. To reproduce I installed
the ms-python extension set the VSCode default shell to fish and repeatedly
ran a script that does "time.sleep(1)". I believe VSCode synthesizes keys
and triggers a race condition.

We can probably fix this but I'm not sure when I'll get to it (given how
relatively unimportant this feature is).

So let's go back to the old behavior of only enabling focus reporting in tmux.

I believe that tmux is affected by the same VSCode issue (also on 3.7.1 I
think) but I haven't been able to get tmux to emit focus reporting sequences
yet.  Still, keep it to not regress cursor shape (#4788).  So far this is
the only motivation for focus reporting and I believe it is only relevant
for terminals that can split windows (though there are a bunch that do).

Closes #10448
This commit is contained in:
Johannes Altmanninger
2024-04-18 10:21:28 +02:00
parent ed8f62e723
commit bdd478bbd0
5 changed files with 14 additions and 7 deletions

View File

@@ -7,6 +7,7 @@
use crate::env::{EnvStack, Environment};
use crate::fd_readable_set::FdReadableSet;
use crate::flog::FLOG;
use crate::global_safety::RelaxedAtomicBool;
use crate::input::KeyNameStyle;
use crate::key::{
self, alt, canonicalize_control_char, canonicalize_keyed_control_char, function_key, shift,
@@ -515,7 +516,12 @@ fn terminal_protocols_disable_impl() {
let _ = write_to_fd(sequences.as_bytes(), STDOUT_FILENO);
}
pub(crate) static IS_TMUX: RelaxedAtomicBool = RelaxedAtomicBool::new(false);
pub(crate) fn focus_events_enable_ifn() {
if !IS_TMUX.load() {
return;
}
let mut term_protocols = TERMINAL_PROTOCOLS.get().borrow_mut();
let Some(term_protocols) = term_protocols.as_mut() else {
panic!()