Refactor the :OpenBookmark command
I altered the behavior of the ":OpenBookmark" command to match that of the "NERDTree-o" mapping. This is acceptable for the following reasons: 1. It was broken, so no one was using it. 2. The name matches its behavior. If a bookmark is to be opened in an explorer window, we should have a command with a matching name for that behavior (":ExploreBookmark", for example). This can be added later if there is enough demand for the feature. Otherwise, this is a perfectly valid change.
This commit is contained in:
parent
a03a639390
commit
3063dfb766
@ -441,21 +441,19 @@ function! s:jumpToSibling(currentNode, forward)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1
|
" FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1
|
||||||
" put the cursor on the given bookmark and, if its a file, open it
|
" Open the Bookmark that has the specified name. This function provides the
|
||||||
|
" implementation for the ":OpenBookmark" command.
|
||||||
function! nerdtree#ui_glue#openBookmark(name)
|
function! nerdtree#ui_glue#openBookmark(name)
|
||||||
try
|
try
|
||||||
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree)
|
let l:bookmark = g:NERDTreeBookmark.BookmarkFor(a:name)
|
||||||
call targetNode.putCursorHere(0, 1)
|
catch /^NERDTree.BookmarkNotFoundError/
|
||||||
redraw!
|
call nerdtree#echoError('bookmark "' . a:name . '" not found')
|
||||||
catch /^NERDTree.BookmarkedNodeNotFoundError/
|
return
|
||||||
call nerdtree#echo("note - target node is not cached")
|
|
||||||
let bookmark = g:NERDTreeBookmark.BookmarkFor(a:name)
|
|
||||||
let targetNode = g:NERDTreeFileNode.New(bookmark.path, b:NERDTree)
|
|
||||||
endtry
|
endtry
|
||||||
if targetNode.path.isDirectory
|
if l:bookmark.path.isDirectory
|
||||||
call targetNode.openExplorer()
|
call l:bookmark.open(b:NERDTree)
|
||||||
else
|
else
|
||||||
call targetNode.open({'where': 'p'})
|
call l:bookmark.open(b:NERDTree, {'where': 'p'})
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ click bookmarks or use the |NERDTree-o| mapping to activate them. See also,
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.2.2. Bookmark commands *NERDTreeBookmarkCommands*
|
2.2.2. Bookmark commands *NERDTreeBookmarkCommands*
|
||||||
|
|
||||||
Note that the following commands are only available in the NERD tree buffer.
|
Note: The following commands are only available within the NERDTree buffer.
|
||||||
|
|
||||||
:Bookmark [<name>]
|
:Bookmark [<name>]
|
||||||
Bookmark the current node as <name>. If there is already a <name>
|
Bookmark the current node as <name>. If there is already a <name>
|
||||||
@ -178,10 +178,11 @@ Note that the following commands are only available in the NERD tree buffer.
|
|||||||
(i.e. directory nodes above it will be opened) and the cursor will be
|
(i.e. directory nodes above it will be opened) and the cursor will be
|
||||||
placed on it.
|
placed on it.
|
||||||
|
|
||||||
:OpenBookmark <bookmark>
|
:OpenBookmark <name>
|
||||||
<bookmark> must point to a file. The file is opened as though |NERDTree-o|
|
The Bookmark named <name> is opened as if |NERDTree-o| was applied to
|
||||||
was applied. If the node is cached under the current root then it will be
|
its entry in the Bookmark table. If the Bookmark points to a directory,
|
||||||
revealed and the cursor will be placed on it.
|
it is made the new root of the current NERDTree. If the Bookmark points
|
||||||
|
to a file, that file is opened for editing in another window.
|
||||||
|
|
||||||
:ClearBookmarks [<bookmarks>]
|
:ClearBookmarks [<bookmarks>]
|
||||||
Remove all the given bookmarks. If no bookmarks are given then remove all
|
Remove all the given bookmarks. If no bookmarks are given then remove all
|
||||||
|
@ -14,7 +14,7 @@ function! s:Creator._bindMappings()
|
|||||||
|
|
||||||
command! -buffer -nargs=? Bookmark :call nerdtree#ui_glue#bookmarkNode('<args>')
|
command! -buffer -nargs=? Bookmark :call nerdtree#ui_glue#bookmarkNode('<args>')
|
||||||
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#ui_glue#revealBookmark('<args>')
|
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#ui_glue#revealBookmark('<args>')
|
||||||
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call nerdtree#ui_glue#openBookmark('<args>')
|
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark call nerdtree#ui_glue#openBookmark('<args>')
|
||||||
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#ui_glue#clearBookmarks('<args>')
|
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#ui_glue#clearBookmarks('<args>')
|
||||||
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('<args>', b:NERDTree)
|
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('<args>', b:NERDTree)
|
||||||
command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() <bar> call b:NERDTree.render()
|
command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() <bar> call b:NERDTree.render()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user