Repository: zellij-org/zellij (language: rust)

Issue:
Alt-h, Alt-l only go in one direction in fullscreen panes
<!-- Thank you for taking the time to file this issue! Please follow the instructions and fill in the missing parts below the instructions, if it is meaningful. Try to be brief and concise. -->

**Basic information**

`zellij --version`: zellij 0.34.4 and [b274fc5](https://github.com/zellij-org/zellij/commit/b274fc5ab19abe8b3ef7f7afe38897f526263414)
`stty size`: 42 168
`uname -av` or `ver`(Windows): Linux endeavouros 6.1.6-arch1-3 #1 SMP PREEMPT_DYNAMIC Mon, 16 Jan 2023 12:51:23 +0000 x86_64 GNU/Linux

<!-- List of programs you interact with: -->

**Further information**

Reproduction steps:
1. Open `zellij`.
2. Open 3 or more panes in 1 tab.
3. Enable fullscreen.
4. Press `Alt-h`/`Alt-l`, they will both switch to the next pane but not the previous one.


https://user-images.githubusercontent.com/49095435/213832357-f4a28ebd-4001-40ce-913d-0f21e10798cc.mp4




Discussion / hints:
can't see anything in the video
> can't see anything in the video

If you have 3 panes: 1, 2, 3. After fullscreen pane 1, pressing either `Alt-h` or `Alt-l` will only cycle them in 1 direction (1 -> 2 -> 3 -> 1 -> ...).

In the video, I pressed `Alt-l` `Alt-l` `Alt-h` `Alt-h` which means the tabs should cycle like this 1 -> 2 -> 3  -> 2 -> 1.
But zellij cycled 1 -> 2 -> 3  -> 1 -> 2.
I noticed this too the other day! Would love to see a fix for this.

Fix patch:
diff --git a/zellij-server/src/panes/tiled_panes/mod.rs b/zellij-server/src/panes/tiled_panes/mod.rs
index cad53e3f1e..4cc4a573ee 100644
--- a/zellij-server/src/panes/tiled_panes/mod.rs
+++ b/zellij-server/src/panes/tiled_panes/mod.rs
@@ -1181,6 +1181,30 @@ impl TiledPanes {
         }
     }
 
+    pub fn focus_pane_left_fullscreen(&mut self, client_id: ClientId) {
+        self.unset_fullscreen();
+        self.move_focus_left(client_id);
+        self.toggle_active_pane_fullscreen(client_id);
+    }
+
+    pub fn focus_pane_right_fullscreen(&mut self, client_id: ClientId) {
+        self.unset_fullscreen();
+        self.move_focus_right(client_id);
+        self.toggle_active_pane_fullscreen(client_id);
+    }
+
+    pub fn focus_pane_up_fullscreen(&mut self, client_id: ClientId) {
+        self.unset_fullscreen();
+        self.move_focus_up(client_id);
+        self.toggle_active_pane_fullscreen(client_id);
+    }
+
+    pub fn focus_pane_down_fullscreen(&mut self, client_id: ClientId) {
+        self.unset_fullscreen();
+        self.move_focus_down(client_id);
+        self.toggle_active_pane_fullscreen(client_id);
+    }
+
     pub fn switch_next_pane_fullscreen(&mut self, client_id: ClientId) {
         self.unset_fullscreen();
         self.focus_next_pane(client_id);
diff --git a/zellij-server/src/tab/mod.rs b/zellij-server/src/tab/mod.rs
index 0dcd7ba58e..59989765a7 100644
--- a/zellij-server/src/tab/mod.rs
+++ b/zellij-server/src/tab/mod.rs
@@ -1339,6 +1339,34 @@ impl Tab {
     pub fn are_floating_panes_visible(&self) -> bool {
         self.floating_panes.panes_are_visible()
     }
+    pub fn focus_pane_left_fullscreen(&mut self, client_id: ClientId) {
+        if !self.is_fullscreen_active() {
+            return;
+        }
+
+        self.tiled_panes.focus_pane_left_fullscreen(client_id);
+    }
+    pub fn focus_pane_right_fullscreen(&mut self, client_id: ClientId) {
+        if !self.is_fullscreen_active() {
+            return;
+        }
+
+        self.tiled_panes.focus_pane_right_fullscreen(client_id);
+    }
+    pub fn focus_pane_up_fullscreen(&mut self, client_id: ClientId) {
+        if !self.is_fullscreen_active() {
+            return;
+        }
+
+        self.tiled_panes.focus_pane_up_fullscreen(client_id);
+    }
+    pub fn focus_pane_down_fullscreen(&mut self, client_id: ClientId) {
+        if !self.is_fullscreen_active() {
+            return;
+        }
+
+        self.tiled_panes.focus_pane_down_fullscreen(client_id);
+    }
     pub fn switch_next_pane_fullscreen(&mut self, client_id: ClientId) {
         if !self.is_fullscreen_active() {
             return;
@@ -1349,7 +1377,7 @@ impl Tab {
         if !self.is_fullscreen_active() {
             return;
         }
-        self.tiled_panes.switch_next_pane_fullscreen(client_id);
+        self.tiled_panes.switch_prev_pane_fullscreen(client_id);
     }
     pub fn set_force_render(&mut self) {
         self.tiled_panes.set_force_render();
@@ -1613,7 +1641,7 @@ impl Tab {
                 return Ok(false);
             }
             if self.tiled_panes.fullscreen_is_active() {
-                self.switch_next_pane_fullscreen(client_id);
+                self.focus_pane_left_fullscreen(client_id);
                 return Ok(true);
             }
             Ok(self.tiled_panes.move_focus_left(client_id))
@@ -1635,7 +1663,8 @@ impl Tab {
                 return Ok(false);
             }
             if self.tiled_panes.fullscreen_is_active() {
-                return Ok(false);
+                self.focus_pane_down_fullscreen(client_id);
+                return Ok(true);
             }
             Ok(self.tiled_panes.move_focus_down(client_id))
         }
@@ -1656,7 +1685,8 @@ impl Tab {
                 return Ok(false);
             }
             if self.tiled_panes.fullscreen_is_active() {
-                return Ok(false);
+                self.focus_pane_up_fullscreen(client_id);
+                return Ok(true);
             }
             Ok(self.tiled_panes.move_focus_up(client_id))
         }
@@ -1678,7 +1708,7 @@ impl Tab {
                 return Ok(false);
             }
             if self.tiled_panes.fullscreen_is_active() {
-                self.switch_next_pane_fullscreen(client_id);
+                self.focus_pane_right_fullscreen(client_id);
                 return Ok(true);
             }
             Ok(self.tiled_panes.move_focus_right(client_id))


Test patch: