#endif
size_t len;
char_u *lbuf;
+ int isdigit = FALSE;
if (postponed_split == 0 && !check_can_set_curbuf_forceit(forceit))
return FAIL;
if (lbuf != NULL)
mch_memmove(lbuf, lbuf_arg, len);
- pbuf = alloc(LSIZE);
+ pbuf = alloc_clear(LSIZE);
// parse the match line into the tagp structure
if (pbuf == NULL || lbuf == NULL || parse_match(lbuf, &tagp) == FAIL)
// copy the command to pbuf[], remove trailing CR/NL
str = tagp.command;
- for (pbuf_end = pbuf; *str && *str != '\n' && *str != '\r'; )
+ if (VIM_ISDIGIT(*str))
+ {
+ // need to inject a ':' for a proper Vim9 :nr command
+ isdigit = TRUE;
+ pbuf[0] = ':';
+ }
+ for (pbuf_end = pbuf + isdigit;
+ *str && *str != '\n' && *str != '\r'; )
{
#ifdef FEAT_EMACS_TAGS
if (tagp.is_etag && *str == ',')// stop at ',' after line number
break;
#endif
*pbuf_end++ = *str++;
- if (pbuf_end - pbuf + 1 >= LSIZE)
+ if (pbuf_end - pbuf + 1 + isdigit >= LSIZE)
break;
}
*pbuf_end = NUL;
* Remove the "<Tab>fieldname:value" stuff; we don't need it here.
*/
str = pbuf;
+ // skip over the ':'
+ if (isdigit)
+ str++;
if (find_extra(&str) == OK)
{
pbuf_end = str;
set startofline&
endfunc
+func Test_tag_excmd_with_number_vim9script()
+ call writefile(["1#1\tXfile\t2;\"\ti"], 'Xtags', 'D')
+ call writefile(['f', 'foobar'], 'Xfile', 'D')
+ let list =<< trim END
+ vim9script
+ command! Tag call Tag()
+ def Tag(): void
+ exe "tag 1#1"
+ enddef
+ END
+ call writefile(list, 'Xtags.vim', 'D')
+
+ setlocal tags=Xtags
+ so Xtags.vim
+ :Tag
+ call assert_equal('Xfile', bufname('%'))
+ call assert_equal(2, line('.'))
+
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab