Repository: wezterm/wezterm (language: rust)

Issue:
activate-pane CLI should unzoom the current pane if unzoom_on_switch_pane is set to true
### What Operating System(s) are you seeing this problem on?

macOS

### Which Wayland compositor or X11 Window manager(s) are you using?

_No response_

### WezTerm version

20240405-180910-cce0706b

### Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

### Describe the bug

https://wezfurlong.org/wezterm/config/lua/config/unzoom_on_switch_pane.html

`unzoom_on_switch_pane` is set to true. Currently, if a pane is split (for e.g, top-bottom), then I focus on the top pane, make it zoomed.

If I run:

```
wezterm cli activate-pane-direction down
```

The top pane will be unzoomed first, then switch to the bottom pane.

I expect it should be the same when running:

```
wezterm cli activate-pane --pane-id $bottom_pane_id
```

### To Reproduce

- split a pane (top-bottom)
- zoom the top pane
- run `wezterm cli activate-pane --pane-id $bottom_pane_id`

### Configuration

```
config.unzoom_on_switch_pane = true
```

### Expected Behavior

The top pane should be unzoom first, then switch to the bottom pane.

### Logs

_No response_

### Anything else?

_No response_


Discussion / hints:

Fix patch:
diff --git a/mux/src/tab.rs b/mux/src/tab.rs
index 1b46ff170bb..cb543781072 100644
--- a/mux/src/tab.rs
+++ b/mux/src/tab.rs
@@ -1724,6 +1724,13 @@ impl TabInner {
     }
 
     fn set_active_pane(&mut self, pane: &Arc<dyn Pane>) {
+        if self.zoomed.is_some() {
+            if !configuration().unzoom_on_switch_pane {
+                return;
+            }
+            self.toggle_zoom();
+        }
+
         if let Some(item) = self
             .iter_panes_ignoring_zoom()
             .iter()


Test patch: