fix(floating-panes): when changing coordinates, if a pane is not floating - make it floating (#3972)
* fix(panes): when changing floating pane coordinates, if the pane is not floating, float it * style(fmt): rustfmt
This commit is contained in:
parent
3a053de2d0
commit
af2be7a7a4
2 changed files with 25 additions and 8 deletions
|
|
@ -2067,6 +2067,7 @@ impl Screen {
|
||||||
plugin_pane_to_move_to_active_tab,
|
plugin_pane_to_move_to_active_tab,
|
||||||
pane_id,
|
pane_id,
|
||||||
None,
|
None,
|
||||||
|
true,
|
||||||
)?;
|
)?;
|
||||||
} else {
|
} else {
|
||||||
new_active_tab.hide_floating_panes();
|
new_active_tab.hide_floating_panes();
|
||||||
|
|
@ -2180,7 +2181,7 @@ impl Screen {
|
||||||
let (mut tiled_panes_layout, mut floating_panes_layout) = default_layout.new_tab();
|
let (mut tiled_panes_layout, mut floating_panes_layout) = default_layout.new_tab();
|
||||||
if pane_to_break_is_floating {
|
if pane_to_break_is_floating {
|
||||||
tab.show_floating_panes();
|
tab.show_floating_panes();
|
||||||
tab.add_floating_pane(active_pane, active_pane_id, None)?;
|
tab.add_floating_pane(active_pane, active_pane_id, None, true)?;
|
||||||
if let Some(already_running_layout) = floating_panes_layout
|
if let Some(already_running_layout) = floating_panes_layout
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|i| i.run == active_pane_run_instruction)
|
.find(|i| i.run == active_pane_run_instruction)
|
||||||
|
|
@ -2304,7 +2305,7 @@ impl Screen {
|
||||||
|
|
||||||
if pane_to_break_is_floating {
|
if pane_to_break_is_floating {
|
||||||
new_active_tab.show_floating_panes();
|
new_active_tab.show_floating_panes();
|
||||||
new_active_tab.add_floating_pane(active_pane, active_pane_id, None)?;
|
new_active_tab.add_floating_pane(active_pane, active_pane_id, None, true)?;
|
||||||
} else {
|
} else {
|
||||||
new_active_tab.hide_floating_panes();
|
new_active_tab.hide_floating_panes();
|
||||||
new_active_tab.add_tiled_pane(active_pane, active_pane_id, Some(client_id))?;
|
new_active_tab.add_tiled_pane(active_pane, active_pane_id, Some(client_id))?;
|
||||||
|
|
|
||||||
|
|
@ -1026,7 +1026,7 @@ impl Tab {
|
||||||
}
|
}
|
||||||
if let Some(embedded_pane_to_float) = self.extract_pane(focused_pane_id, true) {
|
if let Some(embedded_pane_to_float) = self.extract_pane(focused_pane_id, true) {
|
||||||
self.show_floating_panes();
|
self.show_floating_panes();
|
||||||
self.add_floating_pane(embedded_pane_to_float, focused_pane_id, None)?;
|
self.add_floating_pane(embedded_pane_to_float, focused_pane_id, None, true)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -1058,7 +1058,7 @@ impl Tab {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
if let Some(embedded_pane_to_float) = self.extract_pane(pane_id, true) {
|
if let Some(embedded_pane_to_float) = self.extract_pane(pane_id, true) {
|
||||||
self.add_floating_pane(embedded_pane_to_float, pane_id, None)?;
|
self.add_floating_pane(embedded_pane_to_float, pane_id, None, true)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -1203,7 +1203,7 @@ impl Tab {
|
||||||
.insert(pid, (is_scrollback_editor, new_pane));
|
.insert(pid, (is_scrollback_editor, new_pane));
|
||||||
Ok(())
|
Ok(())
|
||||||
} else if self.floating_panes.panes_are_visible() {
|
} else if self.floating_panes.panes_are_visible() {
|
||||||
self.add_floating_pane(new_pane, pid, floating_pane_coordinates)
|
self.add_floating_pane(new_pane, pid, floating_pane_coordinates, true)
|
||||||
} else {
|
} else {
|
||||||
self.add_tiled_pane(new_pane, pid, client_id)
|
self.add_tiled_pane(new_pane, pid, client_id)
|
||||||
}
|
}
|
||||||
|
|
@ -4177,7 +4177,7 @@ impl Tab {
|
||||||
pane.1.set_selectable(true);
|
pane.1.set_selectable(true);
|
||||||
if should_float {
|
if should_float {
|
||||||
self.show_floating_panes();
|
self.show_floating_panes();
|
||||||
self.add_floating_pane(pane.1, pane_id, None)
|
self.add_floating_pane(pane.1, pane_id, None, true)
|
||||||
} else {
|
} else {
|
||||||
self.hide_floating_panes();
|
self.hide_floating_panes();
|
||||||
self.add_tiled_pane(pane.1, pane_id, Some(client_id))
|
self.add_tiled_pane(pane.1, pane_id, Some(client_id))
|
||||||
|
|
@ -4190,7 +4190,8 @@ impl Tab {
|
||||||
match self.suppressed_panes.remove(&pane_id) {
|
match self.suppressed_panes.remove(&pane_id) {
|
||||||
Some(pane) => {
|
Some(pane) => {
|
||||||
self.show_floating_panes();
|
self.show_floating_panes();
|
||||||
self.add_floating_pane(pane.1, pane_id, None).non_fatal();
|
self.add_floating_pane(pane.1, pane_id, None, true)
|
||||||
|
.non_fatal();
|
||||||
self.floating_panes.focus_pane_for_all_clients(pane_id);
|
self.floating_panes.focus_pane_for_all_clients(pane_id);
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
|
|
@ -4230,6 +4231,7 @@ impl Tab {
|
||||||
mut pane: Box<dyn Pane>,
|
mut pane: Box<dyn Pane>,
|
||||||
pane_id: PaneId,
|
pane_id: PaneId,
|
||||||
floating_pane_coordinates: Option<FloatingPaneCoordinates>,
|
floating_pane_coordinates: Option<FloatingPaneCoordinates>,
|
||||||
|
should_focus_new_pane: bool,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let err_context = || format!("failed to add floating pane");
|
let err_context = || format!("failed to add floating pane");
|
||||||
if let Some(mut new_pane_geom) = self.floating_panes.find_room_for_new_pane() {
|
if let Some(mut new_pane_geom) = self.floating_panes.find_room_for_new_pane() {
|
||||||
|
|
@ -4247,8 +4249,10 @@ impl Tab {
|
||||||
resize_pty!(pane, self.os_api, self.senders, self.character_cell_size)
|
resize_pty!(pane, self.os_api, self.senders, self.character_cell_size)
|
||||||
.with_context(err_context)?;
|
.with_context(err_context)?;
|
||||||
self.floating_panes.add_pane(pane_id, pane);
|
self.floating_panes.add_pane(pane_id, pane);
|
||||||
|
if should_focus_new_pane {
|
||||||
self.floating_panes.focus_pane_for_all_clients(pane_id);
|
self.floating_panes.focus_pane_for_all_clients(pane_id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if self.auto_layout && !self.swap_layouts.is_floating_damaged() {
|
if self.auto_layout && !self.swap_layouts.is_floating_damaged() {
|
||||||
// only do this if we're already in this layout, otherwise it might be
|
// only do this if we're already in this layout, otherwise it might be
|
||||||
// confusing and not what the user intends
|
// confusing and not what the user intends
|
||||||
|
|
@ -4520,6 +4524,18 @@ impl Tab {
|
||||||
pane_id: &PaneId,
|
pane_id: &PaneId,
|
||||||
floating_pane_coordinates: FloatingPaneCoordinates,
|
floating_pane_coordinates: FloatingPaneCoordinates,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
if !self.floating_panes.panes_contain(pane_id) {
|
||||||
|
// if these panes are not floating, we make them floating (assuming doing so wouldn't
|
||||||
|
// be removing the last selectable tiled pane in the tab, which would close it)
|
||||||
|
if (self.tiled_panes.panes_contain(&pane_id)
|
||||||
|
&& self.get_selectable_tiled_panes().count() <= 1)
|
||||||
|
|| self.suppressed_panes.contains_key(pane_id)
|
||||||
|
{
|
||||||
|
if let Some(pane) = self.extract_pane(*pane_id, true) {
|
||||||
|
self.add_floating_pane(pane, *pane_id, None, false)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
self.floating_panes
|
self.floating_panes
|
||||||
.change_pane_coordinates(*pane_id, floating_pane_coordinates)?;
|
.change_pane_coordinates(*pane_id, floating_pane_coordinates)?;
|
||||||
self.set_force_render();
|
self.set_force_render();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue