mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-27 12:16:22 +03:00
Add a test case for -once hooks and code style tweaks
This commit is contained in:
parent
4387b1ac90
commit
293610a432
@ -861,8 +861,8 @@ const CommandDesc add_hook_cmd = {
|
||||
Regex regex{parser[2], RegexCompileFlags::Optimize};
|
||||
const String& command = parser[3];
|
||||
auto group = parser.get_switch("group").value_or(StringView{});
|
||||
const auto flags = (parser.get_switch("always") ? HookFlags::Always : HookFlags::None) \
|
||||
| (parser.get_switch("once") ? HookFlags::Once : HookFlags::None);
|
||||
const auto flags = (parser.get_switch("always") ? HookFlags::Always : HookFlags::None) |
|
||||
(parser.get_switch("once") ? HookFlags::Once : HookFlags::None);
|
||||
get_scope(parser[0], context).hooks().add_hook(parser[1], group.str(), flags,
|
||||
std::move(regex), command);
|
||||
}
|
||||
|
@ -126,10 +126,7 @@ void HookManager::run_hook(StringView hook_name, StringView param, Context& cont
|
||||
|
||||
if (to_run.hook->flags & HookFlags::Once)
|
||||
{
|
||||
auto it = std::find_if(hook_list->value.begin(), hook_list->value.end(),
|
||||
[&](const std::unique_ptr<Hook>& h)
|
||||
{ return h.get() == to_run.hook; });
|
||||
|
||||
auto it = find(hook_list->value, to_run.hook);
|
||||
m_hooks_trash.push_back(std::move(*it));
|
||||
hook_list->value.erase(it);
|
||||
}
|
||||
|
1
test/hooks/once/cmd
Normal file
1
test/hooks/once/cmd
Normal file
@ -0,0 +1 @@
|
||||
iaaa<esc>
|
1
test/hooks/once/in
Normal file
1
test/hooks/once/in
Normal file
@ -0,0 +1 @@
|
||||
|
1
test/hooks/once/out
Normal file
1
test/hooks/once/out
Normal file
@ -0,0 +1 @@
|
||||
abaa
|
1
test/hooks/once/rc
Normal file
1
test/hooks/once/rc
Normal file
@ -0,0 +1 @@
|
||||
hook global -once InsertChar a 'exec b'
|
Loading…
Reference in New Issue
Block a user