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: Prefer keybinding with least modifiers when not in conflict mode (#24812)

Agus Zubiaga16ffddf48d25
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 0da2031f887..dbc9b0616fc 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -1617,6 +1617,7 @@ impl Editor {
) -> AcceptEditPredictionBinding {
let key_context = self.key_context_internal(true, window, cx);
let in_conflict = self.edit_prediction_in_conflict();
+
AcceptEditPredictionBinding(
window
.bindings_for_action_in_context(&AcceptEditPrediction, key_context)
@@ -1629,7 +1630,12 @@ impl Editor {
.map_or(false, |keystroke| keystroke.modifiers.modified())
})
.rev()
- .next(),
+ .min_by_key(|binding| {
+ binding
+ .keystrokes()
+ .first()
+ .map_or(u8::MAX, |k| k.modifiers.number_of_modifiers())
+ }),
)
}