From 159d3ab00c49a3984f02d5008dfeb99548ba3188 Mon Sep 17 00:00:00 2001 From: Kay Simmons Date: Sat, 18 Feb 2023 13:49:08 -0800 Subject: [PATCH] Add comment explaining push_keystroke --- crates/gpui/src/keymap_matcher.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/gpui/src/keymap_matcher.rs b/crates/gpui/src/keymap_matcher.rs index 93f5d0934a..26da099a9f 100644 --- a/crates/gpui/src/keymap_matcher.rs +++ b/crates/gpui/src/keymap_matcher.rs @@ -60,6 +60,16 @@ impl KeymapMatcher { !self.pending_keystrokes.is_empty() } + /// Pushes a keystroke onto the matcher. + /// The result of the new keystroke is returned: + /// MatchResult::None => + /// No match is valid for this key given any pending keystrokes. + /// MatchResult::Pending => + /// There exist bindings which are still waiting for more keys. + /// MatchResult::Complete(matches) => + /// 1 or more bindings have recieved the necessary key presses. + /// The order of the matched actions is by order in the keymap file first and + /// position of the matching view second. pub fn push_keystroke( &mut self, keystroke: Keystroke, @@ -117,6 +127,8 @@ impl KeymapMatcher { } if !matched_bindings.is_empty() { + // Collect the sorted matched bindings into the final vec for ease of use + // Matched bindings are in order by precedence MatchResult::Matches(matched_bindings.into_values().flatten().collect()) } else if any_pending { MatchResult::Pending