diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2020-01-29 20:30:23 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-29 20:30:23 -0800 |
commit | 4ea5d7d31a0ad43a84d268e6b05193fa27c5e0da (patch) | |
tree | adb5f5b3cb5ff71ec437539136b5f680a46b8de3 /src/nvim/tag.c | |
parent | 406464fa6e6dbacca82746412b24308bc58ddbc7 (diff) | |
parent | b7447a909fc668b023e86ca40c0e2738dd2e5350 (diff) | |
download | rneovim-4ea5d7d31a0ad43a84d268e6b05193fa27c5e0da.tar.gz rneovim-4ea5d7d31a0ad43a84d268e6b05193fa27c5e0da.tar.bz2 rneovim-4ea5d7d31a0ad43a84d268e6b05193fa27c5e0da.zip |
Merge #11792 from janlazo/vim-8.1.0445
vim-patch:8.1.{445,446},8.2.{77,177}
Diffstat (limited to 'src/nvim/tag.c')
-rw-r--r-- | src/nvim/tag.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/nvim/tag.c b/src/nvim/tag.c index a412ed0276..57bb43c846 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -3158,9 +3158,11 @@ int get_tags(list_T *list, char_u *pat, char_u *buf_fname) is_static = test_for_static(&tp); - /* Skip pseudo-tag lines. */ - if (STRNCMP(tp.tagname, "!_TAG_", 6) == 0) + // Skip pseudo-tag lines. + if (STRNCMP(tp.tagname, "!_TAG_", 6) == 0) { + xfree(matches[i]); continue; + } dict = tv_dict_alloc(); tv_list_append_dict(list, dict); @@ -3378,11 +3380,15 @@ static void tagstack_set_curidx(win_T *wp, int curidx) } // Set the tag stack entries of the specified window. -// 'action' is set to either 'a' for append or 'r' for replace. -int set_tagstack(win_T *wp, dict_T *d, int action) +// 'action' is set to one of: +// 'a' for append +// 'r' for replace +// 't' for truncate +int set_tagstack(win_T *wp, const dict_T *d, int action) + FUNC_ATTR_NONNULL_ARG(1) { dictitem_T *di; - list_T *l; + list_T *l = NULL; // not allowed to alter the tag stack entries from inside tagfunc if (tfu_in_use) { @@ -3395,16 +3401,30 @@ int set_tagstack(win_T *wp, dict_T *d, int action) return FAIL; } l = di->di_tv.vval.v_list; + } + + if ((di = tv_dict_find(d, "curidx", -1)) != NULL) { + tagstack_set_curidx(wp, (int)tv_get_number(&di->di_tv) - 1); + } + if (action == 't') { // truncate the stack + taggy_T *const tagstack = wp->w_tagstack; + const int tagstackidx = wp->w_tagstackidx; + int tagstacklen = wp->w_tagstacklen; + // delete all the tag stack entries above the current entry + while (tagstackidx < tagstacklen) { + tagstack_clear_entry(&tagstack[--tagstacklen]); + } + wp->w_tagstacklen = tagstacklen; + } - if (action == 'r') { + if (l != NULL) { + if (action == 'r') { // replace the stack tagstack_clear(wp); } tagstack_push_items(wp, l); - } - - if ((di = tv_dict_find(d, "curidx", -1)) != NULL) { - tagstack_set_curidx(wp, (int)tv_get_number(&di->di_tv) - 1); + // set the current index after the last entry + wp->w_tagstackidx = wp->w_tagstacklen; } return OK; |