Skip to content

Commit 4602797

Browse files
committed
fix: add check for nil value before passing to ipairs. Fix MeanderingProgrammer#65
1 parent 1387615 commit 4602797

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lua/render-markdown/ui.lua

+9-6
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,15 @@ M.refresh = function(buf, mode, parse)
7979

8080
-- Render marks based on anti-conceal behavior and current row
8181
local row = vim.api.nvim_win_get_cursor(util.buf_to_win(buf))[1] - 1
82-
for _, mark in ipairs(cache.marks[buf]) do
83-
if not state.config.anti_conceal.enabled or not mark.conceal or mark.start_row ~= row then
84-
-- Only ensure strictness if the buffer was parsed this request
85-
-- The order of events can cause our cache to be stale
86-
mark.opts.strict = parse
87-
vim.api.nvim_buf_set_extmark(buf, M.namespace, mark.start_row, mark.start_col, mark.opts)
82+
local marks = cache.marks[buf]
83+
if marks then
84+
for _, mark in ipairs(cache.marks[buf]) do
85+
if not state.config.anti_conceal.enabled or not mark.conceal or mark.start_row ~= row then
86+
-- Only ensure strictness if the buffer was parsed this request
87+
-- The order of events can cause our cache to be stale
88+
mark.opts.strict = parse
89+
vim.api.nvim_buf_set_extmark(buf, M.namespace, mark.start_row, mark.start_col, mark.opts)
90+
end
8891
end
8992
end
9093
end

0 commit comments

Comments
 (0)