From 632e7e217e26eecce5b521e65cde265d08b3db87 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 11 Oct 2013 00:31:03 +0100 Subject: [PATCH] Save last pipe command to the '|' register, and use it for empty cmd --- src/normal.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/normal.cc b/src/normal.cc index 0ccdba11..911ec90a 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -264,6 +264,18 @@ void pipe(Context& context, int) if (event != PromptEvent::Validate) return; + String real_cmd; + if (cmdline.empty()) + real_cmd = RegisterManager::instance()['|'].values(context)[0]; + else + { + RegisterManager::instance()['|'] = cmdline; + real_cmd = cmdline; + } + + if (real_cmd.empty()) + return; + Editor& editor = context.editor(); std::vector strings; for (auto& sel : context.editor().selections()) @@ -272,7 +284,7 @@ void pipe(Context& context, int) bool insert_eol = str.back() != '\n'; if (insert_eol) str += '\n'; - str = ShellManager::instance().pipe(str, cmdline, context, + str = ShellManager::instance().pipe(str, real_cmd, context, {}, EnvVarMap{}); if (insert_eol and str.back() == '\n') str = str.substr(0, str.length()-1);