Fix a menu command that breaks under 'shellslash'
The (l) menu command breaks on Windows systems when 'shellslash' is set. This is due to the fact that the menu item uses a hard coded shell command, thus relying on the use of the default Windows shell without the 'shellslash' setting. The pattern used for the fix is localized to the problem function. However, this technique could easily be abstracted into its own function to execute Windows shell commands with the default shell throughout the NERDTree codebase.
This commit is contained in:
parent
d7cf9a2a98
commit
f4ff6dcf84
@ -212,14 +212,40 @@ endfunction
|
||||
|
||||
" FUNCTION: NERDTreeListNodeWin32() {{{1
|
||||
function! NERDTreeListNodeWin32()
|
||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||
if treenode != {}
|
||||
let metadata = split(system('DIR /Q ' . shellescape(treenode.path.str()) . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'), '\n')
|
||||
call nerdtree#echo(metadata[0])
|
||||
else
|
||||
call nerdtree#echo("No information avaialable")
|
||||
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||
|
||||
if !empty(l:node)
|
||||
|
||||
let l:save_shell = &shell
|
||||
set shell&
|
||||
|
||||
if exists('+shellslash')
|
||||
let l:save_shellslash = &shellslash
|
||||
set noshellslash
|
||||
endif
|
||||
|
||||
let l:command = 'DIR /Q '
|
||||
\ . shellescape(l:node.path.str())
|
||||
\ . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'
|
||||
|
||||
let l:metadata = systemlist(l:command)
|
||||
|
||||
if v:shell_error == 0
|
||||
call nerdtree#echo(l:metadata[0])
|
||||
else
|
||||
call nerdtree#echoError('shell command failed')
|
||||
endif
|
||||
|
||||
let &shell = l:save_shell
|
||||
|
||||
if exists('+shellslash')
|
||||
let &shellslash = l:save_shellslash
|
||||
endif
|
||||
|
||||
return
|
||||
endif
|
||||
|
||||
call nerdtree#echo('node not recognized')
|
||||
endfunction
|
||||
|
||||
" FUNCTION: NERDTreeCopyNode() {{{1
|
||||
|
Loading…
Reference in New Issue
Block a user