aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2024-11-11 16:30:03 +0100
committerGitHub <noreply@github.com>2024-11-11 16:30:03 +0100
commit942b435a67eac8c9c1766cd44bf95374e73ce634 (patch)
treec28d3fd025d50a6d123ca28144feec1741ccff55
parentdocs(changelog): output-buffer fix (diff)
downloadsl0ppij-942b435a67eac8c9c1766cd44bf95374e73ce634.tar.gz
sl0ppij-942b435a67eac8c9c1766cd44bf95374e73ce634.tar.xz
sl0ppij-942b435a67eac8c9c1766cd44bf95374e73ce634.zip
fix(tabs): maintain event order for MoveTab (#3758)
* fix(tabs): maintain event order for MoveTab * style(fmt): rustfmt
-rw-r--r--zellij-server/src/pty.rs25
-rw-r--r--zellij-server/src/screen.rs55
2 files changed, 21 insertions, 59 deletions
diff --git a/zellij-server/src/pty.rs b/zellij-server/src/pty.rs
index da5bd7bd..dc9e5809 100644
--- a/zellij-server/src/pty.rs
+++ b/zellij-server/src/pty.rs
@@ -262,7 +262,6 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<Layout>) -> Result<()> {
pty.bus.senders.clone(),
*terminal_id,
run_command.clone(),
- None,
)
.with_context(err_context)?;
}
@@ -342,7 +341,6 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<Layout>) -> Result<()> {
pty.bus.senders.clone(),
*terminal_id,
run_command.clone(),
- None,
)
.with_context(err_context)?;
}
@@ -445,8 +443,6 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<Layout>) -> Result<()> {
PaneId::Terminal(*terminal_id),
Some(2), // exit status
run_command,
- None,
- None,
))
.with_context(err_context)?;
}
@@ -516,8 +512,6 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<Layout>) -> Result<()> {
PaneId::Terminal(*terminal_id),
Some(2), // exit status
run_command,
- None,
- None,
))
.with_context(err_context)?;
}
@@ -614,8 +608,6 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<Layout>) -> Result<()> {
PaneId::Terminal(*terminal_id),
Some(2), // exit status
run_command,
- None,
- None,
))
.with_context(err_context)?;
}
@@ -667,8 +659,6 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<Layout>) -> Result<()> {
PaneId::Terminal(*terminal_id),
Some(2), // exit status
run_command,
- None,
- None,
))
.with_context(err_context)?;
}
@@ -985,8 +975,6 @@ impl Pty {
pane_id,
exit_status,
command,
- None,
- None,
));
} else {
let _ = senders.send_to_screen(ScreenInstruction::ClosePane(pane_id, None));
@@ -1059,14 +1047,14 @@ impl Pty {
// new_pane_pids
for run_instruction in extracted_run_instructions {
if let Some(new_pane_data) =
- self.apply_run_instruction(run_instruction, default_shell.clone(), tab_index)?
+ self.apply_run_instruction(run_instruction, default_shell.clone())?
{
new_pane_pids.push(new_pane_data);
}
}
for run_instruction in extracted_floating_run_instructions {
if let Some(new_pane_data) =
- self.apply_run_instruction(run_instruction, default_shell.clone(), tab_index)?
+ self.apply_run_instruction(run_instruction, default_shell.clone())?
{
new_floating_panes_pids.push(new_pane_data);
}
@@ -1147,7 +1135,6 @@ impl Pty {
self.bus.senders.clone(),
terminal_id,
run_command.clone(),
- Some(tab_index),
)
.with_context(err_context)?;
} else {
@@ -1168,7 +1155,6 @@ impl Pty {
&mut self,
run_instruction: Option<Run>,
default_shell: TerminalAction,
- tab_index: usize,
) -> Result<Option<(u32, bool, Option<RunCommand>, Result<i32>)>> {
// terminal_id,
// starts_held,
@@ -1193,8 +1179,6 @@ impl Pty {
pane_id,
exit_status,
command,
- Some(tab_index),
- None,
));
} else {
let _ =
@@ -1425,8 +1409,6 @@ impl Pty {
pane_id,
exit_status,
command,
- None,
- None,
));
} else {
let _ =
@@ -1598,7 +1580,6 @@ fn send_command_not_found_to_screen(
senders: ThreadSenders,
terminal_id: u32,
run_command: RunCommand,
- tab_index: Option<usize>,
) -> Result<()> {
let err_context = || format!("failed to send command_not_fount for terminal {terminal_id}");
senders
@@ -1614,8 +1595,6 @@ fn send_command_not_found_to_screen(
PaneId::Terminal(terminal_id),
Some(2),
run_command.clone(),
- tab_index,
- None,
))
.with_context(err_context)?;
Ok(())
diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs
index a1e1407e..174d712c 100644
--- a/zellij-server/src/screen.rs
+++ b/zellij-server/src/screen.rs
@@ -202,13 +202,7 @@ pub enum ScreenInstruction {
TogglePaneFrames,
SetSelectable(PaneId, bool),
ClosePane(PaneId, Option<ClientId>),
- HoldPane(
- PaneId,
- Option<i32>,
- RunCommand,
- Option<usize>,
- Option<ClientId>,
- ), // Option<i32> is the exit status, Option<usize> is the tab_index
+ HoldPane(PaneId, Option<i32>, RunCommand),
UpdatePaneName(Vec<u8>, ClientId),
UndoRenamePane(ClientId),
NewTab(
@@ -3355,32 +3349,13 @@ pub(crate) fn screen_thread_main(
screen.unblock_input()?;
screen.log_and_report_session_state()?;
},
- ScreenInstruction::HoldPane(id, exit_status, run_command, tab_index, client_id) => {
+ ScreenInstruction::HoldPane(id, exit_status, run_command) => {
let is_first_run = false;
- match (client_id, tab_index) {
- (Some(client_id), _) => {
- active_tab!(screen, client_id, |tab: &mut Tab| tab.hold_pane(
- id,
- exit_status,
- is_first_run,
- run_command
- ));
- },
- (_, Some(tab_index)) => match screen.tabs.get_mut(&tab_index) {
- Some(tab) => tab.hold_pane(id, exit_status, is_first_run, run_command),
- None => log::warn!(
- "Tab with index {tab_index} not found. Cannot hold pane with id {:?}",
- id
- ),
- },
- _ => {
- for tab in screen.tabs.values_mut() {
- if tab.get_all_pane_ids().contains(&id) {
- tab.hold_pane(id, exit_status, is_first_run, run_command);
- break;
- }
- }
- },
+ for tab in screen.tabs.values_mut() {
+ if tab.get_all_pane_ids().contains(&id) {
+ tab.hold_pane(id, exit_status, is_first_run, run_command);
+ break;
+ }
}
screen.unblock_input()?;
screen.log_and_report_session_state()?;
@@ -3635,14 +3610,22 @@ pub(crate) fn screen_thread_main(
screen.render(None)?;
},
ScreenInstruction::MoveTabLeft(client_id) => {
- screen.move_active_tab_to_left(client_id)?;
+ if pending_tab_ids.is_empty() {
+ screen.move_active_tab_to_left(client_id)?;
+ screen.render(None)?;
+ } else {
+ pending_events_waiting_for_tab.push(ScreenInstruction::MoveTabLeft(client_id));
+ }
screen.unblock_input()?;
- screen.render(None)?;
},
ScreenInstruction::MoveTabRight(client_id) => {
- screen.move_active_tab_to_right(client_id)?;
+ if pending_tab_ids.is_empty() {
+ screen.move_active_tab_to_right(client_id)?;
+ screen.render(None)?;
+ } else {
+ pending_events_waiting_for_tab.push(ScreenInstruction::MoveTabRight(client_id));
+ }
screen.unblock_input()?;
- screen.render(None)?;
},
ScreenInstruction::TerminalResize(new_size) => {
screen.resize_to_screen(new_size)?;