editor: Do not show inline completion if snippet is active (#20300)

This avoids inline completions being shown (and overriding `<tab>`
behavior) when a snippet is active and the user wants to go through
snippet placeholders with `<tab>`.

Easy to reproduce:

Open a Rust file and use the `tfn` snippet to produce a test function.
Delete the placeholder. Without the change here, the inline provider
would suggest a function name. If you `<tab>`, you accept it, but then
you can't `<tab>` into the function body.

With this change the inline completions are deactivated as long as a
snippet is active.

Closes #19484 

Release Notes:

- Fixed inline completions (Copilot, Supermaven, ...) taking over when a
snippet completion was active. That resulted in `tab` not working to
jump to the next placeholder in the snippet.
This commit is contained in:
Thorsten Ball 2024-11-07 15:34:19 +01:00 committed by GitHub
parent cdd2128311
commit 71aeb6a636
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2498,6 +2498,10 @@ impl Editor {
buffer_position: language::Anchor, buffer_position: language::Anchor,
cx: &AppContext, cx: &AppContext,
) -> bool { ) -> bool {
if !self.snippet_stack.is_empty() {
return false;
}
if let Some(provider) = self.inline_completion_provider() { if let Some(provider) = self.inline_completion_provider() {
if let Some(show_inline_completions) = self.show_inline_completions_override { if let Some(show_inline_completions) = self.show_inline_completions_override {
show_inline_completions show_inline_completions