summaryrefslogtreecommitdiff
path: root/src/normal.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2023-11-11 18:45:27 +1100
committerMaxime Coste <mawww@kakoune.org>2023-11-14 21:39:03 +1100
commit719512b308f1d5165037775cb314094f1bb870ad (patch)
tree5821f46bd14d0da38904c15659ca3f637580edb1 /src/normal.cc
parent79f3f5b046518216c85aeaf11135da0cf5e24521 (diff)
Use a separate copy of the command completer for each completion
This make the completer lifetime tied to the Prompt mode and removes the need for the Start flag. It also makes it possible to cleanup on completer destruction.
Diffstat (limited to 'src/normal.cc')
-rw-r--r--src/normal.cc8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/normal.cc b/src/normal.cc
index ebe86ebc..e70d0680 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -471,17 +471,15 @@ void command(const Context& context, EnvVarMap env_vars, char reg = 0)
if (not CommandManager::has_instance())
throw runtime_error{"commands are not supported"};
- CommandManager::instance().clear_last_complete_command();
-
String default_command = context.main_sel_register_value(reg ? reg : ':').str();
context.input_handler().prompt(
":", {}, default_command,
context.faces()["Prompt"], PromptFlags::DropHistoryEntriesWithBlankPrefix,
':',
- [](const Context& context, CompletionFlags flags,
- StringView cmd_line, ByteCount pos) {
- return CommandManager::instance().complete(context, flags, cmd_line, pos);
+ [completer=CommandManager::Completer{}](const Context& context, CompletionFlags flags,
+ StringView cmd_line, ByteCount pos) mutable {
+ return completer(context, flags, cmd_line, pos);
},
[env_vars = std::move(env_vars), default_command](StringView cmdline, PromptEvent event, Context& context) {
if (context.has_client())