Skip to content

Commit

Permalink
refactor: better implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvxa committed Dec 26, 2023
1 parent ddcb4a4 commit f66879f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
12 changes: 8 additions & 4 deletions autoload/nerdtree/ui_glue.vim
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,16 @@ function! s:jumpToSibling(node, forward) abort
endfunction

" FUNCTION: s:jumpToBookmarks() {{{1
" moves the cursor to the bookmark listing
" moves the cursor to the bookmark table
function! s:jumpToBookmarks() abort
try
call g:NERDTree.CursorToBookmarkTable()
catch /^NERDTree.BookmarkTableNotFoundError\|^NERDTree.IllegalOperationError/
call nerdtree#echoError('bookmark table is closed')
if b:NERDTree.ui.getShowBookmarks()
call g:NERDTree.CursorToBookmarkTable()
else
call b:NERDTree.ui.setShowBookmarks(1)
endif
catch /^NERDTree/
call nerdtree#echoError('Failed to jump to the bookmark table')
return
endtry
endfunction
Expand Down
14 changes: 10 additions & 4 deletions lib/nerdtree/ui.vim
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,10 @@ function! s:UI.toggleIgnoreFilter()
call self.centerView()
endfunction

" FUNCTION: s:UI.toggleShowBookmarks() {{{1
" Toggle the visibility of the Bookmark table.
function! s:UI.toggleShowBookmarks()
let self._showBookmarks = !self._showBookmarks
" FUNCTION: s:UI.setShowBookmarks() {{{1
" Sets the visibility of the Bookmark table.
function! s:UI.setShowBookmarks(value)
let self._showBookmarks = a:value

if self.getShowBookmarks()
call self.nerdtree.render()
Expand All @@ -504,6 +504,12 @@ function! s:UI.toggleShowBookmarks()
call self.centerView()
endfunction

" FUNCTION: s:UI.toggleShowBookmarks() {{{1
" Toggle the visibility of the Bookmark table.
function! s:UI.toggleShowBookmarks()
call self.setShowBookmarks(!self._showBookmarks)
endfunction

" FUNCTION: s:UI.toggleShowFiles() {{{1
" toggles the display of hidden files
function! s:UI.toggleShowFiles()
Expand Down
2 changes: 1 addition & 1 deletion plugin/NERD_tree.vim
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ endif

"SECTION: Init variable calls for key mappings {{{2
let g:NERDTreeMapCustomOpen = get(g:, 'NERDTreeMapCustomOpen', '<CR>')
let g:NERDTreeMapJumpBookmarks = get(g:, 'NERDTreeMapJumpBookmarks', 'b')
let g:NERDTreeMapJumpBookmarks = get(g:, 'NERDTreeMapJumpBookmarks', 'gb')
let g:NERDTreeMapActivateNode = get(g:, 'NERDTreeMapActivateNode', 'o')
let g:NERDTreeMapChangeRoot = get(g:, 'NERDTreeMapChangeRoot', 'C')
let g:NERDTreeMapChdir = get(g:, 'NERDTreeMapChdir', 'cd')
Expand Down

0 comments on commit f66879f

Please sign in to comment.