Code style tweak

This commit is contained in:
Maxime Coste 2017-06-29 07:36:07 +01:00
parent 14958a7c94
commit e95fab0e7a

View File

@ -477,16 +477,12 @@ void pipe(Context& context, NormalParams)
if (event != PromptEvent::Validate) if (event != PromptEvent::Validate)
return; return;
StringView real_cmd;
if (cmdline.empty()) if (cmdline.empty())
real_cmd = context.main_sel_register_value("|"); cmdline = context.main_sel_register_value("|");
else else
{
RegisterManager::instance()['|'].set(context, cmdline.str()); RegisterManager::instance()['|'].set(context, cmdline.str());
real_cmd = cmdline;
}
if (real_cmd.empty()) if (cmdline.empty())
return; return;
Buffer& buffer = context.buffer(); Buffer& buffer = context.buffer();
@ -504,7 +500,7 @@ void pipe(Context& context, NormalParams)
if (insert_eol) if (insert_eol)
in += '\n'; in += '\n';
String out = ShellManager::instance().eval( String out = ShellManager::instance().eval(
real_cmd, context, in, cmdline, context, in,
ShellManager::Flags::WaitForStdout).first; ShellManager::Flags::WaitForStdout).first;
if (insert_eol and out.back() == '\n') if (insert_eol and out.back() == '\n')
@ -519,7 +515,7 @@ void pipe(Context& context, NormalParams)
for (int i = 0; i < selections.size(); ++i) for (int i = 0; i < selections.size(); ++i)
{ {
selections.set_main_index(i); selections.set_main_index(i);
ShellManager::instance().eval(real_cmd, context, ShellManager::instance().eval(cmdline, context,
content(buffer, selections.main()), content(buffer, selections.main()),
ShellManager::Flags::None); ShellManager::Flags::None);
} }
@ -539,20 +535,16 @@ void insert_output(Context& context, NormalParams)
if (event != PromptEvent::Validate) if (event != PromptEvent::Validate)
return; return;
StringView real_cmd;
if (cmdline.empty()) if (cmdline.empty())
real_cmd = context.main_sel_register_value("|"); cmdline = context.main_sel_register_value("|");
else else
{
RegisterManager::instance()['|'].set(context, cmdline.str()); RegisterManager::instance()['|'].set(context, cmdline.str());
real_cmd = cmdline;
}
if (real_cmd.empty()) if (cmdline.empty())
return; return;
auto str = ShellManager::instance().eval( auto str = ShellManager::instance().eval(
real_cmd, context, {}, ShellManager::Flags::WaitForStdout).first; cmdline, context, {}, ShellManager::Flags::WaitForStdout).first;
ScopedEdition edition(context); ScopedEdition edition(context);
context.selections().insert(str, mode); context.selections().insert(str, mode);
}); });