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