From a36473f4bb3c7ec31cfba638a9cbdfd2b6efb9e8 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 31 Jul 2022 11:19:48 +0200 Subject: Do not record prompt history when executing user mode mappings Commit 217dd6a1d (Disable history when executing maps, 2015-11-10) made it so with map global normal X %{:echo 123} X does not add to prompt history (%reg{:}). Unfortunately this behavior was not extended to mappings in the "user" keymap, nor to mappings in custom user modes. In my experience, not adding to history is almost always the expected behavior for mappings. Most users achieve this by adding a leading space: map global user X %{: echo 123} but that's awkward. We should have good defaults (no nnoremap) and map should work the same way across all modes. Fix this by also disabling history when executing user mappings. This is a breaking change but I think it only breaks hypothetical scenarios. I found some uses where user mappings add to history but none of them looks intentional. https://github.com/Delapouite/dot-in-the-sky/blob/f702a641d119fba558c06b24e5aba0ac73269076/.config/kak/kakrc#L169 https://github.com/mawww/config/blob/604ef1c1c2f4722505d3d29a4fc95e763a1fddbb/kakrc#L96 https://github.com/SolitudeSF/dot/blob/d22e7d6f681091fc3737fe460802f6d818bb7d18/kak/kakrc#L71 https://grep.app/search?q=map%20%28global%7Cbuffer%7Cwindow%29%20user%20.%2A%5B%21%3A/%5D%5B%5E%20%5D.%2A%3Cret%3E®exp=true --- src/commands.cc | 1 + src/normal.cc | 1 + 2 files changed, 2 insertions(+) (limited to 'src') diff --git a/src/commands.cc b/src/commands.cc index f07c768b..d9f2500a 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -2620,6 +2620,7 @@ void enter_user_mode(Context& context, String mode_name, KeymapMode mode, bool l auto& mapping = context.keymaps().get_mapping(key, mode); ScopedSetBool disable_keymaps(context.keymaps_disabled()); + ScopedSetBool disable_history(context.history_disabled()); InputHandler::ScopedForceNormal force_normal{context.input_handler(), {}}; diff --git a/src/normal.cc b/src/normal.cc index 09aad6f8..68a5fd6f 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -2014,6 +2014,7 @@ void exec_user_mappings(Context& context, NormalParams params) auto& mapping = context.keymaps().get_mapping(key, KeymapMode::User); ScopedSetBool disable_keymaps(context.keymaps_disabled()); + ScopedSetBool disable_history(context.history_disabled()); InputHandler::ScopedForceNormal force_normal{context.input_handler(), params}; -- cgit v1.2.3