From d1f4b60fa1b639ffc64c7636605aebf37ca67885 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 23 May 2023 17:50:50 +0300 Subject: [PATCH] Allow to disable the new feature --- assets/settings/default.json | 3 +++ crates/editor/src/editor.rs | 2 +- crates/editor/src/editor_settings.rs | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index 246e28cc8e20c57c60179f0bfb2ce572d6c27c42..23599c8dfb1e327d9d842b76fb8c5e2914c23b3f 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -39,6 +39,9 @@ // Whether to pop the completions menu while typing in an editor without // explicitly requesting it. "show_completions_on_input": true, + // Whether to use additional LSP queries to format (and amend) the code after + // every "trigger" symbol input, defined by LSP server capabilities. + "use_on_type_format": true, // Controls whether copilot provides suggestion immediately // or waits for a `copilot::Toggle` "show_copilot_suggestions": true, diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 20116da34f980f7845a15b573a947e578bf51287..a33988dc5d51fa36c2a3fc868002abb9add08b39 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -2123,7 +2123,7 @@ impl Editor { this.change_selections(Some(Autoscroll::fit()), cx, |s| s.select(new_selections)); // When buffer contents is updated and caret is moved, try triggering on type formatting. - if text.len() == 1 { + if settings::get::(cx).use_on_type_format && text.len() == 1 { let input_char = text.chars().next().expect("single char input"); if let Some(on_type_format_task) = this.trigger_on_type_format(input_char, cx) { on_type_format_task.detach_and_log_err(cx); diff --git a/crates/editor/src/editor_settings.rs b/crates/editor/src/editor_settings.rs index 7f01834b161b8f1db75a40145694f1c80e473755..387d4d2c340d2a3bb5b648d8232880de2d8f7fe1 100644 --- a/crates/editor/src/editor_settings.rs +++ b/crates/editor/src/editor_settings.rs @@ -7,6 +7,7 @@ pub struct EditorSettings { pub cursor_blink: bool, pub hover_popover_enabled: bool, pub show_completions_on_input: bool, + pub use_on_type_format: bool, pub scrollbar: Scrollbar, } @@ -30,6 +31,7 @@ pub struct EditorSettingsContent { pub cursor_blink: Option, pub hover_popover_enabled: Option, pub show_completions_on_input: Option, + pub use_on_type_format: Option, pub scrollbar: Option, }