aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/glob.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/glob.c')
-rw-r--r--src/glob.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/glob.c b/src/glob.c
index 0917e5c..24f2647 100644
--- a/src/glob.c
+++ b/src/glob.c
@@ -38,6 +38,7 @@
#include "expressions.h"
#include "qreg.h"
#include "ring.h"
+#include "view.h"
#include "error.h"
#include "undo.h"
#include "glob.h"
@@ -527,21 +528,24 @@ teco_state_glob_filename_done(teco_machine_main_t *ctx, teco_string_t str, GErro
gint rc = tere_exec(&pattern, (chr *)filename, strlen(filename), NULL, 0, NULL, 0);
if (rc == REG_OKAY && (teco_test_mode == 0 || g_file_test(filename, file_flags))) {
if (!colon_modified) {
- sptr_t pos = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0);
-
/*
* 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';
+
+ sptr_t pos = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0);
+ teco_undo_int(teco_ranges[0].from) = teco_current_doc_get_dot();
+
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_int_t to = teco_interface_bytes2glyphs_rel(teco_ranges[0].from, pos, len + 1);
+ teco_undo_int(teco_ranges[0].to) = to;
teco_undo_guint(teco_ranges_count) = 1;
+ teco_current_doc_set_dot(to);
}
matching = TRUE;
@@ -565,14 +569,15 @@ teco_state_glob_filename_done(teco_machine_main_t *ctx, teco_string_t str, GErro
globber = teco_globber_new(pattern_str.data, file_flags);
sptr_t pos = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0);
- teco_undo_int(teco_ranges[0].from) = teco_interface_bytes2glyphs(pos);
+ gsize total_len = 0;
+ teco_undo_int(teco_ranges[0].from) = teco_current_doc_get_dot();
teco_interface_ssm(SCI_BEGINUNDOACTION, 0, 0);
gchar *globbed_filename;
while ((globbed_filename = teco_globber_next(globber))) {
gsize len = strlen(globbed_filename);
- pos += len+1;
+ total_len += len+1;
/*
* FIXME: Filenames may contain linefeeds.
@@ -587,8 +592,10 @@ teco_state_glob_filename_done(teco_machine_main_t *ctx, teco_string_t str, GErro
teco_interface_ssm(SCI_ENDUNDOACTION, 0, 0);
- teco_undo_int(teco_ranges[0].to) = teco_interface_bytes2glyphs(pos);
+ teco_int_t to = teco_interface_bytes2glyphs_rel(teco_ranges[0].from, pos, total_len);
+ teco_undo_int(teco_ranges[0].to) = to;
teco_undo_guint(teco_ranges_count) = 1;
+ teco_current_doc_set_dot(to);
}
if (colon_modified) {