Skip to content

Commit cbd2550

Browse files
authored
Check for existence of next line (#1630)
1 parent a388f9c commit cbd2550

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

plugins/markdown-actions/markdown-actions.vala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ public class Code.Plugins.MarkdownActions : Peas.ExtensionBase, Scratch.Services
123123
var line = get_current_line (next).strip ();
124124
// Get list item number from current line
125125
parse_ordered_list_item (line, ref count, out item_text);
126-
// Start checking following lines
127-
next.forward_line ();
128-
line = get_current_line (next).strip ();
129-
while (parse_ordered_list_item (line, ref count, out item_text)) {
126+
while (
127+
next.forward_line () &&
128+
parse_ordered_list_item (get_current_line (next).strip (), ref count, out item_text)
129+
) {
130130
count++;
131131
var next_mark = current_buffer.create_mark (null, next, true);
132132
var point_offset = line.index_of_char ('.');
@@ -139,8 +139,6 @@ public class Code.Plugins.MarkdownActions : Peas.ExtensionBase, Scratch.Services
139139

140140
var to_insert = "%d".printf (count);
141141
current_buffer.insert (ref next, to_insert, to_insert.length);
142-
next.forward_line ();
143-
line = get_current_line (next).strip ();
144142
}
145143
}
146144

0 commit comments

Comments
 (0)