Skip to content

Commit

Permalink
fix: allow-passthrough must be set to on to prevent tmux from f…
Browse files Browse the repository at this point in the history
…orwarding the real terminal's response to the inactive pane (#2052)
  • Loading branch information
sxyazi authored Dec 16, 2024
1 parent 6e1948e commit f4eef99
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
20 changes: 12 additions & 8 deletions yazi-adapter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ pub static WSL: RoCell<bool> = RoCell::new();
pub static NVIM: RoCell<bool> = RoCell::new();

pub fn init() -> anyhow::Result<()> {
init_default();

EMULATOR.init(Emulator::detect());
yazi_config::init_flavor(EMULATOR.light)?;

ADAPTOR.init(Adapter::matches(*EMULATOR));
ADAPTOR.start();

Ok(())
}

pub fn init_default() {
// Tmux support
TMUX.init(Mux::tmux_passthrough());
ESCAPE.init(if *TMUX == 2 { "\x1b\x1b" } else { "\x1b" });
Expand All @@ -36,12 +48,4 @@ pub fn init() -> anyhow::Result<()> {

// Neovim support
NVIM.init(env_exists("NVIM_LOG_FILE") && env_exists("NVIM"));

EMULATOR.init(Emulator::detect());
yazi_config::init_flavor(EMULATOR.light)?;

ADAPTOR.init(Adapter::matches(*EMULATOR));
ADAPTOR.start();

Ok(())
}
6 changes: 3 additions & 3 deletions yazi-adapter/src/mux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Mux {
}

let child = std::process::Command::new("tmux")
.args(["set", "-p", "allow-passthrough", "all"])
.args(["set", "-p", "allow-passthrough", "on"])
.stdin(std::process::Stdio::null())
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::piped())
Expand All @@ -35,13 +35,13 @@ impl Mux {
Ok(output) if output.status.success() => return 2,
Ok(output) => {
error!(
"Running `tmux set -p allow-passthrough all` failed: {:?}, {}",
"Running `tmux set -p allow-passthrough on` failed: {:?}, {}",
output.status,
String::from_utf8_lossy(&output.stderr)
);
}
Err(err) => {
error!("Failed to spawn `tmux set -p allow-passthrough all`: {err}");
error!("Failed to spawn `tmux set -p allow-passthrough on`: {err}");
}
}
1
Expand Down
6 changes: 5 additions & 1 deletion yazi-fm/src/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ impl Term {
};

enable_raw_mode()?;
if *yazi_adapter::TMUX != 0 {
yazi_adapter::Mux::tmux_passthrough();
}

execute!(
BufWriter::new(stderr()),
EnterAlternateScreen,
Print(Mux::csi("\x1bP$q q\x1b\\")), // Request cursor shape (DECRQM)
Print(Mux::csi("\x1b[?12$p")), // Request cursor blink status (DECSET)
Print("\x1b[?u"), // Request keyboard enhancement flags (CSI u)
Print(Mux::csi("\x1b[0c")), // Request device attributes
EnterAlternateScreen,
EnableBracketedPaste,
mouse::SetMouse(true),
)?;
Expand Down

0 comments on commit f4eef99

Please sign in to comment.