aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2025-06-27 16:13:15 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2025-06-27 16:13:15 +0200
commit39249ed57170f09e7dd2fc76c62b51d90a2a4d76 (patch)
treec8cc8e89c2fd31a0215d4f4dbaf9c1aa6b1191de
parent06b4da0de1388eb8403d3ad88915c117ab84877f (diff)
downloadsciteco-39249ed57170f09e7dd2fc76c62b51d90a2a4d76.tar.gz
fixed ^S/^Y for <Gq> and <EN>
* We must call teco_interface_bytes2glyphs() only ever with byte offsets that already exist in the buffer. * regression, introduced in aaa1d51a4c85fcc627e88ef7cf5292d9c5f5f840
-rw-r--r--src/glob.c10
-rw-r--r--src/qreg-commands.c7
-rw-r--r--tests/testsuite.at3
3 files changed, 12 insertions, 8 deletions
diff --git a/src/glob.c b/src/glob.c
index 4495093..93f3361 100644
--- a/src/glob.c
+++ b/src/glob.c
@@ -513,21 +513,21 @@ teco_state_glob_filename_done(teco_machine_main_t *ctx, const teco_string_t *str
if (g_regex_match(pattern, filename, 0, NULL) &&
(teco_test_mode == 0 || g_file_test(filename, file_flags))) {
if (!colon_modified) {
- gsize len = strlen(filename);
-
sptr_t pos = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0);
- teco_undo_int(teco_ranges[0].from) = teco_interface_bytes2glyphs(pos);
- teco_undo_int(teco_ranges[0].to) = teco_interface_bytes2glyphs(pos + len + 1);
- teco_undo_guint(teco_ranges_count) = 1;
/*
* FIXME: Filenames may contain linefeeds.
* But if we add them null-terminated, they will be relatively hard to parse.
*/
+ gsize len = strlen(filename);
filename[len] = '\n';
teco_interface_ssm(SCI_BEGINUNDOACTION, 0, 0);
teco_interface_ssm(SCI_ADDTEXT, len+1, (sptr_t)filename);
teco_interface_ssm(SCI_ENDUNDOACTION, 0, 0);
+
+ teco_undo_int(teco_ranges[0].from) = teco_interface_bytes2glyphs(pos);
+ teco_undo_int(teco_ranges[0].to) = teco_interface_bytes2glyphs(pos + len + 1);
+ teco_undo_guint(teco_ranges_count) = 1;
}
matching = TRUE;
diff --git a/src/qreg-commands.c b/src/qreg-commands.c
index 0457e92..7189771 100644
--- a/src/qreg-commands.c
+++ b/src/qreg-commands.c
@@ -535,9 +535,6 @@ teco_state_getqregstring_got_register(teco_machine_main_t *ctx, teco_qreg_t *qre
return NULL;
sptr_t pos = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0);
- teco_undo_int(teco_ranges[0].from) = teco_interface_bytes2glyphs(pos);
- teco_undo_int(teco_ranges[0].to) = teco_interface_bytes2glyphs(pos + str.len);
- teco_undo_guint(teco_ranges_count) = 1;
if (str.len > 0) {
teco_interface_ssm(SCI_BEGINUNDOACTION, 0, 0);
@@ -549,6 +546,10 @@ teco_state_getqregstring_got_register(teco_machine_main_t *ctx, teco_qreg_t *qre
undo__teco_interface_ssm(SCI_UNDO, 0, 0);
}
+ teco_undo_int(teco_ranges[0].from) = teco_interface_bytes2glyphs(pos);
+ teco_undo_int(teco_ranges[0].to) = teco_interface_bytes2glyphs(pos + str.len);
+ teco_undo_guint(teco_ranges_count) = 1;
+
return &teco_state_start;
}
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 96d4978..2c298b6 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -215,6 +215,9 @@ AT_SETUP([Search and insertion ranges])
TE_CHECK([[@I/XXYYZZ/^SC ."N(0/0)' C @S/YY/ HK ^YU1U0 Q0-2"N(0/0)' Q1-4"N(0/0)']], 0, ignore, ignore)
TE_CHECK([[@I/XXYYZZ/J @S/XX^E[^EMY]/ 1^YXa :Qa-2"N(0/0)']], 0, ignore, ignore)
TE_CHECK([[@I/XXYYZZ/J @FD/^EMZ/ ^S+2"N(0/0)']], 0, ignore, ignore)
+TE_CHECK([[@^Ua/XYZ/ Ga ^S+3"N(0/0)']], 0, ignore, ignore)
+# NOTE: EN currently inserts another trailing linefeed.
+TE_CHECK([[@EN/*/XYZ/ ^S+4"N(0/0)']], 0, ignore, ignore)
AT_CLEANUP
AT_SETUP([Editing local registers in macro calls])