fix(tabs): maintain event order for MoveTab (#3758)
* fix(tabs): maintain event order for MoveTab * style(fmt): rustfmt
This commit is contained in:
parent
c13fda444c
commit
942b435a67
2 changed files with 21 additions and 59 deletions
|
|
@ -262,7 +262,6 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<Layout>) -> Result<()> {
|
||||||
pty.bus.senders.clone(),
|
pty.bus.senders.clone(),
|
||||||
*terminal_id,
|
*terminal_id,
|
||||||
run_command.clone(),
|
run_command.clone(),
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.with_context(err_context)?;
|
.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(),
|
pty.bus.senders.clone(),
|
||||||
*terminal_id,
|
*terminal_id,
|
||||||
run_command.clone(),
|
run_command.clone(),
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.with_context(err_context)?;
|
.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),
|
PaneId::Terminal(*terminal_id),
|
||||||
Some(2), // exit status
|
Some(2), // exit status
|
||||||
run_command,
|
run_command,
|
||||||
None,
|
|
||||||
None,
|
|
||||||
))
|
))
|
||||||
.with_context(err_context)?;
|
.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),
|
PaneId::Terminal(*terminal_id),
|
||||||
Some(2), // exit status
|
Some(2), // exit status
|
||||||
run_command,
|
run_command,
|
||||||
None,
|
|
||||||
None,
|
|
||||||
))
|
))
|
||||||
.with_context(err_context)?;
|
.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),
|
PaneId::Terminal(*terminal_id),
|
||||||
Some(2), // exit status
|
Some(2), // exit status
|
||||||
run_command,
|
run_command,
|
||||||
None,
|
|
||||||
None,
|
|
||||||
))
|
))
|
||||||
.with_context(err_context)?;
|
.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),
|
PaneId::Terminal(*terminal_id),
|
||||||
Some(2), // exit status
|
Some(2), // exit status
|
||||||
run_command,
|
run_command,
|
||||||
None,
|
|
||||||
None,
|
|
||||||
))
|
))
|
||||||
.with_context(err_context)?;
|
.with_context(err_context)?;
|
||||||
}
|
}
|
||||||
|
|
@ -985,8 +975,6 @@ impl Pty {
|
||||||
pane_id,
|
pane_id,
|
||||||
exit_status,
|
exit_status,
|
||||||
command,
|
command,
|
||||||
None,
|
|
||||||
None,
|
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
let _ = senders.send_to_screen(ScreenInstruction::ClosePane(pane_id, None));
|
let _ = senders.send_to_screen(ScreenInstruction::ClosePane(pane_id, None));
|
||||||
|
|
@ -1059,14 +1047,14 @@ impl Pty {
|
||||||
// new_pane_pids
|
// new_pane_pids
|
||||||
for run_instruction in extracted_run_instructions {
|
for run_instruction in extracted_run_instructions {
|
||||||
if let Some(new_pane_data) =
|
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);
|
new_pane_pids.push(new_pane_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for run_instruction in extracted_floating_run_instructions {
|
for run_instruction in extracted_floating_run_instructions {
|
||||||
if let Some(new_pane_data) =
|
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);
|
new_floating_panes_pids.push(new_pane_data);
|
||||||
}
|
}
|
||||||
|
|
@ -1147,7 +1135,6 @@ impl Pty {
|
||||||
self.bus.senders.clone(),
|
self.bus.senders.clone(),
|
||||||
terminal_id,
|
terminal_id,
|
||||||
run_command.clone(),
|
run_command.clone(),
|
||||||
Some(tab_index),
|
|
||||||
)
|
)
|
||||||
.with_context(err_context)?;
|
.with_context(err_context)?;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1168,7 +1155,6 @@ impl Pty {
|
||||||
&mut self,
|
&mut self,
|
||||||
run_instruction: Option<Run>,
|
run_instruction: Option<Run>,
|
||||||
default_shell: TerminalAction,
|
default_shell: TerminalAction,
|
||||||
tab_index: usize,
|
|
||||||
) -> Result<Option<(u32, bool, Option<RunCommand>, Result<i32>)>> {
|
) -> Result<Option<(u32, bool, Option<RunCommand>, Result<i32>)>> {
|
||||||
// terminal_id,
|
// terminal_id,
|
||||||
// starts_held,
|
// starts_held,
|
||||||
|
|
@ -1193,8 +1179,6 @@ impl Pty {
|
||||||
pane_id,
|
pane_id,
|
||||||
exit_status,
|
exit_status,
|
||||||
command,
|
command,
|
||||||
Some(tab_index),
|
|
||||||
None,
|
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
let _ =
|
let _ =
|
||||||
|
|
@ -1425,8 +1409,6 @@ impl Pty {
|
||||||
pane_id,
|
pane_id,
|
||||||
exit_status,
|
exit_status,
|
||||||
command,
|
command,
|
||||||
None,
|
|
||||||
None,
|
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
let _ =
|
let _ =
|
||||||
|
|
@ -1598,7 +1580,6 @@ fn send_command_not_found_to_screen(
|
||||||
senders: ThreadSenders,
|
senders: ThreadSenders,
|
||||||
terminal_id: u32,
|
terminal_id: u32,
|
||||||
run_command: RunCommand,
|
run_command: RunCommand,
|
||||||
tab_index: Option<usize>,
|
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let err_context = || format!("failed to send command_not_fount for terminal {terminal_id}");
|
let err_context = || format!("failed to send command_not_fount for terminal {terminal_id}");
|
||||||
senders
|
senders
|
||||||
|
|
@ -1614,8 +1595,6 @@ fn send_command_not_found_to_screen(
|
||||||
PaneId::Terminal(terminal_id),
|
PaneId::Terminal(terminal_id),
|
||||||
Some(2),
|
Some(2),
|
||||||
run_command.clone(),
|
run_command.clone(),
|
||||||
tab_index,
|
|
||||||
None,
|
|
||||||
))
|
))
|
||||||
.with_context(err_context)?;
|
.with_context(err_context)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -202,13 +202,7 @@ pub enum ScreenInstruction {
|
||||||
TogglePaneFrames,
|
TogglePaneFrames,
|
||||||
SetSelectable(PaneId, bool),
|
SetSelectable(PaneId, bool),
|
||||||
ClosePane(PaneId, Option<ClientId>),
|
ClosePane(PaneId, Option<ClientId>),
|
||||||
HoldPane(
|
HoldPane(PaneId, Option<i32>, RunCommand),
|
||||||
PaneId,
|
|
||||||
Option<i32>,
|
|
||||||
RunCommand,
|
|
||||||
Option<usize>,
|
|
||||||
Option<ClientId>,
|
|
||||||
), // Option<i32> is the exit status, Option<usize> is the tab_index
|
|
||||||
UpdatePaneName(Vec<u8>, ClientId),
|
UpdatePaneName(Vec<u8>, ClientId),
|
||||||
UndoRenamePane(ClientId),
|
UndoRenamePane(ClientId),
|
||||||
NewTab(
|
NewTab(
|
||||||
|
|
@ -3355,32 +3349,13 @@ pub(crate) fn screen_thread_main(
|
||||||
screen.unblock_input()?;
|
screen.unblock_input()?;
|
||||||
screen.log_and_report_session_state()?;
|
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;
|
let is_first_run = false;
|
||||||
match (client_id, tab_index) {
|
for tab in screen.tabs.values_mut() {
|
||||||
(Some(client_id), _) => {
|
if tab.get_all_pane_ids().contains(&id) {
|
||||||
active_tab!(screen, client_id, |tab: &mut Tab| tab.hold_pane(
|
tab.hold_pane(id, exit_status, is_first_run, run_command);
|
||||||
id,
|
break;
|
||||||
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.unblock_input()?;
|
||||||
screen.log_and_report_session_state()?;
|
screen.log_and_report_session_state()?;
|
||||||
|
|
@ -3635,14 +3610,22 @@ pub(crate) fn screen_thread_main(
|
||||||
screen.render(None)?;
|
screen.render(None)?;
|
||||||
},
|
},
|
||||||
ScreenInstruction::MoveTabLeft(client_id) => {
|
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.unblock_input()?;
|
||||||
screen.render(None)?;
|
|
||||||
},
|
},
|
||||||
ScreenInstruction::MoveTabRight(client_id) => {
|
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.unblock_input()?;
|
||||||
screen.render(None)?;
|
|
||||||
},
|
},
|
||||||
ScreenInstruction::TerminalResize(new_size) => {
|
ScreenInstruction::TerminalResize(new_size) => {
|
||||||
screen.resize_to_screen(new_size)?;
|
screen.resize_to_screen(new_size)?;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue