fix!: indents now rely on treesitter highlight

- Apply suggestions from Lewis to only parse visible lines
- Fix failed tests
This commit is contained in:
Pham Huy Hoang 2023-09-04 16:19:33 +09:00 committed by Christian Clason
parent abcbe65b6e
commit 3966b8808b
2 changed files with 27 additions and 45 deletions

View file

@ -26,7 +26,6 @@ local function check_assertions(file)
)
local parser = ts.get_parser(buf, lang)
local self = parser
local top_level_root = parser:parse(true)[1]:root()
for _, assertion in ipairs(assertions) do
@ -37,7 +36,7 @@ local function check_assertions(file)
assertion.expected_capture_name = neg_assert and assertion.expected_capture_name:sub(2)
or assertion.expected_capture_name
local found = false
self:for_each_tree(function(tstree, tree)
parser:for_each_tree(function(tstree, tree)
if not tstree then
return
end
@ -50,11 +49,11 @@ local function check_assertions(file)
if assertion.expected_capture_name == tree:lang() then
found = true
end
end, true)
end)
if neg_assert then
assert.False(
found,
'Error in at '
'Error in '
.. file
.. ':'
.. (row + 1)
@ -67,7 +66,7 @@ local function check_assertions(file)
else
assert.True(
found,
'Error in at '
'Error in '
.. file
.. ':'
.. (row + 1)