Skip to content
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

Merged

Conversation

axelcarl
Copy link
Contributor

@axelcarl axelcarl commented Oct 23, 2024

Closing multiple items will no longer closed pinned tabs.

Closes #19560

Release Notes:

  • Fixed close actions closing pinned tabs.

Copy link

cla-bot bot commented Oct 23, 2024

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Axel Carlsson.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email [email protected]
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 23, 2024
@maxdeviant maxdeviant changed the title fix: Exclude pinned tabs when closing all items Exclude pinned tabs when closing all items Oct 23, 2024
@CharlesChen0823
Copy link
Contributor

might we can add one more action? like CloseAllItemsExcludePinned?

@axelcarl
Copy link
Contributor Author

@CharlesChen0823 that could be an option, or add an action called CloseAllIncludingPinned, I guess it depends on what is the most sensible default?

@HarshNarayanJha
Copy link
Contributor

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 Close All Except Pinned will only introduce inconvenience!

@axelcarl
Copy link
Contributor Author

axelcarl commented Oct 25, 2024

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?

@HarshNarayanJha
Copy link
Contributor

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?

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.

@axelcarl
Copy link
Contributor Author

@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.

Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I think we need to adjust all "Close*` tab-related commands
  2. 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 SomeoneToIgnore self-assigned this Nov 5, 2024
@axelcarl
Copy link
Contributor Author

axelcarl commented Nov 6, 2024

@SomeoneToIgnore Good idea, will refactor the PR.

@axelcarl axelcarl changed the title Exclude pinned tabs when closing all items Exclude pinned tabs when closing items Nov 6, 2024
Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a 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.

}

#[derive(Clone, PartialEq, Debug, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct CloseAllItems {
pub save_intent: Option<SaveIntent>,
pub close_pinned: Option<bool>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub close_pinned: Option<bool>,
pub close_pinned: bool,

Why cannot it be just this? What does None mean?

Same for everything below.

Copy link
Contributor Author

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).

Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore Nov 7, 2024

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

"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.

Copy link
Contributor Author

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.
Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@SomeoneToIgnore SomeoneToIgnore merged commit 4f62ebe into zed-industries:main Nov 7, 2024
11 checks passed
@axelcarl axelcarl deleted the fix/dont-close-pinned branch November 7, 2024 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Close all except pinned tabs
4 participants