From f4ff6dcf84bff73e6cc0e49410e28d0fb65ad73a Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 19 Aug 2017 08:58:57 -0400 Subject: [PATCH] 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. --- 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 index e563a94..e42942c 100644 --- 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