fix(tabs): maintain event order for MoveTab (#3758)

* fix(tabs): maintain event order for MoveTab

* style(fmt): rustfmt
This commit is contained in:
Aram Drevekenin 2024-11-11 16:30:03 +01:00 committed by GitHub
parent c13fda444c
commit 942b435a67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 59 deletions

View file

@ -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(())

View file

@ -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,33 +3349,14 @@ 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;
}
}
},
}
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) => {
if pending_tab_ids.is_empty() {
screen.move_active_tab_to_left(client_id)?;
screen.unblock_input()?;
screen.render(None)?;
} else {
pending_events_waiting_for_tab.push(ScreenInstruction::MoveTabLeft(client_id));
}
screen.unblock_input()?;
},
ScreenInstruction::MoveTabRight(client_id) => {
if pending_tab_ids.is_empty() {
screen.move_active_tab_to_right(client_id)?;
screen.unblock_input()?;
screen.render(None)?;
} else {
pending_events_waiting_for_tab.push(ScreenInstruction::MoveTabRight(client_id));
}
screen.unblock_input()?;
},
ScreenInstruction::TerminalResize(new_size) => {
screen.resize_to_screen(new_size)?;