mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-14 09:20:04 -04:00
fix(fold): fix #350
Also correctly handle things like :
if (foo) {
}
if (bar) {
}
This commit is contained in:
parent
545e5c479a
commit
36d2c7d746
1 changed files with 10 additions and 4 deletions
|
|
@ -39,8 +39,15 @@ local folds_levels = utils.memoize_by_buf_tick(function(bufnr)
|
||||||
local current_level = 0
|
local current_level = 0
|
||||||
|
|
||||||
for lnum=0,api.nvim_buf_line_count(bufnr) do
|
for lnum=0,api.nvim_buf_line_count(bufnr) do
|
||||||
current_level = current_level + (levels_tmp[lnum] or 0)
|
local prefix= ''
|
||||||
levels[lnum + 1] = current_level
|
local shift = levels_tmp[lnum] or 0
|
||||||
|
|
||||||
|
if levels_tmp[lnum] and shift >= 0 then
|
||||||
|
prefix = '>'
|
||||||
|
end
|
||||||
|
|
||||||
|
current_level = current_level + shift
|
||||||
|
levels[lnum + 1] = prefix .. tostring(current_level)
|
||||||
end
|
end
|
||||||
|
|
||||||
return levels
|
return levels
|
||||||
|
|
@ -53,8 +60,7 @@ function M.get_fold_indic(lnum)
|
||||||
|
|
||||||
local levels = folds_levels(buf) or {}
|
local levels = folds_levels(buf) or {}
|
||||||
|
|
||||||
return tostring(levels[lnum] or 0)
|
return levels[lnum] or '0'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue