Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
editor: Add an option to disable rounded corners for text selection (#36987)
Ivan Trubach3315fd94d27f
diff --git a/assets/settings/default.json b/assets/settings/default.jsonindex b15eb6e5ce8..2aec3aa7b9d 100644--- a/assets/settings/default.json+++ b/assets/settings/default.json@@ -223,6 +223,8 @@"current_line_highlight": "all",// Whether to highlight all occurrences of the selected text in an editor."selection_highlight": true,+ // Whether the text selection should have rounded corners.+ "rounded_selection": true,// The debounce delay before querying highlights from the language// server based on the current cursor location."lsp_highlight_debounce": 75,diff --git a/crates/editor/src/editor_settings.rs b/crates/editor/src/editor_settings.rsindex c2baa9de024..084c4eb5c61 100644--- a/crates/editor/src/editor_settings.rs+++ b/crates/editor/src/editor_settings.rs@@ -17,6 +17,7 @@ pub struct EditorSettings {pub cursor_shape: Option<CursorShape>,pub current_line_highlight: CurrentLineHighlight,pub selection_highlight: bool,+ pub rounded_selection: bool,pub lsp_highlight_debounce: u64,pub hover_popover_enabled: bool,pub hover_popover_delay: u64,@@ -441,6 +442,10 @@ pub struct EditorSettingsContent {////// Default: truepub selection_highlight: Option<bool>,+ /// Whether the text selection should have rounded corners.+ ///+ /// Default: true+ pub rounded_selection: Option<bool>,/// The debounce delay before querying highlights from the language/// server based on the current cursor location.///@@ -794,6 +799,7 @@ impl Settings for EditorSettings {"editor.selectionHighlight",&mut current.selection_highlight,);+ vscode.bool_setting("editor.roundedSelection", &mut current.rounded_selection);vscode.bool_setting("editor.hover.enabled", &mut current.hover_popover_enabled);vscode.u64_setting("editor.hover.delay", &mut current.hover_popover_delay);diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rsindex ca6eac080e6..f384afa1ae9 100644--- a/crates/editor/src/element.rs+++ b/crates/editor/src/element.rs@@ -6063,7 +6063,7 @@ impl EditorElement {};self.paint_lines_background(layout, window, cx);- let invisible_display_ranges = self.paint_highlights(layout, window);+ let invisible_display_ranges = self.paint_highlights(layout, window, cx);self.paint_document_colors(layout, window);self.paint_lines(&invisible_display_ranges, layout, window, cx);self.paint_redactions(layout, window);@@ -6085,6 +6085,7 @@ impl EditorElement {&mut self,layout: &mut EditorLayout,window: &mut Window,+ cx: &mut App,) -> SmallVec<[Range<DisplayPoint>; 32]> {window.paint_layer(layout.position_map.text_hitbox.bounds, |window| {let mut invisible_display_ranges = SmallVec::<[Range<DisplayPoint>; 32]>::new();@@ -6101,7 +6102,11 @@ impl EditorElement {);}- let corner_radius = 0.15 * layout.position_map.line_height;+ let corner_radius = if EditorSettings::get_global(cx).rounded_selection {+ 0.15 * layout.position_map.line_height+ } else {+ Pixels::ZERO+ };for (player_color, selections) in &layout.selections {for selection in selections.iter() {diff --git a/crates/terminal_view/src/terminal_element.rs b/crates/terminal_view/src/terminal_element.rsindex 56715b604ee..5bbf5ad36b3 100644--- a/crates/terminal_view/src/terminal_element.rs+++ b/crates/terminal_view/src/terminal_element.rs@@ -1,4 +1,4 @@-use editor::{CursorLayout, HighlightedRange, HighlightedRangeLine};+use editor::{CursorLayout, EditorSettings, HighlightedRange, HighlightedRangeLine};use gpui::{AbsoluteLength, AnyElement, App, AvailableSpace, Bounds, ContentMask, Context, DispatchPhase,Element, ElementId, Entity, FocusHandle, Font, FontFeatures, FontStyle, FontWeight,@@ -1257,12 +1257,17 @@ impl Element for TerminalElement {if let Some((start_y, highlighted_range_lines)) =to_highlighted_range_lines(relative_highlighted_range, layout, origin){+ let corner_radius = if EditorSettings::get_global(cx).rounded_selection {+ 0.15 * layout.dimensions.line_height+ } else {+ Pixels::ZERO+ };let hr = HighlightedRange {start_y,line_height: layout.dimensions.line_height,lines: highlighted_range_lines,color: *color,- corner_radius: 0.15 * layout.dimensions.line_height,+ corner_radius: corner_radius,};hr.paint(true, bounds, window);}diff --git a/docs/src/configuring-zed.md b/docs/src/configuring-zed.mdindex 2b1d801f801..e245b3ca2fa 100644--- a/docs/src/configuring-zed.md+++ b/docs/src/configuring-zed.md@@ -685,6 +685,12 @@ List of `string` values- Setting: `selection_highlight`- Default: `true`+## Rounded Selection++- Description: Whether the text selection should have rounded corners.+- Setting: `rounded_selection`+- Default: `true`+## Cursor Blink- Description: Whether or not the cursor blinks.