aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-server/src/screen.rs
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2024-10-08 16:57:54 +0200
committerGitHub <noreply@github.com>2024-10-08 16:57:54 +0200
commit203fbf7a491d1abc3cd9e05c1e39858af8395032 (patch)
tree94c48ef5063b4b40d8ba5741320b8edd4c143955 /zellij-server/src/screen.rs
parentdocs(changelog): http fix (diff)
downloadsl0ppij-203fbf7a491d1abc3cd9e05c1e39858af8395032.tar.gz
sl0ppij-203fbf7a491d1abc3cd9e05c1e39858af8395032.tar.xz
sl0ppij-203fbf7a491d1abc3cd9e05c1e39858af8395032.zip
feat(cli): make --layout idempotent(-ish) (#3650)
* feat(cli): if inside a session, apply --layout to the session * fix(screen): some focusing races when switching tab focus * style(fmt): rustfmt
Diffstat (limited to 'zellij-server/src/screen.rs')
-rw-r--r--zellij-server/src/screen.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs
index a4482807..832dfcdb 100644
--- a/zellij-server/src/screen.rs
+++ b/zellij-server/src/screen.rs
@@ -218,6 +218,7 @@ pub enum ScreenInstruction {
Vec<FloatingPaneLayout>,
Option<String>,
(Vec<SwapTiledLayout>, Vec<SwapFloatingLayout>), // swap layouts
+ bool, // should_change_focus_to_new_tab
ClientId,
),
ApplyLayout(
@@ -3420,12 +3421,22 @@ pub(crate) fn screen_thread_main(
floating_panes_layout,
tab_name,
swap_layouts,
+ should_change_focus_to_new_tab,
client_id,
) => {
let tab_index = screen.get_new_tab_index();
- let should_change_focus_to_new_tab = true;
pending_tab_ids.insert(tab_index);
- screen.new_tab(tab_index, swap_layouts, tab_name.clone(), Some(client_id))?;
+ let client_id_for_new_tab = if should_change_focus_to_new_tab {
+ Some(client_id)
+ } else {
+ None
+ };
+ screen.new_tab(
+ tab_index,
+ swap_layouts,
+ tab_name.clone(),
+ client_id_for_new_tab,
+ )?;
screen
.bus
.senders
@@ -3464,6 +3475,19 @@ pub(crate) fn screen_thread_main(
for (tab_index, client_id) in pending_tab_switches.drain() {
screen.go_to_tab(tab_index as usize, client_id)?;
}
+ if should_change_focus_to_new_tab {
+ screen.go_to_tab(tab_index as usize + 1, client_id)?;
+ }
+ } else if should_change_focus_to_new_tab {
+ let client_id_to_switch = if screen.active_tab_indices.contains_key(&client_id)
+ {
+ Some(client_id)
+ } else {
+ screen.active_tab_indices.keys().next().copied()
+ };
+ if let Some(client_id_to_switch) = client_id_to_switch {
+ pending_tab_switches.insert((tab_index as usize, client_id_to_switch));
+ }
}
for plugin_ids in new_plugin_ids.values() {