mirror of
https://github.com/preservim/nerdtree.git
synced 2024-11-22 09:53:18 +08:00
Respect NERDTreeCustomOpenArgs when opening bookmark (#1200)
* Respect NERDTreeCustomOpenArgs when opening bookmark * Update CHANGELOG * Do not duplicate s:initCustomOpenArgs() * Restore missing assignment * fixup! Restore missing assignment * fixup! Do not duplicate s:initCustomOpenArgs() * Simplify loop iteration
This commit is contained in:
parent
aaa946fb6b
commit
7e1713853a
|
@ -5,6 +5,7 @@
|
|||
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
|
||||
-->
|
||||
#### 6.9
|
||||
- **.12**: Respect NERDTreeCustomOpenArgs when opening bookmark (przepompownia) [#1200](https://github.com/preservim/nerdtree/pull/1200)
|
||||
- **.11**: Revamp the README. (buncis, PhilRunninger) [#1192](https://github.com/preservim/nerdtree/pull/1192), [#1193](https://github.com/preservim/nerdtree/pull/1193)
|
||||
- **.10**: Open a mirrored NERDTree with correct width (PhilRunninger) [#1177](https://github.com/preservim/nerdtree/pull/1177)
|
||||
- **.9**: Updated Readme, removed typo (H3RSKO) [#1167](https://github.com/preservim/nerdtree/pull/1167)
|
||||
|
|
|
@ -110,8 +110,38 @@ endfunction
|
|||
"FUNCTION: s:initCustomOpenArgs() {{{1
|
||||
" Make sure NERDTreeCustomOpenArgs has needed keys
|
||||
function! s:initCustomOpenArgs() abort
|
||||
let g:NERDTreeCustomOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {})
|
||||
return extend(g:NERDTreeCustomOpenArgs, {'file':{'reuse': 'all', 'where': 'p'}, 'dir':{}}, 'keep')
|
||||
let l:defaultOpenArgs = {'file': {'reuse': 'all', 'where': 'p'}, 'dir': {}}
|
||||
let l:customOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {})
|
||||
|
||||
if v:false is# s:validateType(l:customOpenArgs, v:t_dict)
|
||||
return l:defaultOpenArgs
|
||||
endif
|
||||
|
||||
for l:typeKey in keys(l:defaultOpenArgs)
|
||||
if v:false is# s:validateType(get(l:customOpenArgs, l:typeKey, {}), v:t_dict)
|
||||
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), v:t_string)
|
||||
continue
|
||||
endif
|
||||
let l:customOpenArgs[l:typeKey][l:optionName] = l:defaultOpenArgs[l:typeKey][l:optionName]
|
||||
endfor
|
||||
endfor
|
||||
|
||||
let g:NERDTreeCustomOpenArgs = l:customOpenArgs
|
||||
|
||||
return extend(l:customOpenArgs, l:defaultOpenArgs, 'keep')
|
||||
endfunction
|
||||
|
||||
function! s:validateType(variable, type) abort
|
||||
if type(a:variable) is# a:type
|
||||
return v:true
|
||||
endif
|
||||
|
||||
return v:false
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:activateAll() {{{1
|
||||
|
@ -500,9 +530,10 @@ function! nerdtree#ui_glue#openBookmark(name) abort
|
|||
endtry
|
||||
if l:bookmark.path.isDirectory
|
||||
call l:bookmark.open(b:NERDTree)
|
||||
else
|
||||
call l:bookmark.open(b:NERDTree, {'where': 'p'})
|
||||
return
|
||||
endif
|
||||
|
||||
call l:bookmark.open(b:NERDTree, s:initCustomOpenArgs().file)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:openHSplit(target) {{{1
|
||||
|
|
Loading…
Reference in New Issue
Block a user