Further simplify terminal_protocols scoping

Remove the last non scoped place where we disable protocols (just before
exec(1)); it's not necessary with the current approach because we always
disable inside eval.
There is an edge case where we don't:

    fish -ic "exec bash"

leaving bash with CSI u enabled.  Disable that also in -ic mode where we
don't have a reader.

In future we should use the same approach for restore_term_mode() but I'm
not sure which one is better.
This commit is contained in:
Johannes Altmanninger
2024-04-21 16:19:39 +02:00
parent 99bf3d0dbb
commit fd61bad946
3 changed files with 12 additions and 14 deletions

View File

@@ -438,7 +438,7 @@ fn terminal_protocols_enable() {
.replace(Some(TerminalProtocols::new()));
}
pub fn terminal_protocols_disable() {
fn terminal_protocols_disable() {
assert!(TERMINAL_PROTOCOLS.get().borrow().is_some());
TERMINAL_PROTOCOLS.get().replace(None);
}
@@ -454,7 +454,9 @@ pub fn terminal_protocols_disable_scoped() -> impl ScopeGuarding<Target = ()> {
// If a child is stopped, this will already be enabled.
if TERMINAL_PROTOCOLS.get().borrow().is_none() {
terminal_protocols_enable();
reader_current_data().unwrap().save_screen_state();
if let Some(data) = reader_current_data() {
data.save_screen_state();
}
}
})
}
@@ -529,7 +531,9 @@ pub(crate) fn focus_events_enable_ifn() {
if !term_protocols.focus_events {
term_protocols.focus_events = true;
let _ = write_to_fd("\x1b[?1004h".as_bytes(), STDOUT_FILENO);
reader_current_data().unwrap().save_screen_state();
if let Some(data) = reader_current_data() {
data.save_screen_state();
}
}
}