aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/search.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-10-16 11:40:52 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-10-16 11:40:52 +0300
commitd714bb48a4b8629f6345a28bc21a24537207176b (patch)
treed605b57c182741590377edae8ced7e693000523d /src/search.c
parentd556aee67e615b48c25861741d28d103109235e3 (diff)
downloadsciteco-d714bb48a4b8629f6345a28bc21a24537207176b.tar.gz
fixup: use teco_machine_t::must_undo instead of trying to identify the current state machine
* The previous solution was not wrong, but unnecessarily complex. We already have a flag for exactly this purpose. * Avoid redundancies by introducing teco_machine_stringbuilding_set_codepage().
Diffstat (limited to 'src/search.c')
-rw-r--r--src/search.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/search.c b/src/search.c
index 22dc726..0d04895 100644
--- a/src/search.c
+++ b/src/search.c
@@ -35,7 +35,6 @@
#include "parser.h"
#include "core-commands.h"
#include "error.h"
-#include "cmdline.h"
#include "search.h"
typedef struct {
@@ -61,12 +60,8 @@ teco_state_search_initial(teco_machine_main_t *ctx, GError **error)
if (ctx->mode > TECO_MODE_NORMAL)
return TRUE;
- /*
- * NOTE: This is not safe to undo in macro calls.
- */
- if (ctx == &teco_cmdline.machine)
- teco_undo_guint(ctx->expectstring.machine.codepage);
- ctx->expectstring.machine.codepage = teco_interface_get_codepage();
+ teco_machine_stringbuilding_set_codepage(&ctx->expectstring.machine,
+ teco_interface_get_codepage());
if (G_UNLIKELY(!teco_search_qreg_machine))
teco_search_qreg_machine = teco_machine_qregspec_new(TECO_QREG_REQUIRED, ctx->qreg_table_locals,
@@ -1052,15 +1047,9 @@ TECO_DEFINE_STATE_SEARCH(teco_state_search_delete);
static gboolean
teco_state_replace_insert_initial(teco_machine_main_t *ctx, GError **error)
{
- if (ctx->mode > TECO_MODE_NORMAL)
- return TRUE;
-
- /*
- * NOTE: This is not safe to undo in macro calls.
- */
- if (ctx == &teco_cmdline.machine)
- teco_undo_guint(ctx->expectstring.machine.codepage);
- ctx->expectstring.machine.codepage = teco_interface_get_codepage();
+ if (ctx->mode == TECO_MODE_NORMAL)
+ teco_machine_stringbuilding_set_codepage(&ctx->expectstring.machine,
+ teco_interface_get_codepage());
return TRUE;
}