nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 9226eab2a873400e0debecfb2a344ae88731a5f0
parent e126b8745dc40931ae8da03d92c78264e8e4b029
Author: Phil Runninger <PhilRunninger@users.noreply.github.com>
Date:   Mon, 22 Apr 2019 15:58:06 -0400

Allow multi-character DirArrows (#985)

* Add debugging messages to diagnose issue #931.

* Echo the CWD and NERDTree root too.

* Ensure DirArrows are trimmed to a single character.

Actually, it's up to the user to make sure it's a single character after
leading and trailing spaces are removed. Spaces need to be removed so
that an accurate level of indentation can be calculated.

* Remove debugging statements

* Simplify the algorithm for calculating indentation level.

1. Replace the DirArrows with a single space.
2. Count the leading spaces.
3. Divide by 2.

This allows users to specify multi-character arrows, where a spaces
prevent characters printing on top of each other.

Diffstat:
Mlib/nerdtree/ui.vim | 9++++-----
Mplugin/NERD_tree.vim | 1+
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim
@@ -280,11 +280,10 @@ endfunction
 
 " FUNCTION: s:UI._indentLevelFor(line) {{{1
 function! s:UI._indentLevelFor(line)
-    " have to do this work around because match() returns bytes, not chars
-    let numLeadBytes = match(a:line, '\M\[^ '.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']')
-    " The next line is a backward-compatible workaround for strchars(a:line(0:numLeadBytes-1]). strchars() is in 7.3+
-    let leadChars = len(split(a:line[0:numLeadBytes-1], '\zs'))
-
+    " Replace multi-character DirArrows with a single space so the
+    " indentation calculation doesn't get messed up.
+    let l:line = substitute(substitute(a:line, g:NERDTreeDirArrowExpandable, ' ', ''), g:NERDTreeDirArrowCollapsible, ' ', '')
+    let leadChars = match(l:line, '\M\[^ ]')
     return leadChars / s:UI.IndentWid()
 endfunction
 
diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim
@@ -77,6 +77,7 @@ else
     call s:initVariable("g:NERDTreeDirArrowExpandable", "+")
     call s:initVariable("g:NERDTreeDirArrowCollapsible", "~")
 endif
+
 call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1)
 call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1)