Skip to content

Commit

Permalink
Merge pull request #434 from mopp/add_open_drop
Browse files Browse the repository at this point in the history
add <Plug>(fern-action-open:drop)
  • Loading branch information
lambdalisue authored Jul 21, 2022
2 parents 951a05d + 92cb78c commit e90cdeb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions autoload/fern/mapping/open.vim
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function! fern#mapping#open#init(disable_default_mappings) abort
nnoremap <buffer><silent> <Plug>(fern-action-open:leftest) :<C-u>call <SID>call('open', 'topleft vsplit')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-open:bottom) :<C-u>call <SID>call('open', 'botright split')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-open:rightest) :<C-u>call <SID>call('open', 'botright vsplit')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-open:drop) :<C-u>call <SID>call('open', 'drop')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-open:edit-or-error) :<C-u>call <SID>call('open', 'edit')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-open:edit-or-split) :<C-u>call <SID>call('open', 'edit/split')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-open:edit-or-vsplit) :<C-u>call <SID>call('open', 'edit/vsplit')<CR>
Expand Down
4 changes: 4 additions & 0 deletions doc/fern.txt
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,10 @@ GLOBAL *fern-mapping-global*
The command will be applied on an "anchor" window when invoked from a
drawer style fern (|fern-glossary-anchor|.)

*<Plug>(fern-action-open:drop)*
Open a cursor node or jump the window when it was already opend.
Note See |drop| for more details.

*<Plug>(fern-action-open:edit-or-error)*
Open a cursor node or marked nodes with |edit| command or fallback
to print an error.
Expand Down
16 changes: 16 additions & 0 deletions test/fern/internal/buffer.vimspec
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,22 @@ Describe fern#internal#buffer
\ 'opener': 'vsplit',
\})
Assert Equals(winnr('$'), 2)
%bwipeout!

call fern#internal#buffer#open('hello1', {
\ 'opener': 'edit',
\})
call fern#internal#buffer#open('hello2', {
\ 'opener': 'vsplit',
\})
call fern#internal#buffer#open('hello1', {
\ 'opener': 'drop',
\})
Assert Equals(winnr(), 2)
call fern#internal#buffer#open('hello2', {
\ 'opener': 'drop',
\})
Assert Equals(winnr(), 1)
End
End
End

0 comments on commit e90cdeb

Please sign in to comment.