From edca195e3c02d30d519dc0a29c1c5e55ea5607c0 Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Fri, 21 Jun 2024 19:59:46 +0200 Subject: [PATCH] assistant: Fix gutter width (#13373) The gutter width of the assistant panel was wider then expected after #13329 was merged. Release Notes: - N/A --- crates/assistant/src/assistant_panel.rs | 1 + crates/editor/src/editor.rs | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rs index 7ec19ef70e..2279a98ac2 100644 --- a/crates/assistant/src/assistant_panel.rs +++ b/crates/assistant/src/assistant_panel.rs @@ -2253,6 +2253,7 @@ impl ContextEditor { editor.set_show_line_numbers(false, cx); editor.set_show_git_diff_gutter(false, cx); editor.set_show_code_actions(false, cx); + editor.set_show_runnables(false, cx); editor.set_show_wrap_guides(false, cx); editor.set_show_indent_guides(false, cx); editor.set_completion_provider(Box::new(completion_provider)); diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index cde7562b6c..4477fa8bbd 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -484,6 +484,7 @@ pub struct Editor { show_line_numbers: Option, show_git_diff_gutter: Option, show_code_actions: Option, + show_runnables: Option, show_wrap_guides: Option, show_indent_guides: Option, placeholder_text: Option>, @@ -566,6 +567,7 @@ pub struct EditorSnapshot { show_line_numbers: Option, show_git_diff_gutter: Option, show_code_actions: Option, + show_runnables: Option, render_git_blame_gutter: bool, pub display_snapshot: DisplaySnapshot, pub placeholder_text: Option>, @@ -1783,6 +1785,7 @@ impl Editor { show_line_numbers: None, show_git_diff_gutter: None, show_code_actions: None, + show_runnables: None, show_wrap_guides: None, show_indent_guides, placeholder_text: None, @@ -2032,6 +2035,7 @@ impl Editor { show_line_numbers: self.show_line_numbers, show_git_diff_gutter: self.show_git_diff_gutter, show_code_actions: self.show_code_actions, + show_runnables: self.show_runnables, render_git_blame_gutter: self.render_git_blame_gutter(cx), display_snapshot: self.display_map.update(cx, |map, cx| map.snapshot(cx)), scroll_anchor: self.scroll_manager.anchor(), @@ -10175,6 +10179,11 @@ impl Editor { cx.notify(); } + pub fn set_show_runnables(&mut self, show_runnables: bool, cx: &mut ViewContext) { + self.show_runnables = Some(show_runnables); + cx.notify(); + } + pub fn set_show_wrap_guides(&mut self, show_wrap_guides: bool, cx: &mut ViewContext) { self.show_wrap_guides = Some(show_wrap_guides); cx.notify(); @@ -11795,7 +11804,7 @@ impl EditorSnapshot { let gutter_settings = EditorSettings::get_global(cx).gutter; let show_line_numbers = self .show_line_numbers - .unwrap_or_else(|| gutter_settings.line_numbers); + .unwrap_or(gutter_settings.line_numbers); let line_gutter_width = if show_line_numbers { // Avoid flicker-like gutter resizes when the line number gains another digit and only resize the gutter on files with N*10^5 lines. let min_width_for_number_on_gutter = em_width * 4.0; @@ -11806,14 +11815,16 @@ impl EditorSnapshot { let show_code_actions = self .show_code_actions - .unwrap_or_else(|| gutter_settings.code_actions); + .unwrap_or(gutter_settings.code_actions); + + let show_runnables = self.show_runnables.unwrap_or(gutter_settings.runnables); let git_blame_entries_width = self .render_git_blame_gutter .then_some(em_width * GIT_BLAME_GUTTER_WIDTH_CHARS); let mut left_padding = git_blame_entries_width.unwrap_or(Pixels::ZERO); - left_padding += if show_code_actions || gutter_settings.runnables { + left_padding += if show_code_actions || show_runnables { em_width * 3.0 } else if show_git_gutter && show_line_numbers { em_width * 2.0