From 3be588569d21d9c2561e5adde722bd4ed3173395 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 29 Jul 2024 21:19:43 +0200 Subject: [PATCH] Disable CSI u inside Midnight Commander for now Using SHELL=$(command -v fish) mc Midnight Commander will spawn a fish child with "function fish_prompt;" "echo \"$PWD\">&%d; fish_prompt_mc; kill -STOP %%self; end\n", So fish_prompt will SIGSTOP itself using an uncatchable signal. On ctrl-o, mc will send SIGCONT to give back control to the shell. Another ctrl-o will be intercepted by mc to put the shell back to sleep. Since mc wants to intercept at least ctrl-o -- also while fish is in control -- we can't use the CSI u encoding until mc either understands that, or uses a different way of passing control between mc and fish. Let's disable it for now. Note that mc still uses %self but we've added a feature flag to disable that. So if you use "set fish_features all" you'll want to add a " no-remove-percent-self". A patch to make mc use $fish_pid has been submitted upstream at https://lists.midnight-commander.org/pipermail/mc-devel/2024-July/011226.html. Closes #10640 --- src/input_common.rs | 4 ++++ src/reader.rs | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/input_common.rs b/src/input_common.rs index 59753c246..81f697279 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -434,8 +434,12 @@ static TERMINAL_PROTOCOLS: MainThread>> = MainThread::new(RefCell::new(None)); pub(crate) static IS_TMUX: RelaxedAtomicBool = RelaxedAtomicBool::new(false); +pub(crate) static IN_MIDNIGHT_COMMANDER: RelaxedAtomicBool = RelaxedAtomicBool::new(false); pub fn terminal_protocols_enable_ifn() { + if IN_MIDNIGHT_COMMANDER.load() { + return; + } let mut term_protocols = TERMINAL_PROTOCOLS.get().borrow_mut(); if term_protocols.is_some() { return; diff --git a/src/reader.rs b/src/reader.rs index 7b7ba932e..36c87bfbb 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -70,6 +70,7 @@ use crate::history::{ SearchType, }; use crate::input::init_input; +use crate::input_common::IN_MIDNIGHT_COMMANDER; use crate::input_common::{ terminal_protocols_disable_ifn, terminal_protocols_enable_ifn, CharEvent, CharInputStyle, InputData, ReadlineCmd, IS_TMUX, @@ -3847,6 +3848,7 @@ fn reader_interactive_init(parser: &Parser) { .set_one(L!("_"), EnvMode::GLOBAL, L!("fish").to_owned()); IS_TMUX.store(parser.vars().get_unless_empty(L!("TMUX")).is_some()); + IN_MIDNIGHT_COMMANDER.store(parser.vars().get_unless_empty(L!("MC_TMPDIR")).is_some()); } /// Destroy data for interactive use.