treesitter: call bufload before parsing (#12603)

This commit is contained in:
Thomas Vigouroux
2020-07-10 15:33:27 +02:00
committed by GitHub
parent b39edb5b60
commit 529251d5e4
2 changed files with 8 additions and 3 deletions

View File

@@ -75,6 +75,9 @@ function M.create_parser(bufnr, lang, id)
if bufnr == 0 then
bufnr = a.nvim_get_current_buf()
end
vim.fn.bufload(bufnr)
local self = setmetatable({bufnr=bufnr, lang=lang, valid=false}, Parser)
self._parser = vim._create_ts_parser(lang)
self.change_cbs = {}

View File

@@ -307,11 +307,13 @@ static int parser_parse_buf(lua_State *L)
}
long bufnr = lua_tointeger(L, 2);
void *payload = handle_get_buffer(bufnr);
if (!payload) {
buf_T *buf = handle_get_buffer(bufnr);
if (!buf) {
return luaL_error(L, "invalid buffer handle: %d", bufnr);
}
TSInput input = { payload, input_cb, TSInputEncodingUTF8 };
TSInput input = { (void *)buf, input_cb, TSInputEncodingUTF8 };
TSTree *new_tree = ts_parser_parse(p->parser, p->tree, input);
uint32_t n_ranges = 0;