From 1b3140d4ab199814093303cfaa200d6b2ddba214 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 7 May 2025 17:33:42 +0100 Subject: [PATCH] Delete code actions indicator (#30140) This conflicts for space with breakpoints, and seems borderline in terms of utility. We could consider bringing it back in a way that is closer to the cursor, or be content with our right-click menu discovery. Release Notes: - Remove the code actions indicator from the gutter. It is still available from the right click menu, or with the keyboard shortcut. --- assets/settings/default.json | 2 - crates/editor/src/editor.rs | 71 +------------------- crates/editor/src/editor_settings.rs | 5 -- crates/editor/src/element.rs | 99 ---------------------------- 4 files changed, 1 insertion(+), 176 deletions(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index f7bc3a4dc31817c59ea727f5c3c80b39d97d4f46..8b382ffeff7238aca1937f350e70a4a3d80e64eb 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -370,8 +370,6 @@ "gutter": { // Whether to show line numbers in the gutter. "line_numbers": true, - // Whether to show code action buttons in the gutter. - "code_actions": true, // Whether to show runnables buttons in the gutter. "runnables": true, // Whether to show breakpoints in the gutter. diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 16b259629e0736cbf781450dd0659810b9063755..06d86bb9880fa978b197d13b5c1f938bc10237d4 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1020,7 +1020,6 @@ pub struct EditorSnapshot { show_gutter: bool, show_line_numbers: Option, show_git_diff_gutter: Option, - show_code_actions: Option, show_runnables: Option, show_breakpoints: Option, git_blame_gutter_max_author_length: Option, @@ -2212,7 +2211,6 @@ impl Editor { show_gutter: self.show_gutter, 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, show_breakpoints: self.show_breakpoints, git_blame_gutter_max_author_length, @@ -6700,69 +6698,6 @@ impl Editor { Some(self.edit_prediction_provider.as_ref()?.provider.clone()) } - fn render_code_actions_indicator( - &self, - _style: &EditorStyle, - row: DisplayRow, - is_active: bool, - breakpoint: Option<&(Anchor, Breakpoint)>, - cx: &mut Context, - ) -> Option { - let color = Color::Muted; - let position = breakpoint.as_ref().map(|(anchor, _)| *anchor); - let show_tooltip = !self.context_menu_visible(); - - if self.available_code_actions.is_some() { - Some( - IconButton::new("code_actions_indicator", ui::IconName::Bolt) - .shape(ui::IconButtonShape::Square) - .icon_size(IconSize::XSmall) - .icon_color(color) - .toggle_state(is_active) - .when(show_tooltip, |this| { - this.tooltip({ - let focus_handle = self.focus_handle.clone(); - move |window, cx| { - Tooltip::for_action_in( - "Toggle Code Actions", - &ToggleCodeActions { - deployed_from_indicator: None, - quick_launch: false, - }, - &focus_handle, - window, - cx, - ) - } - }) - }) - .on_click(cx.listener(move |editor, e: &ClickEvent, window, cx| { - let quick_launch = e.down.button == MouseButton::Left; - window.focus(&editor.focus_handle(cx)); - editor.toggle_code_actions( - &ToggleCodeActions { - deployed_from_indicator: Some(row), - quick_launch, - }, - window, - cx, - ); - })) - .on_right_click(cx.listener(move |editor, event: &ClickEvent, window, cx| { - editor.set_breakpoint_context_menu( - row, - position, - event.down.position, - window, - cx, - ); - })), - ) - } else { - None - } - } - fn clear_tasks(&mut self) { self.tasks.clear() } @@ -20093,10 +20028,6 @@ impl EditorSnapshot { 0.0.into() }; - let show_code_actions = self - .show_code_actions - .unwrap_or(gutter_settings.code_actions); - let show_runnables = self.show_runnables.unwrap_or(gutter_settings.runnables); let show_breakpoints = self.show_breakpoints.unwrap_or(gutter_settings.breakpoints); @@ -20122,7 +20053,7 @@ impl EditorSnapshot { let mut left_padding = git_blame_entries_width.unwrap_or(Pixels::ZERO); left_padding += if !is_singleton { em_width * 4.0 - } else if show_code_actions || show_runnables || show_breakpoints { + } else if show_runnables || show_breakpoints { em_width * 3.0 } else if show_git_gutter && show_line_numbers { em_width * 2.0 diff --git a/crates/editor/src/editor_settings.rs b/crates/editor/src/editor_settings.rs index 072f517bec19dc4bbc8cdf32008027aee3e09877..49c6e740a701993c2d1e36c1eac939d52aeadf7a 100644 --- a/crates/editor/src/editor_settings.rs +++ b/crates/editor/src/editor_settings.rs @@ -119,7 +119,6 @@ pub struct Scrollbar { #[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] pub struct Gutter { pub line_numbers: bool, - pub code_actions: bool, pub runnables: bool, pub breakpoints: bool, pub folds: bool, @@ -468,10 +467,6 @@ pub struct GutterContent { /// /// Default: true pub line_numbers: Option, - /// Whether to show code action buttons in the gutter. - /// - /// Default: true - pub code_actions: Option, /// Whether to show runnable buttons in the gutter. /// /// Default: true diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index f7540f3ff9c7f885d89281b36ae5081e4914c8e1..9188a8a5a3a6a01eb6a73399588a5968c8730af0 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -2409,52 +2409,6 @@ impl EditorElement { elements } - fn layout_code_actions_indicator( - &self, - line_height: Pixels, - newest_selection_head: DisplayPoint, - scroll_pixel_position: gpui::Point, - gutter_dimensions: &GutterDimensions, - gutter_hitbox: &Hitbox, - breakpoint_points: &mut HashMap, - display_hunks: &[(DisplayDiffHunk, Option)], - window: &mut Window, - cx: &mut App, - ) -> Option { - let mut active = false; - let mut button = None; - let row = newest_selection_head.row(); - self.editor.update(cx, |editor, cx| { - if let Some(crate::CodeContextMenu::CodeActions(CodeActionsMenu { - deployed_from_indicator, - .. - })) = editor.context_menu.borrow().as_ref() - { - active = deployed_from_indicator.map_or(true, |indicator_row| indicator_row == row); - }; - - let breakpoint = breakpoint_points.get(&row); - button = editor.render_code_actions_indicator(&self.style, row, active, breakpoint, cx); - }); - - let button = button?; - breakpoint_points.remove(&row); - - let button = prepaint_gutter_button( - button, - row, - line_height, - gutter_dimensions, - scroll_pixel_position, - gutter_hitbox, - display_hunks, - window, - cx, - ); - - Some(button) - } - fn calculate_relative_line_numbers( &self, snapshot: &EditorSnapshot, @@ -4857,10 +4811,6 @@ impl EditorElement { for test_indicator in layout.test_indicators.iter_mut() { test_indicator.paint(window, cx); } - - if let Some(indicator) = layout.code_actions_indicator.as_mut() { - indicator.paint(window, cx); - } }); } @@ -7545,7 +7495,6 @@ impl Element for EditorElement { let gutter_settings = EditorSettings::get_global(cx).gutter; - let mut code_actions_indicator = None; if let Some(newest_selection_head) = newest_selection_head { let newest_selection_point = newest_selection_head.to_point(&snapshot.display_snapshot); @@ -7564,52 +7513,6 @@ impl Element for EditorElement { window, cx, ); - - let show_code_actions = snapshot - .show_code_actions - .unwrap_or(gutter_settings.code_actions); - if show_code_actions { - let newest_selection_point = - newest_selection_head.to_point(&snapshot.display_snapshot); - if !snapshot - .is_line_folded(MultiBufferRow(newest_selection_point.row)) - { - let buffer = snapshot.buffer_snapshot.buffer_line_for_row( - MultiBufferRow(newest_selection_point.row), - ); - if let Some((buffer, range)) = buffer { - let buffer_id = buffer.remote_id(); - let row = range.start.row; - let has_test_indicator = self - .editor - .read(cx) - .tasks - .contains_key(&(buffer_id, row)); - - let has_expand_indicator = row_infos - .get( - (newest_selection_head.row() - start_row).0 - as usize, - ) - .is_some_and(|row_info| row_info.expand_info.is_some()); - - if !has_test_indicator && !has_expand_indicator { - code_actions_indicator = self - .layout_code_actions_indicator( - line_height, - newest_selection_head, - scroll_pixel_position, - &gutter_dimensions, - &gutter_hitbox, - &mut breakpoint_rows, - &display_hunks, - window, - cx, - ); - } - } - } - } } } @@ -7818,7 +7721,6 @@ impl Element for EditorElement { mouse_context_menu, test_indicators, breakpoints, - code_actions_indicator, crease_toggles, crease_trailers, tab_invisible, @@ -7989,7 +7891,6 @@ pub struct EditorLayout { cursors: Vec<(DisplayPoint, Hsla)>, visible_cursors: Vec, selections: Vec<(PlayerColor, Vec)>, - code_actions_indicator: Option, test_indicators: Vec, breakpoints: Vec, crease_toggles: Vec>,