From 4be609010758f0daef1be567a2b2bbea20700e1e Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 6 Mar 2015 13:57:21 +0000 Subject: [PATCH] Fix additional eol inserted when replace piping at end of buffer --- src/normal.cc | 3 ++- test/compose/pipe-at-eof/cmd | 1 + test/compose/pipe-at-eof/in | 3 +++ test/compose/pipe-at-eof/out | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 test/compose/pipe-at-eof/cmd create mode 100644 test/compose/pipe-at-eof/in create mode 100644 test/compose/pipe-at-eof/out diff --git a/src/normal.cc b/src/normal.cc index 02f5490c..2cf066d0 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -395,7 +395,8 @@ void pipe(Context& context, NormalParams) str += '\n'; str = ShellManager::instance().pipe(str, real_cmd, context, {}, EnvVarMap{}); - if (insert_eol and str.back() == '\n') + if ((insert_eol or sel.max() == buffer.back_coord()) and + str.back() == '\n') str = str.substr(0, str.length()-1); strings.push_back(std::move(str)); } diff --git a/test/compose/pipe-at-eof/cmd b/test/compose/pipe-at-eof/cmd new file mode 100644 index 00000000..1a1a3d9b --- /dev/null +++ b/test/compose/pipe-at-eof/cmd @@ -0,0 +1 @@ +%|sort diff --git a/test/compose/pipe-at-eof/in b/test/compose/pipe-at-eof/in new file mode 100644 index 00000000..c2d1e1b2 --- /dev/null +++ b/test/compose/pipe-at-eof/in @@ -0,0 +1,3 @@ +tchou +tchaa +tchii diff --git a/test/compose/pipe-at-eof/out b/test/compose/pipe-at-eof/out new file mode 100644 index 00000000..b2f88aba --- /dev/null +++ b/test/compose/pipe-at-eof/out @@ -0,0 +1,3 @@ +tchaa +tchii +tchou