diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-07-24 13:38:26 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-07-24 13:38:26 +0100 |
| commit | f6308409a16bb80f8daaf14d4e9ed25f6801d3d3 (patch) | |
| tree | 61ce6a00ca934b2ed432f438811dae2ef84ee848 /src/normal.cc | |
| parent | 62fdacb757cee6bb4d859f49b8ca7a2e476b8379 (diff) | |
pipe: auto insert and end of line if needed
Diffstat (limited to 'src/normal.cc')
| -rw-r--r-- | src/normal.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/normal.cc b/src/normal.cc index 4c50bc03..f1e0cac2 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -261,9 +261,17 @@ void pipe(Context& context) Editor& editor = context.editor(); std::vector<String> strings; for (auto& sel : context.editor().selections()) - strings.push_back(ShellManager::instance().pipe(content(context.buffer(), sel), - cmdline, context, {}, - EnvVarMap{})); + { + auto str = content(context.buffer(), sel); + bool insert_eol = str.back() != '\n'; + if (insert_eol) + str += '\n'; + str = ShellManager::instance().pipe(str, cmdline, context, + {}, EnvVarMap{}); + if (insert_eol and str.back() == '\n') + str = str.substr(0, str.length()-1); + strings.push_back(str); + } editor.insert(strings, InsertMode::Replace); }); } |
