diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/mark.c | 27 | ||||
-rw-r--r-- | src/nvim/option.c | 5 | ||||
-rw-r--r-- | src/nvim/option_defs.h | 6 | ||||
-rw-r--r-- | src/nvim/options.lua | 8 |
4 files changed, 43 insertions, 3 deletions
diff --git a/src/nvim/mark.c b/src/nvim/mark.c index e5070f23ff..93bc497cf0 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -178,6 +178,16 @@ void setpcmark(void) curwin->w_pcmark.lnum = 1; } + if (jop_flags & JOP_STACK) { + // If we're somewhere in the middle of the jumplist discard everything + // after the current index. + if (curwin->w_jumplistidx < curwin->w_jumplistlen - 1) { + // Discard the rest of the jumplist by cutting the length down to + // contain nothing beyond the current index. + curwin->w_jumplistlen = curwin->w_jumplistidx + 1; + } + } + /* If jumplist is full: remove oldest entry */ if (++curwin->w_jumplistlen > JUMPLISTSIZE) { curwin->w_jumplistlen = JUMPLISTSIZE; @@ -1204,7 +1214,20 @@ void cleanup_jumplist(win_T *wp, bool checktail) break; } } - if (i >= wp->w_jumplistlen) { // no duplicate + bool mustfree; + if (i >= wp->w_jumplistlen) { // not duplicate + mustfree = false; + } else if (i > from + 1) { // non-adjacent duplicate + // When the jump options include "stack", duplicates are only removed from + // the jumplist when they are adjacent. + mustfree = !(jop_flags & JOP_STACK); + } else { // adjacent duplicate + mustfree = true; + } + + if (mustfree) { + xfree(wp->w_jumplist[from].fname); + } else { if (to != from) { // Not using wp->w_jumplist[to++] = wp->w_jumplist[from] because // this way valgrind complains about overlapping source and destination @@ -1212,8 +1235,6 @@ void cleanup_jumplist(win_T *wp, bool checktail) wp->w_jumplist[to] = wp->w_jumplist[from]; } to++; - } else { - xfree(wp->w_jumplist[from].fname); } } if (wp->w_jumplistidx == wp->w_jumplistlen) { diff --git a/src/nvim/option.c b/src/nvim/option.c index 68ab310329..e48ed201e8 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2184,6 +2184,7 @@ static void didset_options(void) (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, false); (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, true); (void)opt_strings_flags(p_wop, p_wop_values, &wop_flags, true); + (void)opt_strings_flags(p_jop, p_jop_values, &jop_flags, true); (void)spell_check_msm(); (void)spell_check_sps(); (void)compile_cap_prog(curwin->w_s); @@ -2632,6 +2633,10 @@ did_set_string_option( if (strcmp((char *)(*varp), HIGHLIGHT_INIT) != 0) { errmsg = e_unsupportedoption; } + } else if (varp == &p_jop) { // 'jumpoptions' + if (opt_strings_flags(p_jop, p_jop_values, &jop_flags, true) != OK) { + errmsg = e_invarg; + } } else if (gvarp == &p_nf) { // 'nrformats' if (check_opt_strings(*varp, p_nf_values, true) != OK) { errmsg = e_invarg; diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index c6e3f71016..4f9f32794b 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -473,6 +473,12 @@ EXTERN char_u *p_isf; // 'isfname' EXTERN char_u *p_isi; // 'isident' EXTERN char_u *p_isp; // 'isprint' EXTERN int p_js; // 'joinspaces' +EXTERN char_u *p_jop; // 'jumpooptions' +EXTERN unsigned jop_flags; +#ifdef IN_OPTION_C +static char *(p_jop_values[]) = { "stack", NULL }; +#endif +#define JOP_STACK 0x01 EXTERN char_u *p_kp; // 'keywordprg' EXTERN char_u *p_km; // 'keymodel' EXTERN char_u *p_langmap; // 'langmap' diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 1e7105219f..93bfc1c0b1 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -1300,6 +1300,14 @@ return { defaults={if_true={vi=true}} }, { + full_name='jumpoptions', abbreviation='jop', + type='string', list='onecomma', scope={'global'}, + deny_duplicates=true, + varname='p_jop', + vim=true, + defaults={if_true={vim=''}} + }, + { full_name='keymap', abbreviation='kmp', type='string', scope={'buffer'}, normal_fname_chars=true, |