From 39249ed57170f09e7dd2fc76c62b51d90a2a4d76 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Fri, 27 Jun 2025 16:13:15 +0200 Subject: fixed ^S/^Y for and * We must call teco_interface_bytes2glyphs() only ever with byte offsets that already exist in the buffer. * regression, introduced in aaa1d51a4c85fcc627e88ef7cf5292d9c5f5f840 --- src/glob.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/glob.c') 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; -- cgit v1.2.3