From: Olaf Wintermann Date: Sat, 29 Mar 2025 08:34:50 +0000 (+0100) Subject: fix editor_get_markdown does not get text from the last section sometimes X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=b0c1fdefe471002fd9758d9a6584f390a575f702;p=note.git fix editor_get_markdown does not get text from the last section sometimes --- diff --git a/application/gtk-text.c b/application/gtk-text.c index 41156e9..dfd65b0 100644 --- a/application/gtk-text.c +++ b/application/gtk-text.c @@ -728,11 +728,19 @@ cxmutstr editor_get_markdown(UiText *text, const CxAllocator *a) { GtkTextChildAnchor *anchor = NULL; + GtkTextIter end_iter; + gtk_text_buffer_get_iter_at_offset(buffer, &end_iter, -1); + int end_offset = gtk_text_iter_get_offset(&end_iter); + GtkTextIter start; GtkTextIter iter; gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0); start = iter; - while(gtk_text_iter_forward_to_tag_toggle(&iter, NULL)) { + while(gtk_text_iter_get_offset(&iter) < end_offset) { + if(!gtk_text_iter_forward_to_tag_toggle(&iter, NULL)) { + iter = end_iter; + } + if(anchor) { EmbeddedWidget *em = g_object_get_data(G_OBJECT(anchor), "em"); if(em) { @@ -752,6 +760,7 @@ cxmutstr editor_get_markdown(UiText *text, const CxAllocator *a) { } } if(!anchor) { + // we have not checked the anchor at iter anchor = gtk_text_iter_get_child_anchor(&iter); }