Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

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

Piotr Osiewicz58e9952d7b2a
diff --git a/assets/settings/default.json b/assets/settings/default.json
index 1c759c61543..72e7ea6fea5 100644
--- a/assets/settings/default.json
+++ b/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
},
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index a1c344d8867..298b51d7bd2 100644
--- a/crates/editor/src/editor.rs
+++ b/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
diff --git a/crates/editor/src/editor_settings.rs b/crates/editor/src/editor_settings.rs
index 3aa407d6a02..8a222648382 100644
--- a/crates/editor/src/editor_settings.rs
+++ b/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
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs
index 7716325f31e..592f6a43744 100644
--- a/crates/editor/src/element.rs
+++ b/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(