inline completions: Add action to toggle inline completions (#16947)

This adds a new action: `editor: toggle inline completions`.

It allows users to toggle inline completions on/off for the current
buffer.

That toggling is not persistent and when the editor is closed, it's
gone.

That makes it easy to disable inline completions for a single text
buffer, for example, even if you want them on for other buffers.

When toggling on/off, the toggling also overwrites any language
settings. So if you have inline completions disabled for Go buffers,
toggling them on takes precedence over those settings.


Release Notes:

- Added a new editor action to allow toggling inline completions
(Copilot, Supermaven) on and off for the current buffer, taking
precedence over any settings.

Co-authored-by: Antonio <antonio@zed.dev>
This commit is contained in:
Thorsten Ball
2024-08-27 15:51:57 +02:00
committed by GitHub
co-authored by Antonio
parent 5586397f95
commit ad43bbbf5e
9 changed files with 56 additions and 16 deletions
+1 -1
View File
@@ -1136,7 +1136,7 @@ impl InlineAssistant {
editor.set_show_gutter(false, cx);
editor.scroll_manager.set_forbid_vertical_scroll(true);
editor.set_read_only(true);
editor.set_show_inline_completions(false);
editor.set_show_inline_completions(Some(false), cx);
editor.highlight_rows::<DeletedLines>(
Anchor::min()..=Anchor::max(),
Some(cx.theme().status().deleted_background),
+2 -2
View File
@@ -495,7 +495,7 @@ impl PromptLibrary {
editor.set_text(prompt_metadata.title.unwrap_or_default(), cx);
if prompt_id.is_built_in() {
editor.set_read_only(true);
editor.set_show_inline_completions(false);
editor.set_show_inline_completions(Some(false), cx);
}
editor
});
@@ -510,7 +510,7 @@ impl PromptLibrary {
let mut editor = Editor::for_buffer(buffer, None, cx);
if prompt_id.is_built_in() {
editor.set_read_only(true);
editor.set_show_inline_completions(false);
editor.set_show_inline_completions(Some(false), cx);
}
editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx);
editor.set_show_gutter(false, cx);
+1 -1
View File
@@ -78,7 +78,7 @@ impl WorkflowStepView {
editor.set_show_wrap_guides(false, cx);
editor.set_show_indent_guides(false, cx);
editor.set_read_only(true);
editor.set_show_inline_completions(false);
editor.set_show_inline_completions(Some(false), cx);
editor.insert_blocks(
[
BlockProperties {