fix(layouts): naming and gototabname (#2225)
* fix(layouts): properly apply tab name * fix(gototabname): do not crash and properly apply default shell * style(fmt): rustfmt
This commit is contained in:
parent
c6c9bb5c37
commit
57e8ca0fae
10 changed files with 23 additions and 45 deletions
|
|
@ -30,8 +30,7 @@ pub enum PluginInstruction {
|
||||||
Option<TerminalAction>,
|
Option<TerminalAction>,
|
||||||
Option<TiledPaneLayout>,
|
Option<TiledPaneLayout>,
|
||||||
Vec<FloatingPaneLayout>,
|
Vec<FloatingPaneLayout>,
|
||||||
Option<String>, // tab name
|
usize, // tab_index
|
||||||
usize, // tab_index
|
|
||||||
ClientId,
|
ClientId,
|
||||||
),
|
),
|
||||||
Exit,
|
Exit,
|
||||||
|
|
@ -92,7 +91,6 @@ pub(crate) fn plugin_thread_main(
|
||||||
terminal_action,
|
terminal_action,
|
||||||
tab_layout,
|
tab_layout,
|
||||||
floating_panes_layout,
|
floating_panes_layout,
|
||||||
tab_name,
|
|
||||||
tab_index,
|
tab_index,
|
||||||
client_id,
|
client_id,
|
||||||
) => {
|
) => {
|
||||||
|
|
@ -123,7 +121,6 @@ pub(crate) fn plugin_thread_main(
|
||||||
terminal_action,
|
terminal_action,
|
||||||
tab_layout,
|
tab_layout,
|
||||||
floating_panes_layout,
|
floating_panes_layout,
|
||||||
tab_name,
|
|
||||||
tab_index,
|
tab_index,
|
||||||
plugin_ids,
|
plugin_ids,
|
||||||
client_id,
|
client_id,
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,6 @@ pub enum PtyInstruction {
|
||||||
Option<TerminalAction>,
|
Option<TerminalAction>,
|
||||||
Option<TiledPaneLayout>,
|
Option<TiledPaneLayout>,
|
||||||
Vec<FloatingPaneLayout>,
|
Vec<FloatingPaneLayout>,
|
||||||
Option<String>,
|
|
||||||
usize, // tab_index
|
usize, // tab_index
|
||||||
HashMap<RunPluginLocation, Vec<u32>>, // plugin_ids
|
HashMap<RunPluginLocation, Vec<u32>>, // plugin_ids
|
||||||
ClientId,
|
ClientId,
|
||||||
|
|
@ -340,7 +339,6 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<Layout>) -> Result<()> {
|
||||||
terminal_action,
|
terminal_action,
|
||||||
tab_layout,
|
tab_layout,
|
||||||
floating_panes_layout,
|
floating_panes_layout,
|
||||||
tab_name,
|
|
||||||
tab_index,
|
tab_index,
|
||||||
plugin_ids,
|
plugin_ids,
|
||||||
client_id,
|
client_id,
|
||||||
|
|
@ -361,21 +359,6 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<Layout>) -> Result<()> {
|
||||||
client_id,
|
client_id,
|
||||||
)
|
)
|
||||||
.with_context(err_context)?;
|
.with_context(err_context)?;
|
||||||
|
|
||||||
if let Some(tab_name) = tab_name {
|
|
||||||
// clear current name at first
|
|
||||||
pty.bus
|
|
||||||
.senders
|
|
||||||
.send_to_screen(ScreenInstruction::UpdateTabName(vec![0], client_id))
|
|
||||||
.with_context(err_context)?;
|
|
||||||
pty.bus
|
|
||||||
.senders
|
|
||||||
.send_to_screen(ScreenInstruction::UpdateTabName(
|
|
||||||
tab_name.into_bytes(),
|
|
||||||
client_id,
|
|
||||||
))
|
|
||||||
.with_context(err_context)?;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
PtyInstruction::ClosePane(id) => {
|
PtyInstruction::ClosePane(id) => {
|
||||||
pty.close_pane(id)
|
pty.close_pane(id)
|
||||||
|
|
|
||||||
|
|
@ -498,6 +498,7 @@ pub(crate) fn route_action(
|
||||||
.with_context(err_context)?;
|
.with_context(err_context)?;
|
||||||
},
|
},
|
||||||
Action::GoToTabName(name, create) => {
|
Action::GoToTabName(name, create) => {
|
||||||
|
let shell = session.default_shell.clone();
|
||||||
let swap_tiled_layouts = session.layout.swap_tiled_layouts.clone();
|
let swap_tiled_layouts = session.layout.swap_tiled_layouts.clone();
|
||||||
let swap_floating_layouts = session.layout.swap_floating_layouts.clone();
|
let swap_floating_layouts = session.layout.swap_floating_layouts.clone();
|
||||||
session
|
session
|
||||||
|
|
@ -505,6 +506,7 @@ pub(crate) fn route_action(
|
||||||
.send_to_screen(ScreenInstruction::GoToTabName(
|
.send_to_screen(ScreenInstruction::GoToTabName(
|
||||||
name,
|
name,
|
||||||
(swap_tiled_layouts, swap_floating_layouts),
|
(swap_tiled_layouts, swap_floating_layouts),
|
||||||
|
shell,
|
||||||
create,
|
create,
|
||||||
Some(client_id),
|
Some(client_id),
|
||||||
))
|
))
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,7 @@ pub enum ScreenInstruction {
|
||||||
GoToTabName(
|
GoToTabName(
|
||||||
String,
|
String,
|
||||||
(Vec<SwapTiledLayout>, Vec<SwapFloatingLayout>), // swap layouts
|
(Vec<SwapTiledLayout>, Vec<SwapFloatingLayout>), // swap layouts
|
||||||
|
Option<TerminalAction>, // default_shell
|
||||||
bool,
|
bool,
|
||||||
Option<ClientId>,
|
Option<ClientId>,
|
||||||
),
|
),
|
||||||
|
|
@ -932,6 +933,7 @@ impl Screen {
|
||||||
&mut self,
|
&mut self,
|
||||||
tab_index: usize,
|
tab_index: usize,
|
||||||
swap_layouts: (Vec<SwapTiledLayout>, Vec<SwapFloatingLayout>),
|
swap_layouts: (Vec<SwapTiledLayout>, Vec<SwapFloatingLayout>),
|
||||||
|
tab_name: Option<String>,
|
||||||
client_id: ClientId,
|
client_id: ClientId,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let err_context = || format!("failed to create new tab for client {client_id:?}",);
|
let err_context = || format!("failed to create new tab for client {client_id:?}",);
|
||||||
|
|
@ -944,11 +946,13 @@ impl Screen {
|
||||||
client_id
|
client_id
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let tab_name = tab_name.unwrap_or_else(|| String::new());
|
||||||
|
|
||||||
let position = self.tabs.len();
|
let position = self.tabs.len();
|
||||||
let tab = Tab::new(
|
let tab = Tab::new(
|
||||||
tab_index,
|
tab_index,
|
||||||
position,
|
position,
|
||||||
String::new(),
|
tab_name,
|
||||||
self.size,
|
self.size,
|
||||||
self.character_cell_size.clone(),
|
self.character_cell_size.clone(),
|
||||||
self.sixel_image_store.clone(),
|
self.sixel_image_store.clone(),
|
||||||
|
|
@ -2018,7 +2022,7 @@ pub(crate) fn screen_thread_main(
|
||||||
) => {
|
) => {
|
||||||
let tab_index = screen.get_new_tab_index();
|
let tab_index = screen.get_new_tab_index();
|
||||||
pending_tab_ids.insert(tab_index);
|
pending_tab_ids.insert(tab_index);
|
||||||
screen.new_tab(tab_index, swap_layouts, client_id)?;
|
screen.new_tab(tab_index, swap_layouts, tab_name.clone(), client_id)?;
|
||||||
screen
|
screen
|
||||||
.bus
|
.bus
|
||||||
.senders
|
.senders
|
||||||
|
|
@ -2026,7 +2030,6 @@ pub(crate) fn screen_thread_main(
|
||||||
default_shell,
|
default_shell,
|
||||||
layout,
|
layout,
|
||||||
floating_panes_layout,
|
floating_panes_layout,
|
||||||
tab_name,
|
|
||||||
tab_index,
|
tab_index,
|
||||||
client_id,
|
client_id,
|
||||||
))?;
|
))?;
|
||||||
|
|
@ -2082,7 +2085,13 @@ pub(crate) fn screen_thread_main(
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ScreenInstruction::GoToTabName(tab_name, swap_layouts, create, client_id) => {
|
ScreenInstruction::GoToTabName(
|
||||||
|
tab_name,
|
||||||
|
swap_layouts,
|
||||||
|
default_shell,
|
||||||
|
create,
|
||||||
|
client_id,
|
||||||
|
) => {
|
||||||
let client_id = if client_id.is_none() {
|
let client_id = if client_id.is_none() {
|
||||||
None
|
None
|
||||||
} else if screen
|
} else if screen
|
||||||
|
|
@ -2099,15 +2108,14 @@ pub(crate) fn screen_thread_main(
|
||||||
screen.render()?;
|
screen.render()?;
|
||||||
if create && !tab_exists {
|
if create && !tab_exists {
|
||||||
let tab_index = screen.get_new_tab_index();
|
let tab_index = screen.get_new_tab_index();
|
||||||
screen.new_tab(tab_index, swap_layouts, client_id)?;
|
screen.new_tab(tab_index, swap_layouts, Some(tab_name), client_id)?;
|
||||||
screen
|
screen
|
||||||
.bus
|
.bus
|
||||||
.senders
|
.senders
|
||||||
.send_to_plugin(PluginInstruction::NewTab(
|
.send_to_plugin(PluginInstruction::NewTab(
|
||||||
None,
|
default_shell,
|
||||||
None,
|
None,
|
||||||
vec![],
|
vec![],
|
||||||
Some(tab_name),
|
|
||||||
tab_index,
|
tab_index,
|
||||||
client_id,
|
client_id,
|
||||||
))?;
|
))?;
|
||||||
|
|
|
||||||
|
|
@ -671,8 +671,6 @@ impl Tab {
|
||||||
client_id,
|
client_id,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
self.is_pending = false;
|
|
||||||
self.apply_buffered_instructions()?;
|
|
||||||
self.set_force_render();
|
self.set_force_render();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -726,8 +724,6 @@ impl Tab {
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
self.tiled_panes.reapply_pane_frames();
|
self.tiled_panes.reapply_pane_frames();
|
||||||
self.is_pending = false;
|
|
||||||
self.apply_buffered_instructions()?;
|
|
||||||
let display_area = *self.display_area.borrow();
|
let display_area = *self.display_area.borrow();
|
||||||
// we do this so that the new swap layout has a chance to pass through the constraint system
|
// we do this so that the new swap layout has a chance to pass through the constraint system
|
||||||
self.tiled_panes.resize(display_area);
|
self.tiled_panes.resize(display_area);
|
||||||
|
|
|
||||||
|
|
@ -485,7 +485,7 @@ fn new_tab(screen: &mut Screen, pid: u32, tab_index: usize) {
|
||||||
let new_terminal_ids = vec![(pid, None)];
|
let new_terminal_ids = vec![(pid, None)];
|
||||||
let new_plugin_ids = HashMap::new();
|
let new_plugin_ids = HashMap::new();
|
||||||
screen
|
screen
|
||||||
.new_tab(tab_index, (vec![], vec![]), client_id)
|
.new_tab(tab_index, (vec![], vec![]), None, client_id)
|
||||||
.expect("TEST");
|
.expect("TEST");
|
||||||
screen
|
screen
|
||||||
.apply_layout(
|
.apply_layout(
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/./unit/screen_tests.rs
|
source: zellij-server/src/./unit/screen_tests.rs
|
||||||
assertion_line: 2304
|
assertion_line: 2394
|
||||||
expression: "format!(\"{:#?}\", new_tab_action)"
|
expression: "format!(\"{:#?}\", new_tab_action)"
|
||||||
---
|
---
|
||||||
Some(
|
Some(
|
||||||
|
|
@ -43,7 +43,6 @@ Some(
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
[],
|
[],
|
||||||
None,
|
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/./unit/screen_tests.rs
|
source: zellij-server/src/./unit/screen_tests.rs
|
||||||
assertion_line: 2354
|
assertion_line: 2445
|
||||||
expression: "format!(\"{:#?}\", new_tab_instruction)"
|
expression: "format!(\"{:#?}\", new_tab_instruction)"
|
||||||
---
|
---
|
||||||
NewTab(
|
NewTab(
|
||||||
|
|
@ -65,9 +65,6 @@ NewTab(
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
[],
|
[],
|
||||||
Some(
|
|
||||||
"my-awesome-tab-name",
|
|
||||||
),
|
|
||||||
1,
|
1,
|
||||||
10,
|
10,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/./unit/screen_tests.rs
|
source: zellij-server/src/./unit/screen_tests.rs
|
||||||
assertion_line: 2538
|
assertion_line: 2629
|
||||||
expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||||
---
|
---
|
||||||
[
|
[
|
||||||
|
|
@ -65,7 +65,6 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
[],
|
[],
|
||||||
None,
|
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
|
|
@ -219,7 +218,6 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
[],
|
[],
|
||||||
None,
|
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/./unit/screen_tests.rs
|
source: zellij-server/src/./unit/screen_tests.rs
|
||||||
assertion_line: 2581
|
assertion_line: 2672
|
||||||
expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||||
---
|
---
|
||||||
[
|
[
|
||||||
|
|
@ -65,7 +65,6 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
[],
|
[],
|
||||||
None,
|
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
|
|
@ -219,7 +218,6 @@ expression: "format!(\"{:#?}\", * received_plugin_instructions.lock().unwrap())"
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
[],
|
[],
|
||||||
None,
|
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue