History

Add setting for making the tab's close button always visible (#21352)

Closes https://github.com/zed-industries/zed/issues/20422 <img width="700" alt="Screenshot 2024-11-29 at 22 00 20" src="https://github.com/user-attachments/assets/4a17d00c-d64f-4b33-97a7-a57766ce6d17"> Release Notes: - N/A

Danilo Leal committed 1 year ago

Commit dacd9191 parent 740ba784 files · +21 −3Browse files

Unified · Split

4 files
  1. assets/settings/default.json +2 −0
  2. crates/workspace/src/item.rs +5 −0
  3. crates/workspace/src/pane.rs +6 −2
  4. docs/src/configuring-zed.md +8 −1
assets/settings/default.json+2−0
@@ -559,6 +559,8 @@ · 558 unmodified lines
559559 "close_position": "right",
560560 // Whether to show the file icon for a tab.
561561 "file_icons": false,
562+ // Whether to always show the close button on tabs.
563+ "always_show_close_button": false,
562564 // What to do after closing the current tab.
563565 //
564566 // 1. Activate the tab that was open previously (default)
crates/workspace/src/item.rs+5−0
@@ -42,6 +42,7 @@ pub struct ItemSettings { · 41 unmodified lines
4242 pub close_position: ClosePosition,
4343 pub activate_on_close: ActivateOnClose,
4444 pub file_icons: bool,
45+ pub always_show_close_button: bool,
4546 }
4647
4748 #[derive(Deserialize)]
@@ -85,6 +86,10 @@ pub struct ItemSettingsContent { · 37 unmodified lines
8586 ///
8687 /// Default: history
8788 pub activate_on_close: Option<ActivateOnClose>,
89+ /// Whether to always show the close button on tabs.
90+ ///
91+ /// Default: false
92+ always_show_close_button: Option<bool>,
8893 }
8994
9095 #[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
crates/workspace/src/pane.rs+6−2
@@ -1951,7 +1951,9 @@ impl Pane { · 1950 unmodified lines
19511951 };
19521952
19531953 let icon = item.tab_icon(cx);
1954− let close_side = &ItemSettings::get_global(cx).close_position;
1954+ let settings = ItemSettings::get_global(cx);
1955+ let close_side = &settings.close_position;
1956+ let always_show_close_button = settings.always_show_close_button;
19551957 let indicator = render_item_indicator(item.boxed_clone(), cx);
19561958 let item_id = item.item_id();
19571959 let is_first_item = ix == 0;
@@ -2046,7 +2048,9 @@ impl Pane { · 88 unmodified lines
20462048 end_slot_action = &CloseActiveItem { save_intent: None };
20472049 end_slot_tooltip_text = "Close Tab";
20482050 IconButton::new("close tab", IconName::Close)
2049− .visible_on_hover("")
2051+ .when(!always_show_close_button, |button| {
2052+ button.visible_on_hover("")
2053+ })
20502054 .shape(IconButtonShape::Square)
20512055 .icon_color(Color::Muted)
20522056 .size(ButtonSize::None)
docs/src/configuring-zed.md+8−1
@@ -634,7 +634,8 @@ List of `string` values · 633 unmodified lines
634634 "close_position": "right",
635635 "file_icons": false,
636636 "git_status": false,
637− "activate_on_close": "history"
637+ "activate_on_close": "history",
638+ "always_show_close_button": false
638639 },
639640 ```
640641
@@ -698,6 +699,12 @@ List of `string` values · 57 unmodified lines
698699 }
699700 ```
700701
702+### Always show the close button
703+
704+- Description: Whether to always show the close button on tabs.
705+- Setting: `always_show_close_button`
706+- Default: `false`
707+
701708 ## Editor Toolbar
702709
703710 - Description: Whether or not to show various elements in the editor toolbar.