Skip to content

Commit 1128bc3

Browse files
authored
Fix to checkbox completion (#474)
* fix: made checkbox completion handle [ input correctly * fix: fixed completion in tabulated, not last list_item * fix: checkbox cmp on newline before indent May be a clumsy fix * fix: removed debug output and stuff * fix: removed extra bracket check
1 parent 7620d4e commit 1128bc3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lua/render-markdown/integ/source.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ function M.items(buf, row, col)
5050
end
5151

5252
local marker = vim.treesitter.get_node_text(marker_node, buf)
53-
local text = vim.treesitter.get_node_text(node, buf)
54-
if M.ignore(marker, text:gsub('\n$', '')) then
53+
local text = vim.treesitter.get_node_text(node, buf):gsub('\n%s*$', '')
54+
if M.ignore(marker, text) then
5555
return nil
5656
end
5757

@@ -116,7 +116,11 @@ end
116116
---@param text string
117117
---@return boolean
118118
function M.ignore(marker, text)
119-
local prefix = vim.pesc(vim.trim(marker)) .. '%s+'
119+
local prefix = '^' .. vim.pesc(vim.trim(marker)) .. '%s+'
120+
local i, j = text:find(prefix)
121+
if not (i and j) or text:sub(i, j):find('\n') then
122+
return false
123+
end
120124
local patterns = {} ---@type string[]
121125
-- first non-space after the marker is not '['
122126
patterns[#patterns + 1] = prefix .. '[^%[]'

0 commit comments

Comments
 (0)