Slight code tweaks in normal mode pipe function

This commit is contained in:
Maxime Coste 2016-03-17 12:08:11 +00:00
parent f8f530e6ac
commit d277ef6d6c

View File

@ -398,16 +398,15 @@ void pipe(Context& context, NormalParams)
Vector<String> strings; Vector<String> strings;
for (auto& sel : selections) for (auto& sel : selections)
{ {
auto in = content(buffer, sel); String in = content(buffer, sel);
bool insert_eol = in.back() != '\n'; const bool insert_eol = in.back() != '\n';
if (insert_eol) if (insert_eol)
in += '\n'; in += '\n';
auto out = ShellManager::instance().eval( String out = ShellManager::instance().eval(
real_cmd, context, in, real_cmd, context, in,
ShellManager::Flags::WaitForStdout).first; ShellManager::Flags::WaitForStdout).first;
if ((insert_eol or sel.max() == buffer.back_coord()) and if (insert_eol and out.back() == '\n')
out.back() == '\n')
out = out.substr(0, out.length()-1).str(); out = out.substr(0, out.length()-1).str();
strings.push_back(std::move(out)); strings.push_back(std::move(out));
} }