Skip to content

Commit 12d951d

Browse files
chore: pass callback to view.parse
## Details Missed the last thing we need to have in place to do async parsing, the ability to trigger a `callback` where we call `parser:parse()`. Added a `debug` statement when we skip parsing due to missing context.
1 parent 65bd8d0 commit 12d951d

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

lua/render-markdown/core/ui.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,12 @@ function Updater:parse(callback)
167167
local context = Context.new(self.buf, self.win, self.config, self.mode)
168168
if context then
169169
-- make sure injections are processed
170-
context.view:parse(parser)
171-
local marks = handlers.run(context, parser)
172-
callback(iter.list.map(marks, Extmark.new))
170+
context.view:parse(parser, function()
171+
local marks = handlers.run(context, parser)
172+
callback(iter.list.map(marks, Extmark.new))
173+
end)
173174
else
175+
log.buf('debug', 'Skip', self.buf, 'in progress')
174176
callback(nil)
175177
end
176178
else

lua/render-markdown/health.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local state = require('render-markdown.state')
55
local M = {}
66

77
---@private
8-
M.version = '8.6.3'
8+
M.version = '8.6.4'
99

1010
function M.check()
1111
M.start('version')

lua/render-markdown/request/view.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ function View:overlaps(node)
5757
end
5858

5959
---@param parser vim.treesitter.LanguageTree
60-
function View:parse(parser)
60+
---@param callback fun()
61+
function View:parse(parser, callback)
6162
for _, range in ipairs(self.ranges) do
6263
parser:parse({ range.top, range.bottom })
6364
end
65+
callback()
6466
end
6567

6668
---@param root TSNode

0 commit comments

Comments
 (0)