diff options
author | Aram Drevekenin <aram@poor.dev> | 2023-08-30 09:58:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-30 09:58:48 +0200 |
commit | 2081a2e64fcd3c93489d4b4c22478faf784ef73f (patch) | |
tree | 201615241bc9be0b4f2cab1f460ef3c866ff4240 | |
parent | 90875b0c00498fef00fac673086bd30145b64ccd (diff) |
fix(reconnect): do not clear terminal state when entering alternate screen (#2750)
* debug
* refactor(reconnect): articular reconnection logic
-rw-r--r-- | src/commands.rs | 7 | ||||
-rw-r--r-- | zellij-client/src/lib.rs | 25 |
2 files changed, 23 insertions, 9 deletions
diff --git a/src/commands.rs b/src/commands.rs index 5ab188d69..96f49c315 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -340,6 +340,7 @@ pub(crate) fn start_client(opts: CliArgs) { let layout = layout.clone(); let mut config_options = config_options.clone(); let mut opts = opts.clone(); + let mut is_a_reconnect = false; if let Some(reconnect_to_session) = &reconnect_to_session { // this is integration code to make session reconnects work with this existing, @@ -358,6 +359,7 @@ pub(crate) fn start_client(opts: CliArgs) { opts.session = None; config_options.attach_to_session = None; } + is_a_reconnect = true; } let start_client_plan = |session_name: std::string::String| { @@ -417,6 +419,7 @@ pub(crate) fn start_client(opts: CliArgs) { attach_layout, tab_position_to_focus, pane_id_to_focus, + is_a_reconnect, ); } else { if let Some(session_name) = opts.session.clone() { @@ -430,6 +433,7 @@ pub(crate) fn start_client(opts: CliArgs) { Some(layout), None, None, + is_a_reconnect, ); } else { if let Some(session_name) = config_options.session_name.as_ref() { @@ -466,6 +470,7 @@ pub(crate) fn start_client(opts: CliArgs) { attach_layout, None, None, + is_a_reconnect, ); }, _ => { @@ -479,6 +484,7 @@ pub(crate) fn start_client(opts: CliArgs) { Some(layout), None, None, + is_a_reconnect, ); }, } @@ -501,6 +507,7 @@ pub(crate) fn start_client(opts: CliArgs) { Some(layout), None, None, + is_a_reconnect, ); } } diff --git a/zellij-client/src/lib.rs b/zellij-client/src/lib.rs index 8dbae4f0a..bbfc6a15f 100644 --- a/zellij-client/src/lib.rs +++ b/zellij-client/src/lib.rs @@ -147,6 +147,7 @@ pub fn start_client( layout: Option<Layout>, tab_position_to_focus: Option<usize>, pane_id_to_focus: Option<(u32, bool)>, // (pane_id, is_plugin) + is_a_reconnect: bool, ) -> Option<ConnectToSession> { info!("Starting Zellij client!"); @@ -156,14 +157,19 @@ pub fn start_client( let bracketed_paste = "\u{1b}[?2004h"; os_input.unset_raw_mode(0).unwrap(); - let _ = os_input - .get_stdout_writer() - .write(take_snapshot.as_bytes()) - .unwrap(); - let _ = os_input - .get_stdout_writer() - .write(clear_client_terminal_attributes.as_bytes()) - .unwrap(); + if !is_a_reconnect { + // we don't do this for a reconnect because our controlling terminal already has the + // attributes we want from it, and some terminals don't treat these atomically (looking at + // your Windows Terminal...) + let _ = os_input + .get_stdout_writer() + .write(take_snapshot.as_bytes()) + .unwrap(); + let _ = os_input + .get_stdout_writer() + .write(clear_client_terminal_attributes.as_bytes()) + .unwrap(); + } envs::set_zellij("0".to_string()); config.env.set_vars(); @@ -172,6 +178,7 @@ pub fn start_client( .unwrap_or_else(|| os_input.load_palette()); let full_screen_ws = os_input.get_terminal_size_using_fd(0); + log::info!("full_screen_ws: {:?}", full_screen_ws); let client_attributes = ClientAttributes { size: full_screen_ws, style: Style { @@ -375,7 +382,7 @@ pub fn start_client( let mut stdout = os_input.get_stdout_writer(); stdout - .write_all("\u{1b}[1mLoading Zellij\u{1b}[m\n\r".as_bytes()) + .write_all("\u{1b}[1m\u{1b}[HLoading Zellij\u{1b}[m\n\r".as_bytes()) .expect("cannot write to stdout"); stdout.flush().expect("could not flush"); |