-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
folder listing (menu m-l) not working for my locale #883
Comments
Not sure about the corresponding linux function. This might need a fix too. |
I hacked together the following code which seems to do the job: " FUNCTION: NERDTreeListNodeWin32() {{{1
function! NERDTreeListNodeWin32()
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
" try different short date formats...
let l:short_date_regex = [
\ '^[01][0-9][/-][0-3][0-9][/-][12][0-9][0-9][0-9]',
\ '^[0-3][0-9][/-][01][0-9][/-][12][0-9][0-9][0-9]',
\ '^[12][0-9][0-9][0-9][/-][01][0-9][/-][0-3][0-9]',
\ '^[01][0-9][/-][0-3][0-9][/-][0-9][0-9]',
\ '^[0-3][0-9][/-][01][0-9][/-][0-9][0-9]',
\ '^[0-9][0-9][/-][01][0-9][/-][0-3][0-9]'
\]
for regex in l:short_date_regex
let l:command = 'DIR /Q '
\ . shellescape(l:node.path.str())
\ . ' | FINDSTR ' . regex
let l:metadata = split(system(l:command), "\n")
if v:shell_error == 0
break
endif
endfor
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('l:save_shellslash')
let &shellslash = l:save_shellslash
endif
return
endif
call nerdtree#echo('node not recognized')
endfunction |
Further tweaked code which makes use of vim-misc plugin to prevent cmd window popups in the background (maybe a no-go but hey it workes nicely): " FUNCTION: NERDTreeListNodeWin32() {{{1
function! NERDTreeListNodeWin32()
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
" try different short date formats...
let l:short_date_regex = [
\ '^[01][0-9][/-][0-3][0-9][/-][12][0-9][0-9][0-9]',
\ '^[0-3][0-9][/-][01][0-9][/-][12][0-9][0-9][0-9]',
\ '^[12][0-9][0-9][0-9][/-][01][0-9][/-][0-3][0-9]',
\ '^[01][0-9][/-][0-3][0-9][/-][0-9][0-9]',
\ '^[0-3][0-9][/-][01][0-9][/-][0-9][0-9]',
\ '^[0-9][0-9][/-][01][0-9][/-][0-3][0-9]'
\]
let l:command = 'DIR /Q '
\ . shellescape(l:node.path.str())
\ . ' | FINDSTR '
for regex in l:short_date_regex
" Use xolox#misc#os#exec() from vim-misc plugin which has the
" advantage of suppressing the cmd window popup in the background
" (this happens with the Vim builtin system() function).
let l:listNode = xolox#misc#os#exec({
\ 'command': l:command.regex,
\ 'async': 0,
\ 'check': 0
\})
if l:listNode['exit_code'] == 0
break
endif
endfor
if l:listNode['exit_code'] == 0
call nerdtree#echo(l:listNode['stdout'][0])
else
call nerdtree#echoError('shell command failed')
endif
let &shell = l:save_shell
if exists('l:save_shellslash')
let &shellslash = l:save_shellslash
endif
return
endif
call nerdtree#echo('node not recognized')
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
Hitting m-l on a folder in NERDTree gives me 'shell command failed'. I tracked down the error to
FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"
in file fs_menu.vim, function NERDTreeListNodeWin32(). The system date format for my Windows installation is set to yyyy-MM-dd, whereas the regular expression searches for MM-dd-yyyy.
Environment
Vim 8.1.1 with latest NERDTree, Windows 10 set to English language
The text was updated successfully, but these errors were encountered: