diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/option.c | 23 | ||||
-rw-r--r-- | src/nvim/testdir/test_alot.vim | 6 | ||||
-rw-r--r-- | src/nvim/testdir/test_glob2regpat.vim | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_modeline.vim | 22 | ||||
-rw-r--r-- | src/nvim/testdir/test_regexp_latin.vim | 12 |
5 files changed, 44 insertions, 23 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index 743f6c8311..43ee6bf451 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1239,7 +1239,7 @@ int do_set( } len++; if (opt_idx == -1) { - key = find_key_option(arg + 1); + key = find_key_option(arg + 1, true); } } else { len = 0; @@ -1253,7 +1253,7 @@ int do_set( } opt_idx = findoption_len((const char *)arg, (size_t)len); if (opt_idx == -1) { - key = find_key_option(arg); + key = find_key_option(arg, false); } } @@ -1986,7 +1986,7 @@ static char_u *illegal_char(char_u *errbuf, size_t errbuflen, int c) static int string_to_key(char_u *arg) { if (*arg == '<') { - return find_key_option(arg + 1); + return find_key_option(arg + 1, true); } if (*arg == '^') { return Ctrl_chr(arg[1]); @@ -4957,19 +4957,20 @@ char *set_option_value(const char *const name, const long number, return NULL; } -/* - * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number. - */ -int find_key_option_len(const char_u *arg, size_t len) +// Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number. +// When "has_lt" is true there is a '<' before "*arg_arg". +// Returns 0 when the key is not recognized. +int find_key_option_len(const char_u *arg_arg, size_t len, bool has_lt) { - int key; + int key = 0; int modifiers; + const char_u *arg = arg_arg; // Don't use get_special_key_code() for t_xx, we don't want it to call // add_termcap_entry(). if (len >= 4 && arg[0] == 't' && arg[1] == '_') { key = TERMCAP2KEY(arg[2], arg[3]); - } else { + } else if (has_lt) { arg--; // put arg at the '<' modifiers = 0; key = find_special_key(&arg, len + 1, &modifiers, true, true, false); @@ -4980,9 +4981,9 @@ int find_key_option_len(const char_u *arg, size_t len) return key; } -static int find_key_option(const char_u *arg) +static int find_key_option(const char_u *arg, bool has_lt) { - return find_key_option_len(arg, STRLEN(arg)); + return find_key_option_len(arg, STRLEN(arg), has_lt); } /* diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index d5f19057d0..30e29bd05d 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -29,27 +29,25 @@ source test_lambda.vim source test_mapping.vim source test_menu.vim source test_messages.vim +source test_modeline.vim source test_move.vim source test_partial.vim source test_popup.vim source test_put.vim source test_recover.vim -source test_regexp_utf8.vim source test_scroll_opt.vim source test_sort.vim -source test_source_utf8.vim source test_sha256.vim source test_statusline.vim source test_suspend.vim source test_syn_attr.vim source test_tabline.vim -" source test_tabpage.vim +source test_tabpage.vim source test_tagcase.vim source test_tagjump.vim source test_taglist.vim source test_true_false.vim source test_unlet.vim -source test_utf8.vim source test_virtualedit.vim source test_window_cmd.vim source test_wnext.vim diff --git a/src/nvim/testdir/test_glob2regpat.vim b/src/nvim/testdir/test_glob2regpat.vim index fdf17946b6..e6e41f13e7 100644 --- a/src/nvim/testdir/test_glob2regpat.vim +++ b/src/nvim/testdir/test_glob2regpat.vim @@ -1,12 +1,12 @@ " Test glob2regpat() -func Test_invalid() +func Test_glob2regpat_invalid() call assert_fails('call glob2regpat(1.33)', 'E806:') call assert_fails('call glob2regpat("}")', 'E219:') call assert_fails('call glob2regpat("{")', 'E220:') endfunc -func Test_valid() +func Test_glob2regpat_valid() call assert_equal('^foo\.', glob2regpat('foo.*')) call assert_equal('^foo.$', glob2regpat('foo?')) call assert_equal('\.vim$', glob2regpat('*.vim')) diff --git a/src/nvim/testdir/test_modeline.vim b/src/nvim/testdir/test_modeline.vim index 75fe1d993c..091a833774 100644 --- a/src/nvim/testdir/test_modeline.vim +++ b/src/nvim/testdir/test_modeline.vim @@ -1,11 +1,15 @@ +" Tests for parsing the modeline. + func Test_modeline_invalid() - let modeline = &modeline - set modeline - call assert_fails('set Xmodeline', 'E518:') + " This was reading allocated memory in the past. + call writefile(['vi:0', 'nothing'], 'Xmodeline') + let modeline = &modeline + set modeline + call assert_fails('set Xmodeline', 'E518:') - let &modeline = modeline - bwipe! - call delete('Xmodeline') + let &modeline = modeline + bwipe! + call delete('Xmodeline') endfunc func Test_modeline_filetype() @@ -40,6 +44,9 @@ func Test_modeline_syntax() endfunc func Test_modeline_keymap() + if !has('keymap') + return + endif call writefile(['vim: set keymap=greek :', 'nothing'], 'Xmodeline_keymap') let modeline = &modeline set modeline @@ -80,5 +87,8 @@ func Test_modeline_syntax_fails() endfunc func Test_modeline_keymap_fails() + if !has('keymap') + return + endif call s:modeline_fails('keymap', 'keymap=evil$CMD') endfunc diff --git a/src/nvim/testdir/test_regexp_latin.vim b/src/nvim/testdir/test_regexp_latin.vim index 0619e9c027..de209fa9ec 100644 --- a/src/nvim/testdir/test_regexp_latin.vim +++ b/src/nvim/testdir/test_regexp_latin.vim @@ -73,3 +73,15 @@ func Test_backref() call assert_fails('call search("\\%#=2\\(e\\1\\)")', 'E65:') bwipe! endfunc + +func Test_multi_failure() + set re=1 + call assert_fails('/a**', 'E61:') + call assert_fails('/a*\+', 'E62:') + call assert_fails('/a\{a}', 'E554:') + set re=2 + call assert_fails('/a**', 'E871:') + call assert_fails('/a*\+', 'E871:') + call assert_fails('/a\{a}', 'E870:') + set re=0 +endfunc |