pane: Improve close active item to better handle pinned tabs (#23488)

Closes #22247

- [x] Do not close pinned tab on keyboard shortcuts like `ctrl+w` or
`alt+f4`
- [x] Close pinned tab on context menu action, menu bar action, or vim
bang
- [x] While closing pinned tab via shortcut (where it won't close),
instead activate any other non-pinned tab in same pane
- [x] Else, if any other pane contains non-pinned tab, activate that
- [x] Tests

Co-authored-by: uncenter <47499684+uncenter@users.noreply.github.com>

Release Notes:

- Pinned tab now stay open when using close shortcuts, auto focuses to
any other non-pinned tab instead.
This commit is contained in:
smit 2025-02-07 22:54:57 +05:30 committed by GitHub
parent f0565b4e2e
commit 44c6a54f95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 298 additions and 36 deletions

View file

@ -8175,6 +8175,7 @@ mod tests {
pane.close_active_item(
&CloseActiveItem {
save_intent: Some(SaveIntent::Close),
close_pinned: false,
},
window,
cx,
@ -8279,7 +8280,14 @@ mod tests {
});
let close_singleton_buffer_task = pane
.update_in(cx, |pane, window, cx| {
pane.close_active_item(&CloseActiveItem { save_intent: None }, window, cx)
pane.close_active_item(
&CloseActiveItem {
save_intent: None,
close_pinned: false,
},
window,
cx,
)
})
.expect("should have active singleton buffer to close");
cx.background_executor.run_until_parked();
@ -8385,7 +8393,14 @@ mod tests {
});
let _close_multi_buffer_task = pane
.update_in(cx, |pane, window, cx| {
pane.close_active_item(&CloseActiveItem { save_intent: None }, window, cx)
pane.close_active_item(
&CloseActiveItem {
save_intent: None,
close_pinned: false,
},
window,
cx,
)
})
.expect("should have active multi buffer to close");
cx.background_executor.run_until_parked();
@ -8476,7 +8491,14 @@ mod tests {
});
let close_multi_buffer_task = pane
.update_in(cx, |pane, window, cx| {
pane.close_active_item(&CloseActiveItem { save_intent: None }, window, cx)
pane.close_active_item(
&CloseActiveItem {
save_intent: None,
close_pinned: false,
},
window,
cx,
)
})
.expect("should have active multi buffer to close");
cx.background_executor.run_until_parked();