Do not save last command/pipe/regex in register when history is disabled
This commit is contained in:
parent
24403ebf64
commit
55621fb4cc
|
@ -455,7 +455,7 @@ void command(Context& context, NormalParams params)
|
||||||
{
|
{
|
||||||
if (cmdline.empty())
|
if (cmdline.empty())
|
||||||
cmdline = context.main_sel_register_value(':');
|
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());
|
RegisterManager::instance()[':'].set(context, cmdline.str());
|
||||||
|
|
||||||
EnvVarMap env_vars = {
|
EnvVarMap env_vars = {
|
||||||
|
@ -505,7 +505,7 @@ void pipe(Context& context, NormalParams)
|
||||||
|
|
||||||
if (cmdline.empty())
|
if (cmdline.empty())
|
||||||
cmdline = context.main_sel_register_value("|");
|
cmdline = context.main_sel_register_value("|");
|
||||||
else
|
else if (not context.history_disabled())
|
||||||
RegisterManager::instance()['|'].set(context, cmdline.str());
|
RegisterManager::instance()['|'].set(context, cmdline.str());
|
||||||
|
|
||||||
if (cmdline.empty())
|
if (cmdline.empty())
|
||||||
|
@ -580,7 +580,7 @@ void insert_output(Context& context, NormalParams)
|
||||||
|
|
||||||
if (cmdline.empty())
|
if (cmdline.empty())
|
||||||
cmdline = context.main_sel_register_value("|");
|
cmdline = context.main_sel_register_value("|");
|
||||||
else
|
else if (not context.history_disabled())
|
||||||
RegisterManager::instance()['|'].set(context, cmdline.str());
|
RegisterManager::instance()['|'].set(context, cmdline.str());
|
||||||
|
|
||||||
if (cmdline.empty())
|
if (cmdline.empty())
|
||||||
|
@ -761,8 +761,7 @@ void search(Context& context, NormalParams params)
|
||||||
const char reg = to_lower(params.reg ? params.reg : '/');
|
const char reg = to_lower(params.reg ? params.reg : '/');
|
||||||
const int count = params.count;
|
const int count = params.count;
|
||||||
|
|
||||||
auto reg_content = RegisterManager::instance()[reg].get(context);
|
auto saved_reg = RegisterManager::instance()[reg].get(context) | gather<Vector<String>>();
|
||||||
Vector<String> saved_reg{reg_content.begin(), reg_content.end()};
|
|
||||||
const int main_index = std::min(context.selections().main_index(), saved_reg.size()-1);
|
const int main_index = std::min(context.selections().main_index(), saved_reg.size()-1);
|
||||||
|
|
||||||
regex_prompt<direction>(context, prompt.str(), saved_reg[main_index],
|
regex_prompt<direction>(context, prompt.str(), saved_reg[main_index],
|
||||||
|
@ -773,7 +772,8 @@ void search(Context& context, NormalParams params)
|
||||||
RegisterManager::instance()[reg].set(context, saved_reg);
|
RegisterManager::instance()[reg].set(context, saved_reg);
|
||||||
return;
|
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())
|
if (not regex.empty() and not regex.str().empty())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user