Add check to generate_tags() to ensure a header is present.

Prior to this fix a file with tags present before any header would
result in vim errors. Now a single Vimwiki message is printed to alert
the user of the issue.
This commit is contained in:
Rane Brown 2019-12-13 12:59:59 -07:00
parent 460fcb692e
commit eb26a66be5

View File

@ -344,6 +344,10 @@ function! vimwiki#tags#generate_tags(create, ...) abort
if vimwiki#vars#get_wikilocal('syntax') == 'markdown'
let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink3Template')
let link_infos = vimwiki#base#resolve_link(taglink)
if empty(link_infos.anchor)
echom 'Vimwiki Error: Tags must appear after a header.'
return []
endif
let link_caption = split(link_infos.anchor, '#', 0)[-1]
let link_text = split(taglink, '#', 1)[0]