mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -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
|
||||
|
||||
for lnum=0,api.nvim_buf_line_count(bufnr) do
|
||||
current_level = current_level + (levels_tmp[lnum] or 0)
|
||||
levels[lnum + 1] = current_level
|
||||
local prefix= ''
|
||||
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
|
||||
|
||||
return levels
|
||||
|
|
@ -53,8 +60,7 @@ function M.get_fold_indic(lnum)
|
|||
|
||||
local levels = folds_levels(buf) or {}
|
||||
|
||||
return tostring(levels[lnum] or 0)
|
||||
|
||||
return levels[lnum] or '0'
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue