aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/tag.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-01-29 20:44:23 -0500
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-01-29 21:00:11 -0500
commit31f31b40a8af67a3a55e85fa5dfa63d5a5999acc (patch)
tree705f39a1649e74e8fd0b107f2f5dca9349bc4bb1 /src/nvim/tag.c
parentf719b8898ba8aa18f0411be1924eea132a3b103e (diff)
downloadrneovim-31f31b40a8af67a3a55e85fa5dfa63d5a5999acc.tar.gz
rneovim-31f31b40a8af67a3a55e85fa5dfa63d5a5999acc.tar.bz2
rneovim-31f31b40a8af67a3a55e85fa5dfa63d5a5999acc.zip
vim-patch:8.2.0077: settagstack() cannot truncate at current index
Problem: settagstack() cannot truncate at current index. Solution: Add the "t" action. (Yegappan Lakshmanan, closes vim/vim#5417) https://github.com/vim/vim/commit/271fa08a35b8d320d3a40db4ddae83b698fdd4fb
Diffstat (limited to 'src/nvim/tag.c')
-rw-r--r--src/nvim/tag.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index a412ed0276..07f29977aa 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -3378,11 +3378,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 +3399,30 @@ int set_tagstack(win_T *wp, dict_T *d, int action)
return FAIL;
}
l = di->di_tv.vval.v_list;
+ }
- if (action == 'r') {
+ 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 (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;