From 6635b6489ba7f156c75ffa80b8ff301f707a2228 Mon Sep 17 00:00:00 2001 From: myk002 Date: Sat, 12 Nov 2022 09:57:32 -0800 Subject: [PATCH] handle commands like ':lua ' --- plugins/hotkeys.cpp | 4 +++- plugins/lua/hotkeys.lua | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/hotkeys.cpp b/plugins/hotkeys.cpp index 8f980cb2b..85c304d82 100644 --- a/plugins/hotkeys.cpp +++ b/plugins/hotkeys.cpp @@ -99,7 +99,9 @@ static void find_active_keybindings(df::viewscreen *screen, bool filtermenu) { auto list = Core::getInstance().ListKeyBindings(sym); for (auto invoke_cmd = list.begin(); invoke_cmd != list.end(); invoke_cmd++) { - if (invoke_cmd->find(":") == string::npos) { + string::size_type colon_pos = invoke_cmd->find(":"); + // colons at location 0 are for commands like ":lua" + if (colon_pos == string::npos || colon_pos == 0) { add_binding_if_valid(sym, *invoke_cmd, screen, filtermenu); } else { diff --git a/plugins/lua/hotkeys.lua b/plugins/lua/hotkeys.lua index bd88fdd89..7a1a39115 100644 --- a/plugins/lua/hotkeys.lua +++ b/plugins/lua/hotkeys.lua @@ -182,6 +182,7 @@ end function MenuScreen:onSelect(_, choice) if not choice or #self.subviews == 0 then return end local first_word = choice.command:trim():split(' +')[1] + if first_word:startswith(':') then first_word = first_word:sub(2) end self.subviews.help.text_to_wrap = helpdb.is_entry(first_word) and helpdb.get_entry_short_help(first_word) or 'Command not found' self.subviews.help_panel:updateLayout()