commit f4ff6dcf84bff73e6cc0e49410e28d0fb65ad73a parent d7cf9a2a9802f580c988f69f129ab7b187debb4c Author: Jason Franklin <j_fra@fastmail.us> Date: Sat, 19 Aug 2017 08:58:57 -0400 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. Diffstat:
| M | nerdtree_plugin/fs_menu.vim | | | 38 | ++++++++++++++++++++++++++++++++------ |
1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim @@ -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
