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

@ -3103,7 +3103,10 @@ mod tests {
});
cx.dispatch_action(
window.into(),
workspace::CloseActiveItem { save_intent: None },
workspace::CloseActiveItem {
save_intent: None,
close_pinned: false,
},
);
cx.background_executor.run_until_parked();
@ -3116,7 +3119,10 @@ mod tests {
cx.dispatch_action(
window.into(),
workspace::CloseActiveItem { save_intent: None },
workspace::CloseActiveItem {
save_intent: None,
close_pinned: false,
},
);
cx.background_executor.run_until_parked();
cx.simulate_prompt_answer(1);

View file

@ -76,7 +76,10 @@ pub fn app_menus() -> Vec<Menu> {
MenuItem::action("Save All", workspace::SaveAll { save_intent: None }),
MenuItem::action(
"Close Editor",
workspace::CloseActiveItem { save_intent: None },
workspace::CloseActiveItem {
save_intent: None,
close_pinned: true,
},
),
MenuItem::action("Close Window", workspace::CloseWindow),
],