Skip to content

Commit

Permalink
edit predictions: Prefer keybinding with least modifiers when not in …
Browse files Browse the repository at this point in the history
…conflict mode (zed-industries#24812)

This workaround a gpui issue where we don't pick the right keybinding

Release Notes:

- N/A
  • Loading branch information
agu-z authored Feb 13, 2025
1 parent 2f741c8 commit 16ffddf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/editor/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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())
}),
)
}

Expand Down

0 comments on commit 16ffddf

Please sign in to comment.