Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

edit predictions: Don't animate cursor when jumping in eager mode without LSP completions (#24664)

Agus Zubiaga14d9788ba3eb
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index a95d276113d..15414e5b111 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -5457,19 +5457,27 @@ impl Editor {
};
if &accept_keystroke.modifiers == modifiers {
- if let Some(completion) = self.active_inline_completion.as_ref() {
- if self.edit_prediction_preview.start(
- &completion.completion,
- &position_map.snapshot,
- self.selections
- .newest_anchor()
- .head()
- .to_display_point(&position_map.snapshot),
- ) {
- self.request_autoscroll(Autoscroll::fit(), cx);
- self.update_visible_inline_completion(window, cx);
- cx.notify();
- }
+ let Some(completion) = self.active_inline_completion.as_ref() else {
+ return;
+ };
+
+ if !self.edit_prediction_requires_modifier() && !self.has_visible_completions_menu() {
+ return;
+ }
+
+ let transitioned = self.edit_prediction_preview.start(
+ &completion.completion,
+ &position_map.snapshot,
+ self.selections
+ .newest_anchor()
+ .head()
+ .to_display_point(&position_map.snapshot),
+ );
+
+ if transitioned {
+ self.request_autoscroll(Autoscroll::fit(), cx);
+ self.update_visible_inline_completion(window, cx);
+ cx.notify();
}
} else if self.edit_prediction_preview.end(
self.selections