indent guides: Toggle action (#12203)

Added a new action `editor: Toggle indent guides`, to show/hide indent
guides

Release Notes:

- N/A
This commit is contained in:
Bennet Bo Fenner
2024-05-23 16:45:20 +02:00
committed by GitHub
parent feea607bac
commit 58a3ba02c6
4 changed files with 24 additions and 10 deletions
+16
View File
@@ -9640,6 +9640,22 @@ impl Editor {
cx.notify();
}
pub fn toggle_indent_guides(&mut self, _: &ToggleIndentGuides, cx: &mut ViewContext<Self>) {
let currently_enabled = self.should_show_indent_guides(cx);
self.show_indent_guides = Some(!currently_enabled);
cx.notify();
}
fn should_show_indent_guides(&self, cx: &mut ViewContext<Self>) -> bool {
self.show_indent_guides.unwrap_or_else(|| {
self.buffer
.read(cx)
.settings_at(0, cx)
.indent_guides
.enabled
})
}
pub fn toggle_line_numbers(&mut self, _: &ToggleLineNumbers, cx: &mut ViewContext<Self>) {
let mut editor_settings = EditorSettings::get_global(cx).clone();
editor_settings.gutter.line_numbers = !editor_settings.gutter.line_numbers;