Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support unusual characters in file and directory names #868

Merged
merged 21 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
862ce06
Use a delimiter in node to separate file/dir name from the rest.
Jul 5, 2018
2e55cea
Switch warning message to use nerdtree#deprecated function.
Jul 30, 2018
a5ed6e2
Compress the space between the tree symbols and the node.
Jul 30, 2018
0c4834b
Include the delimiter when calculating indent or getting filename.
Jul 30, 2018
0aa80e1
Don't need to strip leading delimiter. It will already be gone.
Jul 30, 2018
e44edbc
Simplify the way the delimiter is being used.
Aug 4, 2018
682ab85
Add syntax highlighting to conceal the delimiter
Aug 4, 2018
8e87744
Put a if has("conceal") check around the syntax statement using it.
Aug 4, 2018
402717d
Merge branch 'master' into nonstandard-characters
Aug 4, 2018
50886c1
Merge branch 'master' into nonstandard-characters
Aug 4, 2018
6a6a801
Make concealment work correctly for LinkFile and readonly files.
PhilRunninger Aug 4, 2018
0af0ac4
Use highlight Ignore if conceal isn't available.
Aug 7, 2018
5bdfbc1
Make the regex better match the original, but more compact.
Aug 8, 2018
8cf55d9
Fix the syntax highlighing of delimiters around NERDTreeExecFile.
Aug 20, 2018
c5cbe60
Bug fix: Parse . and .. from path string with trailing slash.
Aug 20, 2018
e1af7a3
Fix unresponsive cascaded directories.
Sep 10, 2018
b403c8f
Merge branch 'master' into nonstandard-characters
Oct 18, 2018
d64fb3b
Use .= to shorten statement. Use clearer substitutes to get node name.
Oct 18, 2018
18a148e
Remove node delimiters that terminate the line.
Oct 18, 2018
e37ba2b
DRY up the addition of the 2nd delimiter, and use only 1 for all tags.
Oct 19, 2018
bc018ec
Merge branch 'master' into nonstandard-characters
Oct 19, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions lib/nerdtree/path.vim
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ endfunction

" FUNCTION: Path.cacheDisplayString() {{{1
function! s:Path.cacheDisplayString() abort
let self.cachedDisplayString = self.getLastPathComponent(1)
let self.cachedDisplayString = g:NERDTreeNodeDelimiter . self.getLastPathComponent(1)

if self.isExecutable
let self.cachedDisplayString = self.cachedDisplayString . '*'
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . '*'
endif

let self._bookmarkNames = []
Expand All @@ -52,15 +52,24 @@ function! s:Path.cacheDisplayString() abort
endif
endfor
if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks == 1
let self.cachedDisplayString .= ' {' . join(self._bookmarkNames) . '}'
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' {' . join(self._bookmarkNames) . '}'
endif

if self.isSymLink
let self.cachedDisplayString .= ' -> ' . self.symLinkDest
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' -> ' . self.symLinkDest
endif

if self.isReadOnly
let self.cachedDisplayString .= ' ['.g:NERDTreeGlyphReadOnly.']'
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' ['.g:NERDTreeGlyphReadOnly.']'
endif
endfunction

" FUNCTION: Path.addDelimiter() {{{1
function! s:Path.addDelimiter(line)
if a:line =~# '\(.*' . g:NERDTreeNodeDelimiter . '\)\{2}'
return a:line
else
return a:line . g:NERDTreeNodeDelimiter
endif
endfunction

Expand Down
9 changes: 6 additions & 3 deletions lib/nerdtree/tree_dir_node.vim
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ function! s:TreeDirNode.displayString()
let l:label = ''
let l:cascade = self.getCascade()
for l:dirNode in l:cascade
let l:label .= l:dirNode.path.displayString()
let l:next = l:dirNode.path.displayString()
let l:label .= l:label == '' ? l:next : strcharpart(l:next,1)
endfor

" Select the appropriate open/closed status indicator symbol.
Expand Down Expand Up @@ -304,9 +305,11 @@ function! s:TreeDirNode._glob(pattern, all)
for l:file in l:globList
let l:tail = fnamemodify(l:file, ':t')

" Double the modifier if only a separator was stripped.
" If l:file has a trailing slash, then its :tail will be ''. Use
" :h to drop the slash and the empty string after it; then use :t
" to get the directory name.
if l:tail == ''
let l:tail = fnamemodify(l:file, ':t:t')
let l:tail = fnamemodify(l:file, ':h:t')
endif

if l:tail == '.' || l:tail == '..'
Expand Down
2 changes: 1 addition & 1 deletion lib/nerdtree/tree_file_node.vim
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ endfunction

" FUNCTION: TreeFileNode.openInNewTab(options) {{{1
function! s:TreeFileNode.openInNewTab(options)
echomsg 'TreeFileNode.openInNewTab is deprecated'
call nerdtree#deprecated('TreeFileNode.openinNewTab', 'is deprecated, use .open() instead.')
call self.open(extend({'where': 't'}, a:options))
endfunction

Expand Down
25 changes: 4 additions & 21 deletions lib/nerdtree/ui.vim
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ endfunction

" FUNCTION: s:UI.MarkupReg() {{{1
function! s:UI.MarkupReg()
return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+\)'
return '^ *['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']\? '
endfunction

" FUNCTION: s:UI._renderBookmarks {{{1
Expand Down Expand Up @@ -363,30 +363,13 @@ function! s:UI.setShowHidden(val)
endfunction

" FUNCTION: s:UI._stripMarkup(line){{{1
" returns the given line with all the tree parts stripped off
" find the filename in the given line, and return it.
"
" Args:
" line: the subject line
function! s:UI._stripMarkup(line)
let line = a:line
" remove the tree parts and the leading space
let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","")

" strip off any read only flag
let line = substitute (line, ' \['.g:NERDTreeGlyphReadOnly.'\]', "","")

" strip off any bookmark flags
let line = substitute (line, ' {[^}]*}', "","")

" strip off any executable flags
let line = substitute (line, '*\ze\($\| \)', "","")

" strip off any generic flags
let line = substitute (line, '\[[^]]*\]', "","")

let line = substitute (line,' -> .*',"","") " remove link to

return line
let l:line = substitute(a:line, '^.\{-}' . g:NERDTreeNodeDelimiter, '', '')
return substitute(l:line, g:NERDTreeNodeDelimiter.'.*$', '', '')
endfunction

" FUNCTION: s:UI.render() {{{1
Expand Down
3 changes: 3 additions & 0 deletions plugin/NERD_tree.vim
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ let g:NERDTreeOldSortOrder = []

call s:initVariable("g:NERDTreeGlyphReadOnly", "RO")

" ASCII 160: non-breaking space used to delimit items in the tree's nodes.
call s:initVariable("g:NERDTreeNodeDelimiter", "\u00a0")

if !exists('g:NERDTreeStatusline')

"the exists() crap here is a hack to stop vim spazzing out when
Expand Down
9 changes: 9 additions & 0 deletions syntax/nerdtree.vim
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ exec 'syn match NERDTreeRO # *\zs.*\ze \['.g:NERDTreeGlyphReadOnly.'\]# contains
syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile,NERDTreeExecFile
syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir

"highlighing to conceal the delimiter around the file/dir name
if has("conceal")
exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# conceal containedin=NERDTreeFile,NERDTreeLinkFile,NERDTreeExecFile,NERDTreeRO,NERDTreeDir'
setlocal conceallevel=2 concealcursor=nvic
else
exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# containedin=NERDTreeFile,NERDTreeLinkFile,NERDTreeExecFile,NERDTreeRO,NERDTreeDir'
hi! link NERDTreeNodeDelimiters Ignore
endif

syn match NERDTreeCWD #^[</].*$#

"highlighting for bookmarks
Expand Down