From 3d3a37a80cec3be1b38c8176fab0425279c19303 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 27 Mar 2018 07:28:25 +1100 Subject: [PATCH] Fix 'O' not putting the cursor on the correct line --- src/input_handler.cc | 2 +- test/regression/1964-O-does-not-position-cursor-correctly/cmd | 1 + test/regression/1964-O-does-not-position-cursor-correctly/in | 3 +++ test/regression/1964-O-does-not-position-cursor-correctly/out | 4 ++++ 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 test/regression/1964-O-does-not-position-cursor-correctly/cmd create mode 100644 test/regression/1964-O-does-not-position-cursor-correctly/in create mode 100644 test/regression/1964-O-does-not-position-cursor-correctly/out diff --git a/src/input_handler.cc b/src/input_handler.cc index 210b0ec9..20228dd1 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -1365,7 +1365,7 @@ private: buffer.insert(sel.min().line + inserted_count, String{'\n', CharCount{count}}); for (int i = 0; i < count; ++i) - new_sels.push_back({sel.max().line + inserted_count + i}); + new_sels.push_back({sel.min().line + inserted_count + i}); inserted_count += count; } selections.set(std::move(new_sels), diff --git a/test/regression/1964-O-does-not-position-cursor-correctly/cmd b/test/regression/1964-O-does-not-position-cursor-correctly/cmd new file mode 100644 index 00000000..5fa326cb --- /dev/null +++ b/test/regression/1964-O-does-not-position-cursor-correctly/cmd @@ -0,0 +1 @@ +Oqux diff --git a/test/regression/1964-O-does-not-position-cursor-correctly/in b/test/regression/1964-O-does-not-position-cursor-correctly/in new file mode 100644 index 00000000..f25db757 --- /dev/null +++ b/test/regression/1964-O-does-not-position-cursor-correctly/in @@ -0,0 +1,3 @@ +%(foo +bar +baz) diff --git a/test/regression/1964-O-does-not-position-cursor-correctly/out b/test/regression/1964-O-does-not-position-cursor-correctly/out new file mode 100644 index 00000000..75ef555e --- /dev/null +++ b/test/regression/1964-O-does-not-position-cursor-correctly/out @@ -0,0 +1,4 @@ +qux +foo +bar +baz