summaryrefslogtreecommitdiff
path: root/src/input_handler.hh
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2022-08-29 08:00:53 +0200
committerJohannes Altmanninger <aclopte@gmail.com>2023-06-17 11:21:41 +0200
commit163eb6dbc6758e84f8ce107632777fd06c8ac92d (patch)
tree47ea779066257f8f2f386f34111ff85e3f4b25fc /src/input_handler.hh
parent6563b820929772a32ce1afe1d9fce1cc5d1faf2c (diff)
Disable history only for prompts that are never shown in the UI
My terminal allows to map <c-[> and <esc> independently. I like to use <c-[> as escape key so I have this mapping: map global prompt <c-[> <esc> Unfortunately, this is not equivalent to <esc>. Since mappings are run with history disabled, <c-[> will not add the command to the prompt history. So disabling command history inside mappings is wrong in case the command prompt was created before mapping execution. The behavior should be: "a prompt that is both created and closed inside a noninteractive context does not add to prompt history", where "noninteractive" means inside a mapping, hook, command, execute-keys or evaluate-commands. Implement this behavior, it should better meet user expectations. Scripts can always use "set-register" to add to history. Here are my test cases: 1. Basic regression test (needs above mapping): :nop should be added to history<c-[> --- 2. Create the prompt in a noninteractive context: :exec %{:} now we're back in the interactive context, so we can type: nop should be added to history<ret> --- 3. To check if it works for nested prompts, first set up this mapping. map global prompt <c-j> '<a-semicolon>:nop should NOT be added to history<ret>' map global prompt <c-h> '<a-semicolon>:nop should be added to history first' Then type :nop should be added to history second<c-j><c-h><ret><ret> the inner command run by <c-j> should not be added to history because it only existed in a noninteractive context. --- See also the discussion https://github.com/mawww/kakoune/pull/4692 We could automate the tests if we had a test setup that allowed feeding interactive key input into Kakoune instead of using "execute-commands". Some projects use tmux, or maybe we can mock the terminal.
Diffstat (limited to 'src/input_handler.hh')
-rw-r--r--src/input_handler.hh1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/input_handler.hh b/src/input_handler.hh
index b7e53aaf..4a776e84 100644
--- a/src/input_handler.hh
+++ b/src/input_handler.hh
@@ -83,6 +83,7 @@ public:
Face prompt_face, PromptFlags flags, char history_register,
PromptCompleter completer, PromptCallback callback);
void set_prompt_face(Face prompt_face);
+ bool history_enabled() const;
// enter menu mode, callback is called on each selection change,
// abort or validation with corresponding MenuEvent value