pane: Turn off preview mode when pinning a tab (#22501)

Hayashi Mikihiro and Bennet Bo Fenner created

I opened the tab in preview mode, pinned it, then I opened another file,
but its tab unexpectedly closed.


https://github.com/user-attachments/assets/b857382e-f0ad-4d5a-9036-19de01663c97

Pinning a tab now turns off preview mode.



https://github.com/user-attachments/assets/e34b7c7f-452b-4f36-99c1-e0c68429225c


Release Notes:

- Pinning a preview tab will now turn off preview mode

---------

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
Co-authored-by: Bennet Bo Fenner <bennet@zed.dev>

Change summary

crates/workspace/src/pane.rs | 4 ++++
1 file changed, 4 insertions(+)

Detailed changes

crates/workspace/src/pane.rs 🔗

@@ -1961,6 +1961,10 @@ impl Pane {
             self.pinned_tab_count += 1;
             let id = self.item_for_index(ix)?.item_id();
 
+            if self.is_active_preview_item(id) {
+                self.set_preview_item_id(None, cx);
+            }
+
             self.workspace
                 .update(cx, |_, cx| {
                     cx.defer(move |_, cx| move_item(&pane, &pane, id, destination_index, cx));