From a37858ece7a2e01cc2c512fd0818c541bea5ce5b Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 17 Nov 2015 23:47:59 +0000 Subject: [PATCH] Put count and register normal mode params in the shell context '10:echo %val{count}' will display 10 Fixes #10 --- src/normal.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/normal.cc b/src/normal.cc index 8a3da241..bee88b98 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -334,7 +334,7 @@ void for_each_codepoint(Context& context, NormalParams) selections.insert(strings, InsertMode::Replace); } -void command(Context& context, NormalParams) +void command(Context& context, NormalParams params) { if (not CommandManager::has_instance()) return; @@ -345,7 +345,7 @@ void command(Context& context, NormalParams) StringView cmd_line, ByteCount pos) { return CommandManager::instance().complete(context, flags, cmd_line, pos); }, - [](StringView cmdline, PromptEvent event, Context& context) { + [params](StringView cmdline, PromptEvent event, Context& context) { if (context.has_ui()) { context.ui().info_hide(); @@ -362,7 +362,14 @@ void command(Context& context, NormalParams) } } if (event == PromptEvent::Validate) - CommandManager::instance().execute(cmdline, context); + { + EnvVarMap env_vars = { + { "count", to_string(params.count) }, + { "register", String{params.reg} } + }; + CommandManager::instance().execute( + cmdline, context, { {}, env_vars }); + } }); }