From 4fcf926451ae85f2b6ed00eae7067ddaa23b29ca Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Tue, 8 Jul 2025 16:37:12 +0100 Subject: [PATCH] Check for existence of next line --- plugins/markdown-actions/markdown-actions.vala | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/markdown-actions/markdown-actions.vala b/plugins/markdown-actions/markdown-actions.vala index a446edaee..65b712da7 100644 --- a/plugins/markdown-actions/markdown-actions.vala +++ b/plugins/markdown-actions/markdown-actions.vala @@ -123,10 +123,10 @@ public class Code.Plugins.MarkdownActions : Peas.ExtensionBase, Scratch.Services var line = get_current_line (next).strip (); // Get list item number from current line parse_ordered_list_item (line, ref count, out item_text); - // Start checking following lines - next.forward_line (); - line = get_current_line (next).strip (); - while (parse_ordered_list_item (line, ref count, out item_text)) { + while ( + next.forward_line () && + parse_ordered_list_item (get_current_line (next).strip (), ref count, out item_text) + ) { count++; var next_mark = current_buffer.create_mark (null, next, true); var point_offset = line.index_of_char ('.'); @@ -139,8 +139,6 @@ public class Code.Plugins.MarkdownActions : Peas.ExtensionBase, Scratch.Services var to_insert = "%d".printf (count); current_buffer.insert (ref next, to_insert, to_insert.length); - next.forward_line (); - line = get_current_line (next).strip (); } }