1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-14 15:19:12 +08:00

fix(core): fix Enter key in filetree(nerdtree)

The `Enter` key do not change the root to cursor directory.
As the documentation says, `Enter` key is used to open directory
or drop file.
This commit is contained in:
Shidong Wang 2021-09-21 23:46:10 +08:00
parent 492209fe89
commit 25bf4a1b32
No known key found for this signature in database
GPG Key ID: 41BB7053E835C848

View File

@ -31,6 +31,8 @@ function! s:nerdtreeinit() abort
nnoremap <silent><buffer> N :<C-u>call NERDTreeAddNode()<CR>
nnoremap <silent><buffer> . :<C-u>call <SID>nerdtree_dot()<CR>
nnoremap <silent><buffer> <C-Home> :<C-u>NERDTreeCWD<CR>
nnoremap <silent><buffer> <CR> :<C-u>call <SID>nerdtree_enter()<CR>
" nnoremap <silent><buffer> <CR> :<C-u>silent! exe 'NERDTree' g:NERDTreeFileNode.GetSelected().path.str()<CR>
endfunction
function! s:paste_to_file_manager() abort
@ -83,3 +85,12 @@ endfunction
function! s:nerdtree_dot() abort
call g:NERDTreeKeyMap.Invoke('I')
endfunction
function! s:nerdtree_enter() abort
let path = g:NERDTreeFileNode.GetSelected().path.str()
if isdirectory(path)
silent! exe 'NERDTree' g:NERDTreeFileNode.GetSelected().path.str()
else
call g:NERDTreeKeyMap.Invoke('o')
endif
endfunction