From 7015b403bac0ff7bd500d7499f0e5d27f2a9f1a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ondr=CC=8Cej=20S=CC=8Cebek?= Date: Sat, 29 Jun 2024 13:08:37 +0200 Subject: [PATCH] Replace keybinding name fromJust with maybe --- src/Brick/Keybindings/Pretty.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Brick/Keybindings/Pretty.hs b/src/Brick/Keybindings/Pretty.hs index b7afae6..615bee6 100644 --- a/src/Brick/Keybindings/Pretty.hs +++ b/src/Brick/Keybindings/Pretty.hs @@ -25,7 +25,6 @@ where import Brick import Data.List (sort, intersperse) -import Data.Maybe (fromJust) #if !(MIN_VERSION_base(4,11,0)) import Data.Monoid ((<>)) #endif @@ -124,19 +123,19 @@ mkKeybindEventHelp kc h = ByKey b -> (Comment "(non-customizable key)", [Verbatim $ ppBinding b]) ByEvent ev -> - let name = fromJust $ keyEventName (keyConfigEvents kc) ev + let name = maybe (Comment "(unnamed)") Verbatim $ keyEventName (keyConfigEvents kc) ev in case lookupKeyConfigBindings kc ev of Nothing -> if not (null (allDefaultBindings kc ev)) - then (Verbatim name, Verbatim <$> ppBinding <$> allDefaultBindings kc ev) - else (Verbatim name, unbound) + then (name, Verbatim <$> ppBinding <$> allDefaultBindings kc ev) + else (name, unbound) Just Unbound -> - (Verbatim name, unbound) + (name, unbound) Just (BindingList bs) -> let result = if not (null bs) then Verbatim <$> ppBinding <$> bs else unbound - in (Verbatim name, result) + in (name, result) in (label, handlerDescription $ kehHandler h, evText) -- | Build a 'Widget' displaying key binding information for a single