summaryrefslogtreecommitdiff
path: root/src/hook_manager.cc
AgeCommit message (Collapse)Author
2025-07-08Replace on_scope_end with CTAD with OnScopeEnd directlyMaxime Coste
2025-07-08Replace std::unique_ptr with a custom implementationMaxime Coste
<memory> is a costly header we can avoid by just implementing UniquePtr ourselves, which is a pretty straightforward in modern C++, this saves around 10% of the compilation time here.
2025-03-24Fix prompt history recording when using mapped keysJohannes Altmanninger
Commit e3122ab2c (Refactor prompt history handling, 2023-07-05) was a nice simplification but it breaks a rare edge case. It suppresses history recording if all keys the prompt receives were synthesized. That's not quite the right criteria: it means that if prompt is created, edited and and executed, all via mapped keys, we fail to add to history. The criteria should rather be something like "if all keys the prompt receives came from synthesized events". Make it so. This allows us to get rid of the "noninteractive" nested bool that was only used for disabling history.
2024-08-16include headers cleanupAdriĆ  Arrufat
2024-08-12Move debug utils to debug.hh/debug.ccMaxime Coste
Lots of code includes buffer_utils.hh just for write_to_debug_buffer which pulls many unnecessary dependencies. Reorganise to reduce compile times.
2023-08-13Add a ProfileScope helper class to replace most profiling usesMaxime Coste
2023-06-17Rename "disable_history" stack state to "noninteractive"Johannes Altmanninger
The commit after next will fix a bug where we wrongly disable prompt history in some scenarios. The root cause is that life span of "disable_history" does not model when we actually want to disable history. Let's rename the state variable to "noninteractive". It's set whenever we are executing a hook, mapping or command. Note that it's also active inside ":prompt"'s callback, which doesn't play well with the new name :(
2023-02-14Immediately execute ModuleLoaded hooks for already loaded modulesMaxime Coste
This is trickier than expected because ModuleLoaded hooks can (as any other hooks) use arbitrary regular expressions for their filter. Fixes #4841
2020-05-29Add a range based remove_if overloadMaxime Coste
2019-04-15Support named captures in hooksMaxime Coste
Fixes #2857
2019-02-17Fix uses of std::remove_ifMaxime Coste
std::remove_if is not std::partition, it makes no guarantees on the state of the objects past the new end (they usually are in a moved-from state).
2018-12-09Gather the list of hooks to run before running the parentMaxime Coste
This will prevent hooks added by the parent hook manager to be gathered, as was decided during the discussion for #2603
2018-10-23Refactor Hook management to have a well defined list of hooksMaxime Coste
Hooks are now an enum class instead of passing strings around.
2018-09-12Change remove-hooks to take a regular expressionMaxime Coste
All hooks whose group match this regex will be removed. Fixes #2380.
2018-09-09src: Check that `Once` hooks to remove existFrank LENORMAND
Fixes #2370.
2018-08-16Add a test case for -once hooks and code style tweaksMaxime Coste
2018-08-06src: Allow hooks to be run only onceFrank LENORMAND
This commit implements the -once flag on the `:hook` command, which automatically removes a hook after it was run, to avoid having to declare a group and remove it in the hook implementation. Closes #2277
2018-05-26Do not expose C++ typeid().name to user facing errors on wrong option typeMaxime Coste
Fixes #2079
2018-04-26Add a -always switch to hook command to ignore hooks disabledMaxime Coste
Hooks specified as always will run regardless of the hook disabled status.
2018-04-07Make FaceRegistry scopedMaxime Coste
set-face now takes a scope argument, and faces can be overridden on a buffer or window basis. colorscheme apply on global scope, which should be good enough for now. Fixes #1411
2017-11-25Small formating tweakMaxime Coste
2017-10-06Move HookManager::Hook definition in the cppMaxime Coste
This avoids including regex.hh in the header.
2017-08-29Rename containers.hh to ranges.hh (and Container to Range)Maxime Coste
2017-06-07Use microseconds instead of milliseconds for built-in profilingMaxime Coste
2017-06-07Fix memory errors due to sharing the MatchResults in the Hooks structMaxime Coste
A hook execution triggered by another hook execution would change the shared MatchResults object, which is a wrong behaviour and makes it point to dead string data.
2017-06-07Move hook executing logic into HookManagerMaxime Coste
The existing HookManager was able to run arbitrary hook functions, but in practice was only used for user provided textual hooks. That separation was causing some suboptimal performances, by moving that logic directly in the hook manager we can improve hook filtering performance which is a big part of startup time when opening lots of files.
2017-06-07Avoid expensive copies of Hooks in HookManager::run_hooksMaxime Coste
Use a deferred deletion mechanism to ensure hooks are kept alive for the duration of run_hooks.
2017-06-07Use a vector instead of a hash map to store hooksMaxime Coste
2017-03-16Try to clean up option include a bitMaxime Coste
2017-03-07Replace IdMap with HashMapMaxime Coste
2017-02-19Fix handling of disabled_hooks regexMaxime Coste
2017-02-19Copy the list of hooks to run before iterating on them and running themMaxime Coste
Running hooks could result in the hook list getting mutated, leading to potential crashes. Fixes #1222
2017-02-19Small naming tweak in HookManagerMaxime Coste
2016-09-26Make hook disabling work for all hooks, not only user hooksMaxime Coste
Fixes #823
2016-07-24Introduce chrono.hhMaxime Coste
2016-07-11Do not throw when recursive hook calls are detectedMaxime Coste
Running hooks is non critical, and should never `fail` as far as caller is concerned.
2016-06-27Detect recursive hook run and abort in that caseMaxime Coste
Fixes #709
2016-03-17Write the hook parameter in the debug buffer on error in hookMaxime Coste
2016-03-08Rework container helpers, use pipe syntax and cleanup implementationMaxime Coste
use 'container | filter(func) | reverse() | transform(func)' instead of 'transform(reverse(filter(container), func), func)' to express container transformations.
2015-11-21Add a profiling debug flag to get timings for hooks/shell evalMaxime Coste
2015-11-19Introduce a debug flags option to control some tracingMaxime Coste
Support shell|hooks and write traces in debug buffer
2015-09-16Store key hash in IdMapMaxime Coste
2015-07-08Notify user when some hooks failedMaxime Coste
2015-06-06Move write_debug to buffer utils as write_to_debug_bufferMaxime Coste
2015-06-01Port even more code to use format functionMaxime Coste
2015-03-10Refactor String, use a common StringOps interface, hide std::stringMaxime Coste
2015-03-05Use a IdMap for storing hooksMaxime Coste
The number of hook names is small (<20), using an UnorderedMap is overkill, and prevents using StringView for key searching.
2014-12-23Rename id_map to IdMapMaxime Coste
2014-12-23Unify completion from container content logicMaxime Coste
2014-10-20Port more code to StringView instead of const String&Maxime Coste