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

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.
This commit is contained in:
Piotr Osiewicz 2024-06-20 21:07:45 +02:00 committed by GitHub
parent 25c8cf0c5c
commit 58e9952d7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 9 deletions

View File

@ -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
},

View File

@ -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

View File

@ -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

View File

@ -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(