diff options
| author | Dante Pippi <6619666+dantepippi@users.noreply.github.com> | 2021-05-07 18:19:23 -0300 |
|---|---|---|
| committer | Dante Pippi <6619666+dantepippi@users.noreply.github.com> | 2021-05-09 17:05:14 -0300 |
| commit | 9c09cf16587a2b97c63c05d94ff4f18fe557cbf5 (patch) | |
| tree | 18a8ff8eebbbff0f93eb5af8e270c398ccb65a70 /src/client | |
| parent | Merge pull request #473 from zellij-org/bus-business-with-extra-merge-fun (diff) | |
| download | sl0ppij-9c09cf16587a2b97c63c05d94ff4f18fe557cbf5.tar.gz sl0ppij-9c09cf16587a2b97c63c05d94ff4f18fe557cbf5.tar.xz sl0ppij-9c09cf16587a2b97c63c05d94ff4f18fe557cbf5.zip | |
New behavior for h and l
New behavior for h and l, will change tabs if there are no available
panes in the direction.
cargo clippy
Ensuring atomicity for the MoveFocusOrTab
- Blocking the input thread for the action MoveFocusOrTab
- Using "unreachable" macro in match arm to make it clear that the
directions Up and Down should not be used with the action MoveFocusOrTab
Adding tests
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/tab.rs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/client/tab.rs b/src/client/tab.rs index bbd68a4d..7636be39 100644 --- a/src/client/tab.rs +++ b/src/client/tab.rs @@ -1848,12 +1848,13 @@ impl Tab { } self.render(); } - pub fn move_focus_left(&mut self) { + // returns a boolean to allow the caller to know if the move happened or not + pub fn move_focus_left(&mut self) -> bool { if !self.has_selectable_panes() { - return; + return false; } if self.fullscreen_is_active { - return; + return false; } let active_terminal = self.get_active_pane(); if let Some(active) = active_terminal { @@ -1868,6 +1869,8 @@ impl Tab { match next_index { Some(&p) => { self.active_terminal = Some(p); + self.render(); + return true; } None => { self.active_terminal = Some(active.pid()); @@ -1876,7 +1879,7 @@ impl Tab { } else { self.active_terminal = Some(active_terminal.unwrap().pid()); } - self.render(); + false } pub fn move_focus_down(&mut self) { if !self.has_selectable_panes() { @@ -1938,12 +1941,13 @@ impl Tab { } self.render(); } - pub fn move_focus_right(&mut self) { + // returns a boolean to allow the caller to know if the move happened or not + pub fn move_focus_right(&mut self) -> bool { if !self.has_selectable_panes() { - return; + return false; } if self.fullscreen_is_active { - return; + return false; } let active_terminal = self.get_active_pane(); if let Some(active) = active_terminal { @@ -1958,6 +1962,8 @@ impl Tab { match next_index { Some(&p) => { self.active_terminal = Some(p); + self.render(); + return true; } None => { self.active_terminal = Some(active.pid()); @@ -1966,7 +1972,7 @@ impl Tab { } else { self.active_terminal = Some(active_terminal.unwrap().pid()); } - self.render(); + false } fn horizontal_borders(&self, terminals: &[PaneId]) -> HashSet<usize> { terminals.iter().fold(HashSet::new(), |mut borders, t| { |
