From f68e8313b2282b1a94bd5baee2b87581f31fc5e8 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 20 Dec 2021 09:13:53 +1100 Subject: [PATCH] Fix invalid line joining logic with multiple selection per line Fixes #4476 --- src/normal.cc | 1 + test/regression/4476-invalid-line-join/cmd | 1 + test/regression/4476-invalid-line-join/in | 2 ++ test/regression/4476-invalid-line-join/out | 1 + 4 files changed, 5 insertions(+) create mode 100644 test/regression/4476-invalid-line-join/cmd create mode 100644 test/regression/4476-invalid-line-join/in create mode 100644 test/regression/4476-invalid-line-join/out diff --git a/src/normal.cc b/src/normal.cc index c1a084a4..40efc32d 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -1104,6 +1104,7 @@ void join_lines_select_spaces(Context& context, NormalParams) if (selections.empty()) return; context.selections_write_only() = std::move(selections); + context.selections().merge_consecutive(); ScopedEdition edition(context); context.selections().replace({" "_str}); } diff --git a/test/regression/4476-invalid-line-join/cmd b/test/regression/4476-invalid-line-join/cmd new file mode 100644 index 00000000..ba1947f7 --- /dev/null +++ b/test/regression/4476-invalid-line-join/cmd @@ -0,0 +1 @@ +% diff --git a/test/regression/4476-invalid-line-join/in b/test/regression/4476-invalid-line-join/in new file mode 100644 index 00000000..b5e0c3a5 --- /dev/null +++ b/test/regression/4476-invalid-line-join/in @@ -0,0 +1,2 @@ +ab +ac diff --git a/test/regression/4476-invalid-line-join/out b/test/regression/4476-invalid-line-join/out new file mode 100644 index 00000000..2b456081 --- /dev/null +++ b/test/regression/4476-invalid-line-join/out @@ -0,0 +1 @@ +ab ac