mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
fix(treesitter): don't spam query errors in the highlighter
**Problem:** An erroneous query in the treesitter highlighter gives a
deluge of errors that makes the editor almost unusable.
**Solution:** Detach the highlighter after an error is detected, so that
it only gets displayed once (per highlighter instance).
(cherry picked from commit b0bbe25c48
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
d65ce60f49
commit
00d3956109
@@ -240,7 +240,12 @@ end
|
||||
---@return vim.treesitter.highlighter.Query
|
||||
function TSHighlighter:get_query(lang)
|
||||
if not self._queries[lang] then
|
||||
self._queries[lang] = TSHighlighterQuery.new(lang)
|
||||
local success, result = pcall(TSHighlighterQuery.new, lang)
|
||||
if not success then
|
||||
self:destroy()
|
||||
error(result)
|
||||
end
|
||||
self._queries[lang] = result
|
||||
end
|
||||
|
||||
return self._queries[lang]
|
||||
|
Reference in New Issue
Block a user