aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ring.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ring.c')
-rw-r--r--src/ring.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/ring.c b/src/ring.c
index 548173b..ceeb730 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -736,19 +736,24 @@ teco_state_read_file_done(teco_machine_main_t *ctx, teco_string_t str, GError **
if (ctx->flags.mode > TECO_MODE_NORMAL)
return &teco_state_start;
- sptr_t pos = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0);
- teco_undo_int(teco_ranges[0].from) = teco_interface_bytes2glyphs(pos);
+ sptr_t from = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0);
+ teco_undo_int(teco_ranges[0].from) = teco_current_doc_get_dot();;
g_autofree gchar *filename = teco_file_expand_path(str.data);
/* FIXME: Add wrapper to interface.h? */
if (!teco_view_load(teco_interface_current_view, filename, FALSE, error))
return NULL;
- pos = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0);
- teco_undo_int(teco_ranges[0].to) = teco_interface_bytes2glyphs(pos);
+ /*
+ * FIXME: Perhaps teco_view_load() should return the number of glyphs added.
+ */
+ sptr_t to = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0);
+ teco_undo_int(teco_ranges[0].to) = teco_interface_bytes2glyphs_rel(teco_ranges[0].from,
+ from, to-from);
teco_undo_guint(teco_ranges_count) = 1;
if (teco_ranges[0].from != teco_ranges[0].to) {
+ teco_current_doc_set_dot(teco_ranges[0].to);
teco_ring_dirtify();
if (teco_current_doc_must_undo())