commit eb26a66be551f82dbeaa7bfbbd424960ef6a6fae
parent 460fcb692e562c13f740e6e89864bbf40d018805
Author: Rane Brown <rane.brown@gmail.com>
Date: Fri, 13 Dec 2019 12:59:59 -0700
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.
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/autoload/vimwiki/tags.vim b/autoload/vimwiki/tags.vim
@@ -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]