summaryrefslogtreecommitdiff
path: root/src/keymap_manager.cc
AgeCommit message (Collapse)Author
2024-08-16include headers cleanupAdrià Arrufat
2024-08-12Reduce headers dependency graphMaxime Coste
Move more code into the implementation files to reduce the amount of code pulled by headers.
2024-08-12Extract format implementation to its own fileMaxime Coste
Split it to avoid pulling all string_utils dependencies for just format.
2023-07-20Allow map/unmap during mapping executionJohannes Altmanninger
Commits e49c0fb04 (unmap: fail if the mapping is currently executing, 2023-05-14) 42be0057a (map: fail if key is currently executing, 2023-06-24) fixed potential use-after-free issues. By doing so, it broke configurations that in practice have not triggered any crashes [1] [2]. For example with, set -remove global autocomplete insert hook global InsertCompletionShow .* %{ map window insert <esc> <c-o> } hook global InsertCompletionHide .* %{ unmap window insert <esc> <c-o> } The execution of the <esc> mapping triggers InsertCompletionHide fails at unmapping. This seems legit and I don't see an obvious alternative way to write it (InsertIdle would not be correct though it would work in practice). Fix the regression by allowing map and unmap again while keeping the mappings alive until they have finished executing. Applying map/unmap immediately seems like the most obvious semantics. Alternatively, we could apply them in between key presses. [1]: <https://github.com/kak-lsp/kak-lsp/issues/689> [2]: <https://github.com/alexherbo2/auto-pairs.kak/issues/60>
2023-07-03map: fail if key is currently executingJohannes Altmanninger
If during execution of a mapping, that same mapping is replaced, there is undefined behavior because we destroy a mapping that we are still iterating over. I have been using this mapping inside my kakrc to re-source the kakrc. map global user s %{:source "%val{config}/kakrc"<ret>} -docstring 'source "%val{config}/kakrc"' Now <space>s happens to not trigger undefined behavior because the mapping stays the same. However it triggers an assertion added by Commit e49c0fb04 (unmap: fail if the mapping is currently executing, 2023-05-14), specifically the destructor of ScopedSetBool that guards mapping execution. Fix these by banning map of a key that is executing, just like we did for unmap. Alternative solution: we could allow mapping (and even unmapping) keys at any time and keep them alive by moving them into a trash can, like we do for clients and others.
2023-05-29Refactor KeymapManager to enfore setting is_executing on key iterationMaxime Coste
Add an iterator based remove to HashMap as that was missing. Make KeymapManager responsible for throwing on unmap an executing mapping.
2023-05-25unmap: fail if the mapping is currently executingJohannes Altmanninger
When unmapping a key sequence that is currently executing, we continue executing freed memory which can have weird effects. Let's instead throw an error if that happens. In future we can support unmap in this scenario. Closes #4896
2018-09-23Add a way to unmap all keys of a given mode at onceDelapouite
2018-03-25Unify code that validates identifiers in KakouneMaxime Coste
Session/Client/User modes names are now requiered to be "identifiers" they must be in [a-zA-Z0-9_-]. Option names are the same except they do not allow '-' as they need to be made available through the env vars and '-' is not supported there. Fixes #1946
2018-03-11Handle hyphens in user-mode namesDelapouite
Fix #1921
2018-03-02Remove <scope> from user-modes commandsDelapouite
2018-02-18Small code tweaks regarding user modesMaxime Coste
2018-02-12Add declare-user-mode / enter-user-mode commandsDelapouite
2017-11-24Rename KeyMapInfo → KeymapInfoDelapouite
2017-07-11Preserve order of definition of mappings when listing themMaxime Coste
Fixes #1479 Closes #1494
2017-03-07Replace uses of UnorderedMap with HashMapMaxime Coste
2017-03-03Add docstring support for mappings, and use them in autoinfoMaxime Coste
Fixes #105 Fixes #1100 Closes #1165
2015-03-09ArrayView content is not const anymoreMaxime Coste
As in upcoming std c++ array_view, ArrayView<T> points to mutable data, use ArrayView<const T> or alias ConstArrayView<T> for const data.
2015-01-06Rename memoryview to ArrayViewMaxime Coste
2014-12-17Tweak keymap_manager style, fix missing moveMaxime Coste
2014-12-16Rework hashing, use a more extensible framework similar to n3876 proposalMaxime Coste
std::hash specialization is a pain to work with, stop using that, and just specialize a 'size_t hash_value(const T&)' free function.
2014-11-12Cleanup includesMaxime Coste
2013-10-25Add key mapping supportMaxime Coste