From eb26a66be551f82dbeaa7bfbbd424960ef6a6fae Mon Sep 17 00:00:00 2001 From: Rane Brown Date: Fri, 13 Dec 2019 12:59:59 -0700 Subject: [PATCH] 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. --- autoload/vimwiki/tags.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autoload/vimwiki/tags.vim b/autoload/vimwiki/tags.vim index d3f0160..3a63317 100644 --- 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]