Fix a panic when drop-splitting the terminal panel (cherry-pick #21795) (#21798)

gcp-cherry-pick-bot[bot] and Kirill Bulatov created

Cherry-picked Fix a panic when drop-splitting the terminal panel
(#21795)

Closes https://github.com/zed-industries/zed/issues/21792

Release Notes:

- (Preview only) Fixed a panic when drop-splitting the terminal panel

Co-authored-by: Kirill Bulatov <kirill@zed.dev>

Change summary

crates/terminal_view/src/terminal_panel.rs | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

Detailed changes

crates/terminal_view/src/terminal_panel.rs 🔗

@@ -912,10 +912,15 @@ pub fn new_terminal_pane(
 
                         let new_pane = pane.drag_split_direction().and_then(|split_direction| {
                             terminal_panel.update(cx, |terminal_panel, cx| {
+                                let is_zoomed = if terminal_panel.active_pane == this_pane {
+                                    pane.is_zoomed()
+                                } else {
+                                    terminal_panel.active_pane.read(cx).is_zoomed()
+                                };
                                 let new_pane = new_terminal_pane(
                                     workspace.clone(),
                                     project.clone(),
-                                    terminal_panel.active_pane.read(cx).is_zoomed(),
+                                    is_zoomed,
                                     cx,
                                 );
                                 terminal_panel.apply_tab_bar_buttons(&new_pane, cx);