Skip to content

Commit e856877

Browse files
committed
fix: Prevent infinite loop by using custom gmatch iterator (#237)
1 parent 8065d69 commit e856877

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lua/mkdnflow/links.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,8 +865,12 @@ M.createLink = function(args)
865865
-- is, perform the search until a match is found whose right edge follows
866866
-- the cursor position
867867
if cursor_word ~= '' then
868-
while right < col do
869-
left, right = string.find(line, cursor_word, right, true)
868+
for _left, _right in utils.betterGmatch(line, cursor_word) do
869+
if _right >= col then
870+
left = _left
871+
right = _right
872+
break
873+
end
870874
end
871875
else
872876
left, right = col + 1, col

0 commit comments

Comments
 (0)