tasks: Allow disabling runnables in the gutter (#13329)

Piotr Osiewicz created

Runnables can now be disabled with:
```
  "gutter": {
    "runnables": false
  }
```
Fixes #13280



Release Notes:

- Added `gutter.runnables` setting that controls whether runnable
indicators are displayed in the gutter.

Change summary

assets/settings/default.json         |  2 ++
crates/editor/src/editor.rs          |  7 ++++++-
crates/editor/src/editor_settings.rs |  5 +++++
crates/editor/src/element.rs         | 20 ++++++++++++--------
4 files changed, 25 insertions(+), 9 deletions(-)

Detailed changes

assets/settings/default.json 🔗

@@ -231,6 +231,8 @@
     "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 fold buttons in the gutter.
     "folds": true
   },

crates/editor/src/editor.rs 🔗

@@ -8247,6 +8247,10 @@ impl Editor {
     }
 
     fn refresh_runnables(&mut self, cx: &mut ViewContext<Self>) -> Task<()> {
+        if !EditorSettings::get_global(cx).gutter.runnables {
+            self.clear_tasks();
+            return Task::ready(());
+        }
         let project = self.project.clone();
         cx.spawn(|this, mut cx| async move {
             let Ok(display_snapshot) = this.update(&mut cx, |this, cx| {
@@ -11017,6 +11021,7 @@ impl Editor {
     }
 
     fn settings_changed(&mut self, cx: &mut ViewContext<Self>) {
+        self.tasks_update_task = Some(self.refresh_runnables(cx));
         self.refresh_inline_completion(true, cx);
         self.refresh_inlay_hints(
             InlayHintRefreshReason::SettingsChange(inlay_hint_settings(
@@ -11790,7 +11795,7 @@ impl EditorSnapshot {
             .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 {
+        left_padding += if show_code_actions || gutter_settings.runnables {
             em_width * 3.0
         } else if show_git_gutter && show_line_numbers {
             em_width * 2.0

crates/editor/src/editor_settings.rs 🔗

@@ -84,6 +84,7 @@ pub struct Scrollbar {
 pub struct Gutter {
     pub line_numbers: bool,
     pub code_actions: bool,
+    pub runnables: bool,
     pub folds: bool,
 }
 
@@ -255,6 +256,10 @@ pub struct GutterContent {
     ///
     /// Default: true
     pub code_actions: Option<bool>,
+    /// Whether to show runnable buttons in the gutter.
+    ///
+    /// Default: true
+    pub runnables: Option<bool>,
     /// Whether to show fold buttons in the gutter.
     ///
     /// Default: true

crates/editor/src/element.rs 🔗

@@ -4931,14 +4931,18 @@ impl Element for EditorElement {
                         }
                     }
 
-                    let test_indicators = self.layout_run_indicators(
-                        line_height,
-                        scroll_pixel_position,
-                        &gutter_dimensions,
-                        &gutter_hitbox,
-                        &snapshot,
-                        cx,
-                    );
+                    let test_indicators = if gutter_settings.runnables {
+                        self.layout_run_indicators(
+                            line_height,
+                            scroll_pixel_position,
+                            &gutter_dimensions,
+                            &gutter_hitbox,
+                            &snapshot,
+                            cx,
+                        )
+                    } else {
+                        vec![]
+                    };
 
                     if !cx.has_active_drag() {
                         self.layout_hover_popovers(