mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 20:00:05 +08:00
fix(bookmarks): fix next/previous function
This commit is contained in:
parent
5816fbbbfa
commit
32aec1ec5b
@ -138,21 +138,27 @@ function! bookmarks#delete(file, lnum) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:jump_to_bookmark(bookmark) abort
|
function! s:jump_to_bookmark(bookmark) abort
|
||||||
|
let file = s:FILE.unify_path(expand('%'), ':p')
|
||||||
|
|
||||||
|
if file !=# a:bookmark.file
|
||||||
exe 'e ' . a:bookmark.file
|
exe 'e ' . a:bookmark.file
|
||||||
|
endif
|
||||||
exe a:bookmark.lnum
|
exe a:bookmark.lnum
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! bookmarks#next() abort
|
function! bookmarks#next() abort
|
||||||
let file = s:FILE.unify_path(expand('%'), ':p')
|
let file = s:FILE.unify_path(expand('%'), ':p')
|
||||||
|
if has_key(s:bookmarks, file) && !empty(keys(s:bookmarks[file]))
|
||||||
if has_key(s:bookmarks, file)
|
for lnum in sort(keys(s:bookmarks[file]))
|
||||||
for lnum in keys(s:bookmarks[file])
|
|
||||||
if lnum > line('.')
|
if lnum > line('.')
|
||||||
call s:jump_to_bookmark(s:bookmarks[file][lnum])
|
call s:jump_to_bookmark(s:bookmarks[file][lnum])
|
||||||
|
return
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
" if all bookmarks < line('.')
|
||||||
|
" jump to first bookmark
|
||||||
|
call s:jump_to_bookmark(s:bookmarks[file][keys(s:bookmarks[file])[0]])
|
||||||
else
|
else
|
||||||
call s:NT.notify('no bookmarks found')
|
call s:NT.notify('no bookmarks found')
|
||||||
endif
|
endif
|
||||||
@ -162,12 +168,16 @@ endfunction
|
|||||||
function! bookmarks#previous() abort
|
function! bookmarks#previous() abort
|
||||||
let file = s:FILE.unify_path(expand('%'), ':p')
|
let file = s:FILE.unify_path(expand('%'), ':p')
|
||||||
|
|
||||||
if has_key(s:bookmarks, file)
|
if has_key(s:bookmarks, file) && !empty(keys(s:bookmarks[file]))
|
||||||
for lnum in reverse(keys(s:bookmarks[file]))
|
for lnum in reverse(sort(keys(s:bookmarks[file])))
|
||||||
if lnum < line('.')
|
if lnum < line('.')
|
||||||
call s:jump_to_bookmark(s:bookmarks[file][lnum])
|
call s:jump_to_bookmark(s:bookmarks[file][lnum])
|
||||||
|
return
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
" if all bookmarks > line('.')
|
||||||
|
" jump to first bookmark
|
||||||
|
call s:jump_to_bookmark(s:bookmarks[file][keys(s:bookmarks[file])[-1]])
|
||||||
else
|
else
|
||||||
call s:NT.notify('no bookmarks found')
|
call s:NT.notify('no bookmarks found')
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user