diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-07-23 01:15:45 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-07-23 01:15:45 +0300 |
commit | c2cdafdd5c92f8caa4701257ba91dd7915054fbe (patch) | |
tree | b8e0d94a978583d92c85c6eb5083d088485e8698 | |
parent | 63a314144a36691a57c2e82fe2f3da008c403aba (diff) | |
download | sciteco-c2cdafdd5c92f8caa4701257ba91dd7915054fbe.tar.gz |
if EX falis because of a dirty buffer, the buffer's id is now included in the error message
-rw-r--r-- | src/core-commands.c | 7 | ||||
-rw-r--r-- | src/ring.c | 12 | ||||
-rw-r--r-- | src/ring.h | 2 |
3 files changed, 13 insertions, 8 deletions
diff --git a/src/core-commands.c b/src/core-commands.c index a1d180c..04cdf94 100644 --- a/src/core-commands.c +++ b/src/core-commands.c @@ -2581,9 +2581,10 @@ teco_state_ecommand_exit(teco_machine_main_t *ctx, GError **error) teco_int_t v; if (!teco_expressions_pop_num_calc(&v, teco_num_sign, error)) return; - if (teco_is_failure(v) && teco_ring_is_any_dirty()) { - g_set_error_literal(error, TECO_ERROR, TECO_ERROR_FAILED, - "Modified buffers exist"); + guint id; + if (teco_is_failure(v) && (id = teco_ring_get_first_dirty())) { + g_set_error(error, TECO_ERROR, TECO_ERROR_FAILED, + "Buffer with id %u is dirty", id); return; } } @@ -233,16 +233,20 @@ teco_ring_dirtify(void) teco_interface_info_update(teco_ring_current); } -gboolean -teco_ring_is_any_dirty(void) +/** Get id of first dirty buffer, or otherwise 0 */ +guint +teco_ring_get_first_dirty(void) { + guint id = 1; + for (teco_tailq_entry_t *cur = teco_ring_head.first; cur != NULL; cur = cur->next) { teco_buffer_t *buffer = (teco_buffer_t *)cur; if (buffer->dirty) - return TRUE; + return id; + id++; } - return FALSE; + return 0; } gboolean @@ -67,7 +67,7 @@ teco_buffer_t *teco_ring_find_by_id(teco_int_t id); teco_int_t : teco_ring_find_by_id)(X)) void teco_ring_dirtify(void); -gboolean teco_ring_is_any_dirty(void); +guint teco_ring_get_first_dirty(void); gboolean teco_ring_save_all_dirty_buffers(GError **error); gboolean teco_ring_edit_by_name(const gchar *filename, GError **error); |