-
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
Can't open directory after latest update #1205
Comments
Can you take another look your PR #1200? The Also, can you rewrite your type checking to be backward compatible as explained in
|
@sunnyguan I reverted the PR that introduced the bug. Another |
Sorry @RobertAudi. I tagged the wrong person. I've been in front of the screen for too long. @przepompownia, Please see the comment above. Thanks. |
function! s:initCustomOpenArgs(customOpenArgs) abort
let l:defaultOpenArgs = {'file': {'reuse': 'all', 'where': 'p'}, 'dir': {}}
let l:customOpenArgs = a:customOpenArgs
if v:false is# s:validateType(l:customOpenArgs, type({})) || empty(l:customOpenArgs)
let g:NERDTreeCustomOpenArgs = l:customOpenArgs
return l:defaultOpenArgs
endif
for l:typeKey in keys(l:defaultOpenArgs)
if v:false is# s:validateType(get(l:customOpenArgs, l:typeKey, {}), type({}))
\ || !has_key(l:customOpenArgs, l:typeKey)
let l:customOpenArgs[l:typeKey] = l:defaultOpenArgs[l:typeKey]
continue
endif
for l:optionName in keys(l:defaultOpenArgs[l:typeKey])
if s:validateType(get(l:customOpenArgs[l:typeKey], l:optionName, v:null), type(''))
continue
endif
let l:customOpenArgs[l:typeKey][l:optionName] = l:defaultOpenArgs[l:typeKey][l:optionName]
endfor
endfor
return extend(l:customOpenArgs, l:defaultOpenArgs, 'keep')
endfunction
function! s:validateType(variable, type)
if type(a:variable) is# a:type
return v:true
endif
return v:false
endfunction
function! s:testInitCustomOpenArgs(options, expectedResult)
call assert_equal(a:expectedResult, s:initCustomOpenArgs(a:options))
endfunction
function! s:testValidateType(variable, expectedResult)
call assert_true(s:validateType(a:variable, a:expectedResult))
endfunction
let v:errors = []
let defaultOpenArgs = {'file': {'reuse': 'all', 'where': 'p'}, 'dir': {}}
call s:testValidateType({}, v:t_dict)
call s:testValidateType(defaultOpenArgs['file']['where'], v:t_string)
call s:testInitCustomOpenArgs(1, defaultOpenArgs)
call s:testInitCustomOpenArgs({}, defaultOpenArgs)
call s:testInitCustomOpenArgs({'file': 1}, defaultOpenArgs)
call s:testInitCustomOpenArgs({'file': {}, 'dir': 'foo'}, defaultOpenArgs)
call s:testInitCustomOpenArgs(
\ {'file': {'reuse': [1], 'where': 'w', 'foo': []}},
\ {'file': {'reuse': 'all', 'where': 'w', 'foo': []}, 'dir': {}}
\ )
call s:testInitCustomOpenArgs(
\ {'file': {'reuse': [1], 'foo': []}},
\ {'file': {'reuse': 'all', 'where': 'p', 'foo': []}, 'dir': {}}
\ )
call s:testInitCustomOpenArgs(
\ {'file': {'reuse': [1], 'foo': []}},
\ {'file': {'reuse': 'all', 'where': 'p', 'foo': []}, 'dir': {}}
\ )
if !len(v:errors)
echom 'Success!'
finish
endif
echoerr v:errors Apart from fixing it for the case when |
* Fix missing key case, add BC type checking Resolves #1205 * Assign g:NERDTreeCustomOpenArgs also before quick return * Fix syntax to be compatibile with Vim 7.3
Self-Diagnosis
:h NERDTree
Environment (for bug reports)
:echo v:version
: Neovim 0.5.0, Vim 8.0.0?
: 6.9.12Steps to Reproduce the Issue
:PlugUpdate
for vim-plug):NERDTree
Current Result (Include screenshots where appropriate.)
Error pops up:
Expected Result
Directory opens correctly without errors.
I have tested this with the last release (tag 6.9.11) and there were no issues with opening folders. NERDTree was the only plugin to be installed when testing both versions. I think this is related to #1200 but I'm not technically proficient enough to be sure.
The text was updated successfully, but these errors were encountered: