Skip to content

Commit dacd919

Browse files
authored
Add setting for making the tab's close button always visible (#21352)
Closes #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
1 parent 740ba78 commit dacd919

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

assets/settings/default.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,8 @@
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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub struct ItemSettings {
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 {
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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,7 +1951,9 @@ impl Pane {
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 {
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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,8 @@ List of `string` values
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
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.

0 commit comments

Comments
 (0)