Skip to content
This repository was archived by the owner on Sep 12, 2022. It is now read-only.

Commit 31b84a3

Browse files
committed
Play nice with builtin fold.
1 parent 95dfec3 commit 31b84a3

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

autoload/netranger/fold.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function! netranger#fold#foldtext()
2+
return substitute(getline(v:foldstart), '\e\[[0-9;]*m', '', 'g')
3+
endfunction

plugin/netranger.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function NetrangerInit()
4040
autocmd Filetype netranger autocmd WinEnter <buffer> exec g:_NETRPY.'ranger.on_winenter('.expand("<abuf>").')'
4141
autocmd Filetype netranger autocmd CursorMoved <buffer> exec g:_NETRPY.'ranger.on_cursormoved('.expand("<abuf>").')'
4242
autocmd Filetype netranger autocmd BufWriteCmd <buffer> exec g:_NETRPY.'ranger.NETRSave()'
43+
autocmd Filetype netranger setlocal foldtext=netranger#fold#foldtext()
4344
autocmd ColorScheme * call netranger#syntax#define()
4445
augroup END
4546
silent doautocmd USER NETRInit

pythonx/netranger/netranger.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,10 @@ def NETRToggleExpand(self):
16261626
""" Expand the current node. """
16271627
if self.cur_buf.fs_busy():
16281628
return
1629-
self.cur_buf.toggle_expand()
1629+
if int(Vim.eval('foldclosed(".")')) > -1:
1630+
Vim.command('normal! za')
1631+
else:
1632+
self.cur_buf.toggle_expand()
16301633

16311634
def NETRToggleExpandRec(self):
16321635
""" Expand the current node recursively. """

0 commit comments

Comments
 (0)