From 55621fb4cc9c01972317182dd6a8ed3ced0e1f9e Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 19 Jan 2018 09:48:57 +1100 Subject: [PATCH] Do not save last command/pipe/regex in register when history is disabled --- src/normal.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/normal.cc b/src/normal.cc index fe1292162..6208d01b6 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -455,7 +455,7 @@ void command(Context& context, NormalParams params) { if (cmdline.empty()) cmdline = context.main_sel_register_value(':'); - else if (not is_blank(cmdline[0])) + else if (not is_blank(cmdline[0]) and not context.history_disabled()) RegisterManager::instance()[':'].set(context, cmdline.str()); EnvVarMap env_vars = { @@ -505,7 +505,7 @@ void pipe(Context& context, NormalParams) if (cmdline.empty()) cmdline = context.main_sel_register_value("|"); - else + else if (not context.history_disabled()) RegisterManager::instance()['|'].set(context, cmdline.str()); if (cmdline.empty()) @@ -580,7 +580,7 @@ void insert_output(Context& context, NormalParams) if (cmdline.empty()) cmdline = context.main_sel_register_value("|"); - else + else if (not context.history_disabled()) RegisterManager::instance()['|'].set(context, cmdline.str()); if (cmdline.empty()) @@ -761,8 +761,7 @@ void search(Context& context, NormalParams params) const char reg = to_lower(params.reg ? params.reg : '/'); const int count = params.count; - auto reg_content = RegisterManager::instance()[reg].get(context); - Vector saved_reg{reg_content.begin(), reg_content.end()}; + auto saved_reg = RegisterManager::instance()[reg].get(context) | gather>(); const int main_index = std::min(context.selections().main_index(), saved_reg.size()-1); regex_prompt(context, prompt.str(), saved_reg[main_index], @@ -773,7 +772,8 @@ void search(Context& context, NormalParams params) RegisterManager::instance()[reg].set(context, saved_reg); return; } - RegisterManager::instance()[reg].set(context, regex.str()); + if (not context.history_disabled()) + RegisterManager::instance()[reg].set(context, regex.str()); if (not regex.empty() and not regex.str().empty()) {