Skip to content

Commit

Permalink
fix: Prevent infinite loop by using custom gmatch iterator (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakewvincent committed Jul 10, 2024
1 parent 8065d69 commit e856877
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lua/mkdnflow/links.lua
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,12 @@ M.createLink = function(args)
-- is, perform the search until a match is found whose right edge follows
-- the cursor position
if cursor_word ~= '' then
while right < col do
left, right = string.find(line, cursor_word, right, true)
for _left, _right in utils.betterGmatch(line, cursor_word) do
if _right >= col then
left = _left
right = _right
break
end
end
else
left, right = col + 1, col
Expand Down

0 comments on commit e856877

Please sign in to comment.