From 0d3da2ce68df9f442aa0606361b64bae1dd57811 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 21 Jun 2022 03:26:52 +0200 Subject: avoid unnecessary creation of undo tokens --- src/core-commands.c | 10 ++++++---- src/qreg-commands.c | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/core-commands.c b/src/core-commands.c index 1c52e5a..2a49d0d 100644 --- a/src/core-commands.c +++ b/src/core-commands.c @@ -777,9 +777,10 @@ teco_delete_words(teco_int_t n) } g_assert(size != teco_interface_ssm(SCI_GETLENGTH, 0, 0)); - undo__teco_interface_ssm(SCI_SETEMPTYSELECTION, pos, 0); - if (teco_current_doc_must_undo()) + if (teco_current_doc_must_undo()) { + undo__teco_interface_ssm(SCI_SETEMPTYSELECTION, pos, 0); undo__teco_interface_ssm(SCI_UNDO, 0, 0); + } teco_ring_dirtify(); return TECO_SUCCESS; @@ -2249,8 +2250,9 @@ teco_state_ecommand_eol(teco_machine_main_t *ctx, GError **error) } } - undo__teco_interface_ssm(SCI_SETEOLMODE, - teco_interface_ssm(SCI_GETEOLMODE, 0, 0), 0); + if (teco_current_doc_must_undo()) + undo__teco_interface_ssm(SCI_SETEOLMODE, + teco_interface_ssm(SCI_GETEOLMODE, 0, 0), 0); teco_interface_ssm(SCI_SETEOLMODE, eol_mode, 0); } else if (teco_machine_main_eval_colon(ctx)) { const gchar *eol_seq = teco_eol_get_seq(teco_interface_ssm(SCI_GETEOLMODE, 0, 0)); diff --git a/src/qreg-commands.c b/src/qreg-commands.c index 1e1649b..1e4e214 100644 --- a/src/qreg-commands.c +++ b/src/qreg-commands.c @@ -490,7 +490,8 @@ teco_state_getqregstring_got_register(teco_machine_main_t *ctx, teco_qreg_t *qre teco_interface_ssm(SCI_ENDUNDOACTION, 0, 0); teco_ring_dirtify(); - undo__teco_interface_ssm(SCI_UNDO, 0, 0); + if (teco_current_doc_must_undo()) + undo__teco_interface_ssm(SCI_UNDO, 0, 0); } return &teco_state_start; -- cgit v1.2.3