From d5cc3fea3d59c3b35f1113bec4cb2657d64cfc2a Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 25 Feb 2022 16:13:53 -0700 Subject: [PATCH] Implement Debug for keymap::MatchResult Helpful when debugging issues with keystroke dispatch. Co-Authored-By: Max Brunsfeld --- crates/gpui/src/keymap.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/gpui/src/keymap.rs b/crates/gpui/src/keymap.rs index 848cb8fe39..05fbd5b74b 100644 --- a/crates/gpui/src/keymap.rs +++ b/crates/gpui/src/keymap.rs @@ -76,6 +76,19 @@ pub enum MatchResult { Action(Box), } +impl Debug for MatchResult { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MatchResult::None => f.debug_struct("MatchResult::None").finish(), + MatchResult::Pending => f.debug_struct("MatchResult::Pending").finish(), + MatchResult::Action(action) => f + .debug_tuple("MatchResult::Action") + .field(&action.name()) + .finish(), + } + } +} + impl Matcher { pub fn new(keymap: Keymap) -> Self { Self {