From b283996b6ecffc3a1d05c52df02c89ec86cafa96 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Fri, 20 Nov 2026 01:45:55 +0100 Subject: fixed rubbing out Q-reg string appends (:Xq or :^Uq) I was trying to get the current position within the Q-register before it was loaded into the view - so we'd get the previous register's position instead (usually 0). Still, we cannot assume the position to be at the end of the register before an append operation, so we must get the size of the string instead (SCI_GETLENGTH). Has been broken since e371b5fc710c597e175e6b7d7645b3a224a731a1. --- src/qreg.c | 8 +++++--- tests/testsuite.at | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/qreg.c b/src/qreg.c index 7d9a83b..c3231f3 100644 --- a/src/qreg.c +++ b/src/qreg.c @@ -199,9 +199,6 @@ teco_qreg_plain_append_string(teco_qreg_t *qreg, const gchar *str, gsize len, GE teco_doc_undo_edit(&teco_qreg_current->string); teco_doc_undo_reset(&qreg->string); - - sptr_t pos = teco_view_ssm(teco_qreg_view, SCI_GETCURRENTPOS, 0, 0); - undo__teco_view_ssm(teco_qreg_view, SCI_DELETERANGE, pos, len); } if (teco_qreg_current) @@ -209,6 +206,11 @@ teco_qreg_plain_append_string(teco_qreg_t *qreg, const gchar *str, gsize len, GE teco_doc_edit(&qreg->string, teco_default_codepage()); + if (qreg->flags.must_undo) { // FIXME + sptr_t pos = teco_view_ssm(teco_qreg_view, SCI_GETLENGTH, 0, 0); + undo__teco_view_ssm(teco_qreg_view, SCI_DELETERANGE, pos, len); + } + teco_view_ssm(teco_qreg_view, SCI_APPENDTEXT, len, (sptr_t)str); if (teco_qreg_current) diff --git a/tests/testsuite.at b/tests/testsuite.at index 3f55e15..b0a3c55 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -736,6 +736,8 @@ AT_CLEANUP AT_SETUP([Rub out string append]) TE_CHECK_CMDLINE([[@I/XXX/ H:Xa{-4D} :Qa-0"N(0/0)']], 0, ignore, stderr) AT_FAIL_IF([$GREP "^Error:" stderr]) +TE_CHECK_CMDLINE([[@^Ua/ABC/ :@^Ua/012/{-10D} :@EN/ABC/^EQa/"F(0/0)']], 0, ignore, stderr) +AT_FAIL_IF([$GREP "^Error:" stderr]) AT_CLEANUP AT_SETUP([Rub out of empty forward kill]) -- cgit v1.3