From 8299d1da1f4e3fd856dc81ff1c8ec584714582e0 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 1 Nov 2021 09:05:57 +1100 Subject: [PATCH 1/2] Fix pasting all from empty register Raise an error if the register is empty for paste-all Fixes #4414 --- src/normal.cc | 3 +++ test/regression/4414-crash-on-paste-all/cmd | 1 + test/regression/4414-crash-on-paste-all/in | 1 + test/regression/4414-crash-on-paste-all/out | 1 + 4 files changed, 6 insertions(+) create mode 100644 test/regression/4414-crash-on-paste-all/cmd create mode 100644 test/regression/4414-crash-on-paste-all/in create mode 100644 test/regression/4414-crash-on-paste-all/out diff --git a/src/normal.cc b/src/normal.cc index 64daabc69..8d2ed82c9 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -720,6 +720,9 @@ void paste_all(Context& context, NormalParams params) offsets.push_back(all.length()); } + if (offsets.empty()) + throw runtime_error("nothing to paste"); + Buffer& buffer = context.buffer(); Vector result; auto& selections = context.selections(); diff --git a/test/regression/4414-crash-on-paste-all/cmd b/test/regression/4414-crash-on-paste-all/cmd new file mode 100644 index 000000000..a857f6480 --- /dev/null +++ b/test/regression/4414-crash-on-paste-all/cmd @@ -0,0 +1 @@ + diff --git a/test/regression/4414-crash-on-paste-all/in b/test/regression/4414-crash-on-paste-all/in new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/test/regression/4414-crash-on-paste-all/in @@ -0,0 +1 @@ + diff --git a/test/regression/4414-crash-on-paste-all/out b/test/regression/4414-crash-on-paste-all/out new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/test/regression/4414-crash-on-paste-all/out @@ -0,0 +1 @@ + From 9be2a1f170c3936e3296959492275429fd7e31bb Mon Sep 17 00:00:00 2001 From: Sidharth Kshatriya Date: Tue, 2 Nov 2021 15:28:39 +0530 Subject: [PATCH 2/2] Remove .kak_history file that seems to have been committed by mistake --- test/highlight/replace-only-fully-selected-ranges/.kak_history | 1 - 1 file changed, 1 deletion(-) delete mode 100644 test/highlight/replace-only-fully-selected-ranges/.kak_history diff --git a/test/highlight/replace-only-fully-selected-ranges/.kak_history b/test/highlight/replace-only-fully-selected-ranges/.kak_history deleted file mode 100644 index 06fb5c84f..000000000 --- a/test/highlight/replace-only-fully-selected-ranges/.kak_history +++ /dev/null @@ -1 +0,0 @@ -'reg' ':' '' 'wq' \ No newline at end of file