mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-15 19:45:46 +08:00
feat(bookmarks): edit existing annotation
This commit is contained in:
parent
3d557dceeb
commit
8649032dc5
@ -19,17 +19,33 @@ function! bookmarks#toggle() abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
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
|
function! bookmarks#annotate() abort
|
||||||
|
|
||||||
let annotation = input('Annotation:')
|
|
||||||
|
|
||||||
if !empty(annotation)
|
|
||||||
let file = s:FILE.unify_path(expand('%'), ':p')
|
let file = s:FILE.unify_path(expand('%'), ':p')
|
||||||
let lnum = line('.')
|
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
|
||||||
|
let annotation = input('Annotation:')
|
||||||
|
if !empty(annotation)
|
||||||
call bookmarks#add(file, lnum, annotation, 1)
|
call bookmarks#add(file, lnum, annotation, 1)
|
||||||
else
|
else
|
||||||
call s:NT.notify('empty annotation, skipped!')
|
call s:NT.notify('empty annotation, skipped!')
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user