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.
This commit is contained in:
Phil Runninger 2019-04-22 15:58:06 -04:00 committed by GitHub
parent e126b8745d
commit 9226eab2a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -280,11 +280,10 @@ endfunction
" FUNCTION: s:UI._indentLevelFor(line) {{{1 " FUNCTION: s:UI._indentLevelFor(line) {{{1
function! s:UI._indentLevelFor(line) function! s:UI._indentLevelFor(line)
" have to do this work around because match() returns bytes, not chars " Replace multi-character DirArrows with a single space so the
let numLeadBytes = match(a:line, '\M\[^ '.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']') " indentation calculation doesn't get messed up.
" The next line is a backward-compatible workaround for strchars(a:line(0:numLeadBytes-1]). strchars() is in 7.3+ let l:line = substitute(substitute(a:line, g:NERDTreeDirArrowExpandable, ' ', ''), g:NERDTreeDirArrowCollapsible, ' ', '')
let leadChars = len(split(a:line[0:numLeadBytes-1], '\zs')) let leadChars = match(l:line, '\M\[^ ]')
return leadChars / s:UI.IndentWid() return leadChars / s:UI.IndentWid()
endfunction endfunction

View File

@ -77,6 +77,7 @@ else
call s:initVariable("g:NERDTreeDirArrowExpandable", "+") call s:initVariable("g:NERDTreeDirArrowExpandable", "+")
call s:initVariable("g:NERDTreeDirArrowCollapsible", "~") call s:initVariable("g:NERDTreeDirArrowCollapsible", "~")
endif endif
call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1) call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1)
call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1) call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1)