Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow-passthrough must be set to on to prevent tmux from forwarding the real terminal's response to the inactive pane #2052

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading