copilot: Propagate action if suggest_next is not possible. (#3129)

One of our users ran into an issue where typing "true quote" characters
(option-[ for „ and option-] for ‚) was not possible; I've narrowed it
down to a collision with Copilot's NextSuggestion and PreviousSuggestion
action default keybinds. I explicitly did not want to alter the key
bindings, so I've went with a more neutral fix - one that propagates the
keystroke if there's no Copilot action to be taken (user is not using
Copilot etc). Note however that typing true quotes while using a Copilot
is still not possible, as for that we'd have to change a keybind.

Fixes zed-industries/community#2072


Release Notes:
- Fixed Copilot's "Suggest next" and "Suggest previous" actions
colliding with true quotes key bindings (`option-[` and `option-]`). The
keystrokes are now propagated if there's no Copilot action to be taken
at cursor's position.
This commit is contained in:
Piotr Osiewicz 2023-10-15 17:27:36 +02:00 committed by GitHub
parent 2323fd17b0
commit 6f4008ebab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4158,7 +4158,10 @@ impl Editor {
if self.has_active_copilot_suggestion(cx) {
self.cycle_copilot_suggestions(Direction::Next, cx);
} else {
self.refresh_copilot_suggestions(false, cx);
let is_copilot_disabled = self.refresh_copilot_suggestions(false, cx).is_none();
if is_copilot_disabled {
cx.propagate_action();
}
}
}
@ -4170,7 +4173,10 @@ impl Editor {
if self.has_active_copilot_suggestion(cx) {
self.cycle_copilot_suggestions(Direction::Prev, cx);
} else {
self.refresh_copilot_suggestions(false, cx);
let is_copilot_disabled = self.refresh_copilot_suggestions(false, cx).is_none();
if is_copilot_disabled {
cx.propagate_action();
}
}
}