-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude pinned tabs when closing items #19593
Exclude pinned tabs when closing items #19593
Conversation
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Axel Carlsson.
|
3182e13
to
38fb1ea
Compare
might we can add one more action? like |
@CharlesChen0823 that could be an option, or add an action called CloseAllIncludingPinned, I guess it depends on what is the most sensible default? |
Well, Close All Tabs shouldn't really close the Pinned tabs because they are special, that's why they were pinned. Adding an option that says |
Yes, that was my feeling as well. Do you think I should add a CloseAllIncludingPinned that can be bound to qa (vim-mode) for those that want that as their default behavior? |
38fb1ea
to
0a355e0
Compare
Could be useful for is non vim users too. I agree with CloseAllIncludingPinned Action. But don't make it default, and for vim users, they know it better. |
@CharlesChen0823 @HarshNarayanJha Added the new action "CloseAllItemsIncludingPinned" and tests, I guess the question now is how close left/right should be affected, it would maybe make sense to alter them in a separate pull request though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I think we need to adjust all "Close*` tab-related commands
- We do not need any extra actions (not sure why that was suggested initially, but it's not a maintainer's suggestion so feel free to ignore).
Something like
#[derive(Clone, PartialEq, Debug, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct CloseAllItems {
pub save_intent: Option<SaveIntent>,
pub close_pinned: bool,
}
where close_pinned
will be false
by default and anyone may rebind it to something else if they need.
@SomeoneToIgnore Good idea, will refactor the PR. |
9969068
to
631c135
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, and even the new test is there.
Seems to be close to merging.
Let's also update both default-macos.json
and default-linux.json
to explicitly show the "close_pinned": false
in each affected action: this will serve as a documentation.
crates/workspace/src/pane.rs
Outdated
} | ||
|
||
#[derive(Clone, PartialEq, Debug, Deserialize, Default)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct CloseAllItems { | ||
pub save_intent: Option<SaveIntent>, | ||
pub close_pinned: Option<bool>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub close_pinned: Option<bool>, | |
pub close_pinned: bool, |
Why cannot it be just this? What does None
mean?
Same for everything below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opted for an Option to keep support for old keymaps, however if that is not reason enough I can switch it to bool!
(Setting it to a bool would require that every CloseAction would have to be followed by brackets and an explicit boolean value, whereas leaving it empty now would mean close_pinned would be "false" due to the unwrap_or statements).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting it to a bool would require that every CloseAction would have to be followed by brackets and an explicit boolean value
Can you elaborate?
I think it's not true at all, as when we deserialize, we fill in the defaults for the missing declarations.
Example:
we have
zed/assets/keymaps/default-macos.json
Line 117 in b0b29d9
"cmd-shift-left": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": true }], |
and when I declare
{
"bindings": {
"shift-d": "editor::SelectToBeginningOfLine"
}
}
it works for me just fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, then I was mistaken, will alter it to bool and update the json files. Thanks!
Pinned tabs are no longer closed when multiple items are closed. This behavior can be overriden by setting the field close_pinned to true.
631c135
to
086a1c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
Closing multiple items will no longer closed pinned tabs.
Closes #19560
Release Notes: