Skip to content

Commit 249f06e

Browse files
committed
Use display type none() to avoid gaps around hidden status bar items
1 parent 203cbd6 commit 249f06e

File tree

10 files changed

+50
-46
lines changed

10 files changed

+50
-46
lines changed

crates/diagnostics/src/items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl Render for DiagnosticIndicator {
3030
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
3131
let indicator = h_flex().gap_2();
3232
if !ProjectSettings::get_global(cx).diagnostics.button {
33-
return indicator;
33+
return indicator.none();
3434
}
3535

3636
let diagnostic_indicator = match (self.summary.error_count, self.summary.warning_count) {

crates/edit_prediction_button/src/edit_prediction_button.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,17 @@ impl Render for EditPredictionButton {
7272
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
7373
// Return empty div if AI is disabled
7474
if DisableAiSettings::get_global(cx).disable_ai {
75-
return div();
75+
return div().none();
7676
}
7777

7878
let all_language_settings = all_language_settings(None, cx);
7979

8080
match all_language_settings.edit_predictions.provider {
81-
EditPredictionProvider::None => div(),
81+
EditPredictionProvider::None => div().none(),
8282

8383
EditPredictionProvider::Copilot => {
8484
let Some(copilot) = Copilot::global(cx) else {
85-
return div();
85+
return div().none();
8686
};
8787
let status = copilot.read(cx).status();
8888

crates/go_to_line/src/cursor_position.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use editor::{Editor, MultiBufferSnapshot};
2-
use gpui::{App, Entity, FocusHandle, Focusable, Subscription, Task, WeakEntity};
2+
use gpui::{App, Entity, FocusHandle, Focusable, Styled, Subscription, Task, WeakEntity};
33
use settings::Settings;
44
use std::{fmt::Write, num::NonZeroU32, time::Duration};
55
use text::{Point, Selection};
@@ -208,7 +208,7 @@ impl CursorPosition {
208208
impl Render for CursorPosition {
209209
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
210210
if !StatusBarSettings::get_global(cx).cursor_position_button {
211-
return div();
211+
return div().none();
212212
}
213213

214214
div().when_some(self.position, |el, position| {

crates/image_viewer/src/image_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl Render for ImageInfo {
4747
let settings = ImageViewerSettings::get_global(cx);
4848

4949
let Some(metadata) = self.metadata.as_ref() else {
50-
return div();
50+
return div().none();
5151
};
5252

5353
let mut components = Vec::new();

crates/language_selector/src/active_buffer_language.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use editor::Editor;
22
use gpui::{
3-
Context, Entity, IntoElement, ParentElement, Render, Subscription, WeakEntity, Window, div,
3+
Context, Entity, IntoElement, ParentElement, Render, Styled, Subscription, WeakEntity, Window,
4+
div,
45
};
56
use language::LanguageName;
67
use settings::Settings as _;
@@ -41,7 +42,7 @@ impl ActiveBufferLanguage {
4142
impl Render for ActiveBufferLanguage {
4243
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
4344
if !StatusBarSettings::get_global(cx).active_language_button {
44-
return div();
45+
return div().none();
4546
}
4647

4748
div().when_some(self.active_language.as_ref(), |el, active_language| {

crates/language_tools/src/lsp_button.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ impl StatusItemView for LspButton {
10111011
impl Render for LspButton {
10121012
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl ui::IntoElement {
10131013
if self.server_state.read(cx).language_servers.is_empty() || self.lsp_menu.is_none() {
1014-
return div();
1014+
return div().none();
10151015
}
10161016

10171017
let mut has_errors = false;

crates/line_ending_selector/src/line_ending_indicator.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,25 @@ impl LineEndingIndicator {
3131
impl Render for LineEndingIndicator {
3232
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
3333
if !StatusBarSettings::get_global(cx).line_endings_button {
34-
return div();
34+
return div().none();
3535
}
3636

37-
div().when_some(self.line_ending.as_ref(), |el, line_ending| {
38-
el.child(
39-
Button::new("change-line-ending", line_ending.label())
40-
.label_size(LabelSize::Small)
41-
.on_click(cx.listener(|this, _, window, cx| {
42-
if let Some(editor) = this.active_editor.as_ref() {
43-
LineEndingSelector::toggle(editor, window, cx);
44-
}
45-
}))
46-
.tooltip(|window, cx| {
47-
Tooltip::for_action("Select Line Ending", &Toggle, window, cx)
48-
}),
49-
)
50-
})
37+
let Some(line_ending) = self.line_ending else {
38+
return div().none();
39+
};
40+
41+
div().child(
42+
Button::new("change-line-ending", line_ending.label())
43+
.label_size(LabelSize::Small)
44+
.on_click(cx.listener(|this, _, window, cx| {
45+
if let Some(editor) = this.active_editor.as_ref() {
46+
LineEndingSelector::toggle(editor, window, cx);
47+
}
48+
}))
49+
.tooltip(|window, cx| {
50+
Tooltip::for_action("Select Line Ending", &Toggle, window, cx)
51+
}),
52+
)
5153
}
5254
}
5355

crates/search/src/search_status_button.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl Render for SearchButton {
1818
let button = div();
1919

2020
if !EditorSettings::get_global(cx).search.button {
21-
return button.w_0().invisible();
21+
return button.none();
2222
}
2323

2424
button.child(

crates/toolchain_selector/src/active_toolchain.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ use std::sync::Arc;
22

33
use editor::Editor;
44
use gpui::{
5-
AsyncWindowContext, Context, Entity, IntoElement, ParentElement, Render, Subscription, Task,
6-
WeakEntity, Window, div,
5+
AsyncWindowContext, Context, Entity, IntoElement, ParentElement, Render, Styled, Subscription,
6+
Task, WeakEntity, Window, div,
77
};
88
use language::{Buffer, BufferEvent, LanguageName, Toolchain, ToolchainScope};
99
use project::{Project, ProjectPath, Toolchains, WorktreeId, toolchain_store::ToolchainStoreEvent};
10-
use ui::{Button, ButtonCommon, Clickable, FluentBuilder, LabelSize, SharedString, Tooltip};
10+
use ui::{Button, ButtonCommon, Clickable, LabelSize, SharedString, Tooltip};
1111
use util::{maybe, rel_path::RelPath};
1212
use workspace::{StatusItemView, Workspace, item::ItemHandle};
1313

@@ -230,21 +230,22 @@ impl ActiveToolchain {
230230

231231
impl Render for ActiveToolchain {
232232
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
233-
div().when_some(self.active_toolchain.as_ref(), |el, active_toolchain| {
234-
let term = self.term.clone();
235-
el.child(
236-
Button::new("change-toolchain", active_toolchain.name.clone())
237-
.label_size(LabelSize::Small)
238-
.on_click(cx.listener(|this, _, window, cx| {
239-
if let Some(workspace) = this.workspace.upgrade() {
240-
workspace.update(cx, |workspace, cx| {
241-
ToolchainSelector::toggle(workspace, window, cx)
242-
});
243-
}
244-
}))
245-
.tooltip(Tooltip::text(format!("Select {}", &term))),
246-
)
247-
})
233+
let Some(active_toolchain) = self.active_toolchain.as_ref() else {
234+
return div().none();
235+
};
236+
237+
div().child(
238+
Button::new("change-toolchain", active_toolchain.name.clone())
239+
.label_size(LabelSize::Small)
240+
.on_click(cx.listener(|this, _, window, cx| {
241+
if let Some(workspace) = this.workspace.upgrade() {
242+
workspace.update(cx, |workspace, cx| {
243+
ToolchainSelector::toggle(workspace, window, cx)
244+
});
245+
}
246+
}))
247+
.tooltip(Tooltip::text(format!("Select {}", &self.term))),
248+
)
248249
}
249250
}
250251

crates/vim/src/mode_indicator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use gpui::{Context, Element, Entity, Render, Subscription, WeakEntity, Window, div};
1+
use gpui::{Context, Entity, Render, Subscription, WeakEntity, Window, div};
22
use ui::text_for_keystrokes;
33
use workspace::{StatusItemView, item::ItemHandle, ui::prelude::*};
44

@@ -89,7 +89,7 @@ impl Render for ModeIndicator {
8989
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
9090
let vim = self.vim();
9191
let Some(vim) = vim else {
92-
return div().into_any();
92+
return div().none().into_any_element();
9393
};
9494

9595
let vim_readable = vim.read(cx);

0 commit comments

Comments
 (0)