aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2021-04-05 10:48:27 +0200
committerGitHub <noreply@github.com>2021-04-05 10:48:27 +0200
commitcdbd74f49b9d7e896fffd010dabede5164186278 (patch)
tree974232182cc77d1c6f20b3fda9b28b71003a1e09 /src/client
parentMerge pull request #242 from a-kenji/strider-empty-directory (diff)
downloadsl0ppij-cdbd74f49b9d7e896fffd010dabede5164186278.tar.gz
sl0ppij-cdbd74f49b9d7e896fffd010dabede5164186278.tar.xz
sl0ppij-cdbd74f49b9d7e896fffd010dabede5164186278.zip
fix(tabs): do not resize title bar when closing pane under it (#252)
* fix(tabs): closing a pane no longer resizes the tab bar * style(tab): add clarification comment
Diffstat (limited to 'src/client')
-rw-r--r--src/client/tab.rs99
1 files changed, 64 insertions, 35 deletions
diff --git a/src/client/tab.rs b/src/client/tab.rs
index 695d42cb..9e2b370f 100644
--- a/src/client/tab.rs
+++ b/src/client/tab.rs
@@ -2064,47 +2064,76 @@ impl Tab {
}
}
pub fn close_pane_without_rerender(&mut self, id: PaneId) {
- if let Some(terminal_to_close) = self.panes.get(&id) {
- let terminal_to_close_width = terminal_to_close.columns();
- let terminal_to_close_height = terminal_to_close.rows();
- if let Some(terminals) = self.panes_to_the_left_between_aligning_borders(id) {
- for terminal_id in terminals.iter() {
- self.increase_pane_width_right(&terminal_id, terminal_to_close_width + 1);
- // 1 for the border
- }
- if self.active_terminal == Some(id) {
- self.active_terminal = self.next_active_pane(terminals);
- }
- } else if let Some(terminals) = self.panes_to_the_right_between_aligning_borders(id) {
- for terminal_id in terminals.iter() {
- self.increase_pane_width_left(&terminal_id, terminal_to_close_width + 1);
- // 1 for the border
- }
- if self.active_terminal == Some(id) {
- self.active_terminal = self.next_active_pane(terminals);
- }
- } else if let Some(terminals) = self.panes_above_between_aligning_borders(id) {
- for terminal_id in terminals.iter() {
- self.increase_pane_height_down(&terminal_id, terminal_to_close_height + 1);
- // 1 for the border
+ if let Some(pane_to_close) = self.panes.get(&id) {
+ let pane_to_close_width = pane_to_close.columns();
+ let pane_to_close_height = pane_to_close.rows();
+ if let Some(panes) = self.panes_to_the_left_between_aligning_borders(id) {
+ if panes.iter().all(|p| {
+ let pane = self.panes.get(p).unwrap();
+ pane.can_increase_width_by(pane_to_close_width + 1)
+ }) {
+ for pane_id in panes.iter() {
+ self.increase_pane_width_right(&pane_id, pane_to_close_width + 1);
+ // 1 for the border
+ }
+ self.panes.remove(&id);
+ if self.active_terminal == Some(id) {
+ self.active_terminal = self.next_active_pane(panes);
+ }
+ return;
}
- if self.active_terminal == Some(id) {
- self.active_terminal = self.next_active_pane(terminals);
+ }
+ if let Some(panes) = self.panes_to_the_right_between_aligning_borders(id) {
+ if panes.iter().all(|p| {
+ let pane = self.panes.get(p).unwrap();
+ pane.can_increase_width_by(pane_to_close_width + 1)
+ }) {
+ for pane_id in panes.iter() {
+ self.increase_pane_width_left(&pane_id, pane_to_close_width + 1);
+ // 1 for the border
+ }
+ self.panes.remove(&id);
+ if self.active_terminal == Some(id) {
+ self.active_terminal = self.next_active_pane(panes);
+ }
+ return;
}
- } else if let Some(terminals) = self.panes_below_between_aligning_borders(id) {
- for terminal_id in terminals.iter() {
- self.increase_pane_height_up(&terminal_id, terminal_to_close_height + 1);
- // 1 for the border
+ }
+ if let Some(panes) = self.panes_above_between_aligning_borders(id) {
+ if panes.iter().all(|p| {
+ let pane = self.panes.get(p).unwrap();
+ pane.can_increase_height_by(pane_to_close_height + 1)
+ }) {
+ for pane_id in panes.iter() {
+ self.increase_pane_height_down(&pane_id, pane_to_close_height + 1);
+ // 1 for the border
+ }
+ self.panes.remove(&id);
+ if self.active_terminal == Some(id) {
+ self.active_terminal = self.next_active_pane(panes);
+ }
+ return;
}
- if self.active_terminal == Some(id) {
- self.active_terminal = self.next_active_pane(terminals);
+ }
+ if let Some(panes) = self.panes_below_between_aligning_borders(id) {
+ if panes.iter().all(|p| {
+ let pane = self.panes.get(p).unwrap();
+ pane.can_increase_height_by(pane_to_close_height + 1)
+ }) {
+ for pane_id in panes.iter() {
+ self.increase_pane_height_up(&pane_id, pane_to_close_height + 1);
+ // 1 for the border
+ }
+ self.panes.remove(&id);
+ if self.active_terminal == Some(id) {
+ self.active_terminal = self.next_active_pane(panes);
+ }
+ return;
}
- } else {
}
+ // if we reached here, this is either the last pane or there's some sort of
+ // configuration error (eg. we're trying to close a pane surrounded by fixed panes)
self.panes.remove(&id);
- if self.active_terminal.is_none() {
- self.active_terminal = self.next_active_pane(self.get_pane_ids());
- }
}
}
pub fn close_focused_pane(&mut self) {