aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-12-08 16:41:34 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-12-08 16:41:34 +0300
commit3f6572c5b46254002cb1b3fd1001bc28ecc2bb10 (patch)
tree937a07bddf381199d81a8182109620ef6719fb82
parentbd87ff40e73929e761e1233aa812a6736cacbed1 (diff)
downloadsciteco-3f6572c5b46254002cb1b3fd1001bc28ecc2bb10.tar.gz
fixed rubbing out file open with glob patterns
* This would crash if <EB> opened more than one file, e.g. EB*.c$. The reason is that teco_current_doc_undo_edit() must be called before every teco_ring_edit(). * Unfortunately, this is not reproduceable with sciteco --no-profile --fake-cmdline '@EB"foo*.txt"{HK}' since the crashes actually happen when printing messages in interactive mode. That's why no test case has been added.
-rw-r--r--src/ring.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/ring.c b/src/ring.c
index d6fadda..8ce6948 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -441,9 +441,6 @@ teco_state_edit_file_done(teco_machine_main_t *ctx, const teco_string_t *str, GE
return &teco_state_start;
}
- if (!teco_current_doc_undo_edit(error))
- return NULL;
-
g_autofree gchar *filename = teco_file_expand_path(str->data);
if (teco_globber_is_pattern(filename)) {
g_auto(teco_globber_t) globber;
@@ -451,13 +448,15 @@ teco_state_edit_file_done(teco_machine_main_t *ctx, const teco_string_t *str, GE
gchar *globbed_filename;
while ((globbed_filename = teco_globber_next(&globber))) {
- gboolean rc = teco_ring_edit(globbed_filename, error);
+ gboolean rc = teco_current_doc_undo_edit(error) &&
+ teco_ring_edit(globbed_filename, error);
g_free(globbed_filename);
if (!rc)
return NULL;
}
} else {
- if (!teco_ring_edit_by_name(*filename ? filename : NULL, error))
+ if (!teco_current_doc_undo_edit(error) ||
+ !teco_ring_edit_by_name(*filename ? filename : NULL, error))
return NULL;
}