1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-13 02:05:40 +08:00

feat(bookmarks): edit existing annotation

This commit is contained in:
Eric Wong 2024-03-29 10:31:29 +08:00
parent 3d557dceeb
commit 8649032dc5

View File

@ -19,16 +19,32 @@ function! bookmarks#toggle() abort
endif
endfunction
function! s:has_annotation(file, lnum) abort
return has_key(s:bookmarks, a:file)
\ && has_key(s:bookmarks[a:file], a:lnum)
\ && has_key(s:bookmarks[a:file][a:lnum], 'annotation')
\ && !empty(s:bookmarks[a:file][a:lnum].annotation)
endfunction
function! bookmarks#annotate() abort
let annotation = input('Annotation:')
if !empty(annotation)
let file = s:FILE.unify_path(expand('%'), ':p')
let lnum = line('.')
call bookmarks#add(file, lnum, annotation, 1)
let file = s:FILE.unify_path(expand('%'), ':p')
let lnum = line('.')
if s:has_annotation(file, lnum)
let default_annotation = s:bookmarks[file][lnum].annotation
let annotation = input({'prompt' : 'Annotation:', 'default' : default_annotation, 'cancelreturn' : ''})
if !empty(annotation)
call bookmarks#add(file, lnum, annotation, 1)
else
call s:NT.notify('canceled, no changes.')
endif
else
call s:NT.notify('empty annotation, skipped!')
let annotation = input('Annotation:')
if !empty(annotation)
call bookmarks#add(file, lnum, annotation, 1)
else
call s:NT.notify('empty annotation, skipped!')
endif
endif
endfunction