diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/buffer.c | 1 | ||||
-rw-r--r-- | src/nvim/buffer_defs.h | 6 | ||||
-rw-r--r-- | src/nvim/option.c | 29 | ||||
-rw-r--r-- | src/nvim/option_defs.h | 9 | ||||
-rw-r--r-- | src/nvim/options.lua | 7 | ||||
-rw-r--r-- | src/nvim/tag.c | 18 | ||||
-rw-r--r-- | src/nvim/testdir/Makefile | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_tagcase.in | 55 | ||||
-rw-r--r-- | src/nvim/testdir/test_tagcase.ok | 76 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
10 files changed, 200 insertions, 4 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 62ab7495da..8191aa6f25 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1547,6 +1547,7 @@ void free_buf_options(buf_T *buf, int free_p_ff) clear_string_option(&buf->b_p_ep); clear_string_option(&buf->b_p_path); clear_string_option(&buf->b_p_tags); + clear_string_option(&buf->b_p_tc); clear_string_option(&buf->b_p_dict); clear_string_option(&buf->b_p_tsr); clear_string_option(&buf->b_p_qe); diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 936a14b903..a5e597702b 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -674,6 +674,8 @@ struct file_buffer { char_u *b_p_path; /* 'path' local value */ int b_p_ar; /* 'autoread' local value */ char_u *b_p_tags; /* 'tags' local value */ + char_u *b_p_tc; ///< 'tagcase' local value + unsigned b_tc_flags; ///< flags for 'tagcase' char_u *b_p_dict; /* 'dictionary' local value */ char_u *b_p_tsr; /* 'thesaurus' local value */ long b_p_ul; /* 'undolevels' local value */ @@ -953,9 +955,7 @@ struct window_S { time through cursupdate() to the current virtual column */ - /* - * the next six are used to update the visual part - */ + // the next seven are used to update the visual part char w_old_visual_mode; /* last known VIsual_mode */ linenr_T w_old_cursor_lnum; /* last known end of visual part */ colnr_T w_old_cursor_fcol; /* first column for block visual part */ diff --git a/src/nvim/option.c b/src/nvim/option.c index 5efd71444a..8a8a1d82bb 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2058,6 +2058,7 @@ static void didset_options(void) (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, true); (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, true); (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, true); + (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)spell_check_msm(); (void)spell_check_sps(); @@ -2145,6 +2146,7 @@ void check_buf_options(buf_T *buf) check_string_option(&buf->b_p_ep); check_string_option(&buf->b_p_path); check_string_option(&buf->b_p_tags); + check_string_option(&buf->b_p_tc); check_string_option(&buf->b_p_dict); check_string_option(&buf->b_p_tsr); check_string_option(&buf->b_p_lw); @@ -2984,6 +2986,24 @@ did_set_string_option ( if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, true) != OK) { errmsg = e_invarg; } + } else if (gvarp == &p_tc) { // 'tagcase' + unsigned int *flags; + + if (opt_flags & OPT_LOCAL) { + p = curbuf->b_p_tc; + flags = &curbuf->b_tc_flags; + } else { + p = p_tc; + flags = &tc_flags; + } + + if ((opt_flags & OPT_LOCAL) && *p == NUL) { + // make the local value empty: use the global value + *flags = 0; + } else if (*p == NUL + || opt_strings_flags(p, p_tc_values, flags, false) != OK) { + errmsg = e_invarg; + } } else if (varp == &p_cmp) { // 'casemap' if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, true) != OK) errmsg = e_invarg; @@ -5112,6 +5132,10 @@ void unset_global_local_option(char *name, void *from) case PV_TAGS: clear_string_option(&buf->b_p_tags); break; + case PV_TC: + clear_string_option(&buf->b_p_tc); + buf->b_tc_flags = 0; + break; case PV_DEF: clear_string_option(&buf->b_p_def); break; @@ -5165,6 +5189,7 @@ static char_u *get_varp_scope(vimoption_T *p, int opt_flags) case PV_PATH: return (char_u *)&(curbuf->b_p_path); case PV_AR: return (char_u *)&(curbuf->b_p_ar); case PV_TAGS: return (char_u *)&(curbuf->b_p_tags); + case PV_TC: return (char_u *)&(curbuf->b_p_tc); case PV_DEF: return (char_u *)&(curbuf->b_p_def); case PV_INC: return (char_u *)&(curbuf->b_p_inc); case PV_DICT: return (char_u *)&(curbuf->b_p_dict); @@ -5202,6 +5227,8 @@ static char_u *get_varp(vimoption_T *p) ? (char_u *)&(curbuf->b_p_ar) : p->var; case PV_TAGS: return *curbuf->b_p_tags != NUL ? (char_u *)&(curbuf->b_p_tags) : p->var; + case PV_TC: return *curbuf->b_p_tc != NUL + ? (char_u *)&(curbuf->b_p_tc) : p->var; case PV_BKC: return *curbuf->b_p_bkc != NUL ? (char_u *)&(curbuf->b_p_bkc) : p->var; case PV_DEF: return *curbuf->b_p_def != NUL @@ -5581,6 +5608,8 @@ void buf_copy_options(buf_T *buf, int flags) buf->b_p_kp = empty_option; buf->b_p_path = empty_option; buf->b_p_tags = empty_option; + buf->b_p_tc = empty_option; + buf->b_tc_flags = 0; buf->b_p_def = empty_option; buf->b_p_inc = empty_option; buf->b_p_inex = vim_strsave(p_inex); diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 547bd9442c..90cf69d46d 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -595,6 +595,14 @@ static char *(p_swb_values[]) = #define SWB_NEWTAB 0x008 #define SWB_VSPLIT 0x010 EXTERN int p_tbs; ///< 'tagbsearch' +EXTERN char_u *p_tc; ///< 'tagcase' +EXTERN unsigned tc_flags; ///< flags from 'tagcase' +#ifdef IN_OPTION_C +static char *(p_tc_values[]) = { "followic", "ignore", "match", NULL }; +#endif +#define TC_FOLLOWIC 0x01 +#define TC_IGNORE 0x02 +#define TC_MATCH 0x04 EXTERN long p_tl; ///< 'taglength' EXTERN int p_tr; ///< 'tagrelative' EXTERN char_u *p_tags; ///< 'tags' @@ -735,6 +743,7 @@ enum { , BV_SW , BV_SWF , BV_TAGS + , BV_TC , BV_TS , BV_TW , BV_TX diff --git a/src/nvim/options.lua b/src/nvim/options.lua index df77c374ec..a743e8c605 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -2332,6 +2332,13 @@ return { defaults={if_true={vi=true}} }, { + full_name='tagcase', abbreviation='tc', + type='string', scope={'global', 'buffer'}, + vim=true, + varname='p_tc', + defaults={if_true={vi="followic", vim="followic"}} + }, + { full_name='taglength', abbreviation='tl', type='number', scope={'global'}, vi_def=true, diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 8fcb02c3b6..21a9c605b3 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1147,6 +1147,22 @@ find_tags ( int get_it_again = FALSE; int use_cscope = (flags & TAG_CSCOPE); int verbose = (flags & TAG_VERBOSE); + int save_p_ic = p_ic; + + // Change the value of 'ignorecase' according to 'tagcase' for the + // duration of this function. + switch (curbuf->b_tc_flags ? curbuf->b_tc_flags : tc_flags) { + case TC_FOLLOWIC: + break; + case TC_IGNORE: + p_ic = true; + break; + case TC_MATCH: + p_ic = false; + break; + default: + assert(false); + } help_save = curbuf->b_help; orgpat.pat = pat; @@ -1955,6 +1971,8 @@ findtag_end: curbuf->b_help = help_save; xfree(saved_pat); + p_ic = save_p_ic; + return retval; } diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 63ca4cf6c4..2e01c636a3 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -38,6 +38,7 @@ SCRIPTS := \ test_close_count.out \ test_marks.out \ test_match_conceal.out \ + test_tagcase.out \ NEW_TESTS = diff --git a/src/nvim/testdir/test_tagcase.in b/src/nvim/testdir/test_tagcase.in new file mode 100644 index 0000000000..322d7696af --- /dev/null +++ b/src/nvim/testdir/test_tagcase.in @@ -0,0 +1,55 @@ +Tests for 'tagcase' option + +STARTTEST +:/^start text$/+1,/^end text$/w! Xtext +:/^start tags$/+1,/^end tags$/-1w! Xtags +:set tags=Xtags +:e Xtext +:" +:" Verify default values. +:set ic& | setg tc& | setl tc& +:call append('$', "ic=".&ic." g:tc=".&g:tc." l:tc=".&l:tc." tc=".&tc) +:" +:" Verify that the local setting accepts <empty> but that the global setting +:" does not. The first of these (setting the local value to <empty>) should +:" succeed; the other two should fail. +:let v:errmsg = "" +:setl tc= +:call append('$', v:errmsg) +:let v:errmsg = "" +:setg tc= +:call append('$', v:errmsg) +:let v:errmsg = "" +:set tc= +:call append('$', v:errmsg) +:" +:" Verify that the correct number of matching tags is found for all values of +:" 'ignorecase' and global and local values 'tagcase', in all combinations. +:for &ic in [0, 1] +: for &g:tc in ["followic", "ignore", "match"] +: for &l:tc in ["", "followic", "ignore", "match"] +: call append('$', "ic=".&ic." g:tc=".&g:tc." l:tc=".&l:tc." tc=".&tc) +: call append('$', len(taglist("^foo$"))) +: call append('$', len(taglist("^Foo$"))) +: endfor +: endfor +:endfor +:" +:1,/^end text$/d +:w! test.out +:qa! +ENDTEST + +start text + +Foo +Bar +foo + +end text + +start tags +Bar Xtext 3 +Foo Xtext 2 +foo Xtext 4 +end tags diff --git a/src/nvim/testdir/test_tagcase.ok b/src/nvim/testdir/test_tagcase.ok new file mode 100644 index 0000000000..fe161cf387 --- /dev/null +++ b/src/nvim/testdir/test_tagcase.ok @@ -0,0 +1,76 @@ +ic=0 g:tc=followic l:tc=followic tc=followic + +E474: Invalid argument: tc= +E474: Invalid argument: tc= +ic=0 g:tc=followic l:tc= tc=followic +1 +1 +ic=0 g:tc=followic l:tc=followic tc=followic +1 +1 +ic=0 g:tc=followic l:tc=ignore tc=ignore +2 +2 +ic=0 g:tc=followic l:tc=match tc=match +1 +1 +ic=0 g:tc=ignore l:tc= tc=ignore +2 +2 +ic=0 g:tc=ignore l:tc=followic tc=followic +1 +1 +ic=0 g:tc=ignore l:tc=ignore tc=ignore +2 +2 +ic=0 g:tc=ignore l:tc=match tc=match +1 +1 +ic=0 g:tc=match l:tc= tc=match +1 +1 +ic=0 g:tc=match l:tc=followic tc=followic +1 +1 +ic=0 g:tc=match l:tc=ignore tc=ignore +2 +2 +ic=0 g:tc=match l:tc=match tc=match +1 +1 +ic=1 g:tc=followic l:tc= tc=followic +2 +2 +ic=1 g:tc=followic l:tc=followic tc=followic +2 +2 +ic=1 g:tc=followic l:tc=ignore tc=ignore +2 +2 +ic=1 g:tc=followic l:tc=match tc=match +1 +1 +ic=1 g:tc=ignore l:tc= tc=ignore +2 +2 +ic=1 g:tc=ignore l:tc=followic tc=followic +2 +2 +ic=1 g:tc=ignore l:tc=ignore tc=ignore +2 +2 +ic=1 g:tc=ignore l:tc=match tc=match +1 +1 +ic=1 g:tc=match l:tc= tc=match +1 +1 +ic=1 g:tc=match l:tc=followic tc=followic +2 +2 +ic=1 g:tc=match l:tc=ignore tc=ignore +2 +2 +ic=1 g:tc=match l:tc=match tc=match +1 +1 diff --git a/src/nvim/version.c b/src/nvim/version.c index 4e875516c0..0f78d365ca 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -349,7 +349,7 @@ static int included_patches[] = { 944, // 943 NA // 942, - // 941, + 941, // 940 NA 939, // 938 NA |