diff options
| author | Thomas Vigouroux <tomvig38@gmail.com> | 2021-04-22 15:18:04 +0200 |
|---|---|---|
| committer | Thomas Vigouroux <tomvig38@gmail.com> | 2021-04-22 16:30:31 +0200 |
| commit | 41ed83ffc762b611644a311e344b33d5efc01944 (patch) | |
| tree | 60fede14f9168b824baf6d25e162b0b1161978bf /lua | |
| parent | fix(c): fold switch statements (diff) | |
| download | nvim-treesitter-41ed83ffc762b611644a311e344b33d5efc01944.tar nvim-treesitter-41ed83ffc762b611644a311e344b33d5efc01944.tar.gz nvim-treesitter-41ed83ffc762b611644a311e344b33d5efc01944.tar.bz2 nvim-treesitter-41ed83ffc762b611644a311e344b33d5efc01944.tar.lz nvim-treesitter-41ed83ffc762b611644a311e344b33d5efc01944.tar.xz nvim-treesitter-41ed83ffc762b611644a311e344b33d5efc01944.tar.zst nvim-treesitter-41ed83ffc762b611644a311e344b33d5efc01944.zip | |
fix(folds): always fold more than one line
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-treesitter/fold.lua | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lua/nvim-treesitter/fold.lua b/lua/nvim-treesitter/fold.lua index d1416ef4b..124cfa2ed 100644 --- a/lua/nvim-treesitter/fold.lua +++ b/lua/nvim-treesitter/fold.lua @@ -30,9 +30,11 @@ local folds_levels = tsutils.memoize_by_buf_tick(function(bufnr) stop = stop + 1 end + local should_fold = start + 1 > stop -- Only fold for 2+ lines + -- This can be folded -- Fold only multiline nodes that are not exactly the same as previously met folds - if start ~= stop and not (levels_tmp[start] and levels_tmp[stop]) then + if should_fold and not (levels_tmp[start] and levels_tmp[stop]) then levels_tmp[start] = (levels_tmp[start] or 0) + 1 levels_tmp[stop] = (levels_tmp[stop] or 0) - 1 end |
