comparison src/tag.c @ 19033:f0312cf3c792 v8.2.0077

patch 8.2.0077: settagstack() cannot truncate at current index Commit: https://github.com/vim/vim/commit/271fa08a35b8d320d3a40db4ddae83b698fdd4fb Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 2 14:02:16 2020 +0100 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 https://github.com/vim/vim/issues/5417)
author Bram Moolenaar <Bram@vim.org>
date Thu, 02 Jan 2020 14:15:05 +0100
parents 7e7ec935e7c8
children 8645b73b3645
comparison
equal deleted inserted replaced
19032:02dcaab77547 19033:f0312cf3c792
4222 wp->w_tagstackidx = wp->w_tagstacklen; 4222 wp->w_tagstackidx = wp->w_tagstacklen;
4223 } 4223 }
4224 4224
4225 /* 4225 /*
4226 * Set the tag stack entries of the specified window. 4226 * Set the tag stack entries of the specified window.
4227 * 'action' is set to either 'a' for append or 'r' for replace. 4227 * 'action' is set to one of:
4228 * 'a' for append
4229 * 'r' for replace
4230 * 't' for truncate
4228 */ 4231 */
4229 int 4232 int
4230 set_tagstack(win_T *wp, dict_T *d, int action) 4233 set_tagstack(win_T *wp, dict_T *d, int action)
4231 { 4234 {
4232 dictitem_T *di; 4235 dictitem_T *di;
4233 list_T *l; 4236 list_T *l = NULL;
4234 4237
4235 #ifdef FEAT_EVAL 4238 #ifdef FEAT_EVAL
4236 // not allowed to alter the tag stack entries from inside tagfunc 4239 // not allowed to alter the tag stack entries from inside tagfunc
4237 if (tfu_in_use) 4240 if (tfu_in_use)
4238 { 4241 {
4247 { 4250 {
4248 emsg(_(e_listreq)); 4251 emsg(_(e_listreq));
4249 return FAIL; 4252 return FAIL;
4250 } 4253 }
4251 l = di->di_tv.vval.v_list; 4254 l = di->di_tv.vval.v_list;
4252
4253 if (action == 'r')
4254 tagstack_clear(wp);
4255
4256 tagstack_push_items(wp, l);
4257 } 4255 }
4258 4256
4259 if ((di = dict_find(d, (char_u *)"curidx", -1)) != NULL) 4257 if ((di = dict_find(d, (char_u *)"curidx", -1)) != NULL)
4260 tagstack_set_curidx(wp, (int)tv_get_number(&di->di_tv) - 1); 4258 tagstack_set_curidx(wp, (int)tv_get_number(&di->di_tv) - 1);
4261 4259
4260 if (action == 't') // truncate the stack
4261 {
4262 taggy_T *tagstack = wp->w_tagstack;
4263 int tagstackidx = wp->w_tagstackidx;
4264 int tagstacklen = wp->w_tagstacklen;
4265 // delete all the tag stack entries above the current entry
4266 while (tagstackidx < tagstacklen)
4267 tagstack_clear_entry(&tagstack[--tagstacklen]);
4268 wp->w_tagstacklen = tagstacklen;
4269 }
4270
4271 if (l != NULL)
4272 {
4273 if (action == 'r') // replace the stack
4274 tagstack_clear(wp);
4275
4276 tagstack_push_items(wp, l);
4277 // set the current index after the last entry
4278 wp->w_tagstackidx = wp->w_tagstacklen;
4279 }
4280
4262 return OK; 4281 return OK;
4263 } 4282 }
4264 #endif 4283 #endif