Skip to content

Commit 4ab8359

Browse files
Recompute marks if missing instead of ignoring
1 parent b7cf9e9 commit 4ab8359

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

Diff for: justfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
init := "tests/minimal.lua"
22

3+
default: update test health
4+
35
test:
46
nvim --headless --noplugin -u {{init}} \
57
-c "PlenaryBustedDirectory tests { minimal_init = '{{init}}', sequential=true }"

Diff for: lua/render-markdown/ui.lua

+11-13
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,14 @@ M.refresh = function(buf, mode, parse)
6464
util.set_win_option(win, name, value.rendered)
6565
end
6666

67-
-- Re compute marks, needed in-between text changes
68-
if parse then
69-
local parser = vim.treesitter.get_parser(buf)
67+
-- Re-compute marks, needed if missing or between text changes
68+
local marks = cache.marks[buf]
69+
if marks == nil or parse then
70+
marks = {}
7071
-- Make sure injections are processed
72+
local parser = vim.treesitter.get_parser(buf)
7173
parser:parse(true)
7274
-- Parse and cache marks
73-
local marks = {}
7475
parser:for_each_tree(function(tree, language_tree)
7576
vim.list_extend(marks, M.parse(buf, language_tree:lang(), tree:root()))
7677
end)
@@ -79,15 +80,12 @@ M.refresh = function(buf, mode, parse)
7980

8081
-- Render marks based on anti-conceal behavior and current row
8182
local row = vim.api.nvim_win_get_cursor(util.buf_to_win(buf))[1] - 1
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
83+
for _, mark in ipairs(marks) do
84+
if not state.config.anti_conceal.enabled or not mark.conceal or mark.start_row ~= row then
85+
-- Only ensure strictness if the buffer was parsed this request
86+
-- The order of events can cause our cache to be stale
87+
mark.opts.strict = parse
88+
vim.api.nvim_buf_set_extmark(buf, M.namespace, mark.start_row, mark.start_col, mark.opts)
9189
end
9290
end
9391
end

0 commit comments

Comments
 (0)