@@ -64,13 +64,14 @@ M.refresh = function(buf, mode, parse)
64
64
util .set_win_option (win , name , value .rendered )
65
65
end
66
66
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 = {}
70
71
-- Make sure injections are processed
72
+ local parser = vim .treesitter .get_parser (buf )
71
73
parser :parse (true )
72
74
-- Parse and cache marks
73
- local marks = {}
74
75
parser :for_each_tree (function (tree , language_tree )
75
76
vim .list_extend (marks , M .parse (buf , language_tree :lang (), tree :root ()))
76
77
end )
@@ -79,15 +80,12 @@ M.refresh = function(buf, mode, parse)
79
80
80
81
-- Render marks based on anti-conceal behavior and current row
81
82
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 )
91
89
end
92
90
end
93
91
end
0 commit comments