aboutsummaryrefslogtreecommitdiff
path: root/test/helpers.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2023-08-10 14:21:56 +0100
committerLewis Russell <me@lewisr.dev>2023-08-12 16:11:36 +0100
commit2ca076e45fb3f1c08f6a1a374834df0701b8d778 (patch)
tree3338df585168c4e6455137757519ca0bcd211c8c /test/helpers.lua
parent5a25dcc5a4c73f50902432e32335ab073950cceb (diff)
downloadrneovim-2ca076e45fb3f1c08f6a1a374834df0701b8d778.tar.gz
rneovim-2ca076e45fb3f1c08f6a1a374834df0701b8d778.tar.bz2
rneovim-2ca076e45fb3f1c08f6a1a374834df0701b8d778.zip
feat(treesitter)!: incremental injection parsing
Problem: Treesitter highlighting is slow for large files with lots of injections. Solution: Only parse injections we are going to render during a redraw cycle. --- - `LanguageTree:parse()` will no longer parse injections by default and now requires an explicit range argument to be passed. - `TSHighlighter` now parses injections incrementally during on_win callbacks for the line range being rendered. - Plugins which require certain injections to be parsed must run `parser:parse({ start_row, end_row })` before using the tree.
Diffstat (limited to 'test/helpers.lua')
-rw-r--r--test/helpers.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/test/helpers.lua b/test/helpers.lua
index 8f06311a3c..f0e8576a3a 100644
--- a/test/helpers.lua
+++ b/test/helpers.lua
@@ -570,21 +570,23 @@ function module.concat_tables(...)
end
--- @param str string
---- @param leave_indent? boolean
+--- @param leave_indent? integer
--- @return string
function module.dedent(str, leave_indent)
-- find minimum common indent across lines
- local indent = nil
+ local indent --- @type string?
for line in str:gmatch('[^\n]+') do
local line_indent = line:match('^%s+') or ''
if indent == nil or #line_indent < #indent then
indent = line_indent
end
end
- if indent == nil or #indent == 0 then
+
+ if not indent or #indent == 0 then
-- no minimum common indent
return str
end
+
local left_indent = (' '):rep(leave_indent or 0)
-- create a pattern for the indent
indent = indent:gsub('%s', '[ \t]')