summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-03-06 13:57:21 +0000
committerMaxime Coste <frrrwww@gmail.com>2015-03-06 13:57:21 +0000
commit4be609010758f0daef1be567a2b2bbea20700e1e (patch)
tree3b9443b26ce17bbfcf56eac51b995ed887f6e1aa
parent2d93933d81ea7e00b0541396e11087ef01c4ff7d (diff)
Fix additional eol inserted when replace piping at end of buffer
-rw-r--r--src/normal.cc3
-rw-r--r--test/compose/pipe-at-eof/cmd1
-rw-r--r--test/compose/pipe-at-eof/in3
-rw-r--r--test/compose/pipe-at-eof/out3
4 files changed, 9 insertions, 1 deletions
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<ret>
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