Compare commits

...

23 Commits

Author SHA1 Message Date
Yegappan Lakshmanan
df1bbea436 patch 8.2.4512: the find_tags_in_file() function is much too long
Problem:    The find_tags_in_file() function is much too long.
Solution:   Refactor into multiple smaller functions. (Yegappan Lakshmanan,
            closes #9892)
2022-03-05 14:35:12 +00:00
Bram Moolenaar
c12dc47b8f patch 8.2.4511: filetype test fails
Problem:    Filetype test fails.
Solution:   Change "endw" to "endwhile".
2022-03-05 13:45:56 +00:00
Bram Moolenaar
204852ae2a patch 8.2.4510: Vim9: shortening commands leads to confusing script
Problem:    Vim9: shortening commands leads to confusing script.
Solution:   In Vim9 script require at least ":cont" for ":continue", "const"
            instead of "cons", "break" instead of "brea", "catch" instead of
            "cat", "else" instead of "el" "elseif" instead of "elsei" "endfor"
            instead of "endfo" "endif" instead of "en" "endtry" instead of
            "endt", "finally" instead of "fina", "throw" instead of "th",
            "while" instead of "wh".
2022-03-05 12:56:44 +00:00
Bram Moolenaar
e1d1211799 patch 8.2.4509: Vim9: can declare a variable with ":va"
Problem:    Vim9: can declare a variable with ":va".
Solution:   Disallow using ":va", require using ":var".
2022-03-05 11:37:48 +00:00
Bram Moolenaar
330a388e18 patch 8.2.4508: Vim9: cannot assign to a global variable on the command line
Problem:    Vim9: cannot assign to a global variable on the command line.
Solution:   Allow using :vim9cmd for assignment on the command line.
2022-03-05 11:05:57 +00:00
Bram Moolenaar
f78ee2b49f patch 8.2.4507: test fails because of new error message
Problem:    Test fails because of new error message.
Solution:   Avoid the test fails.
2022-03-04 23:22:27 +00:00
Bram Moolenaar
24d9c0557e patch 8.2.4506: "pattern not found" for :global is not an error message
Problem:    "pattern not found" for :global is not an error message.
Solution:   In Vim9 script make this an actual error, so that try/catch can be
            used as expected.
2022-03-04 21:34:31 +00:00
Bram Moolenaar
f07751457c patch 8.2.4505: Vim9: outdated "autocmd nested" still works
Problem:    Vim9: outdated "autocmd nested" still works.
Solution:   Do not accept the :autocmd argument "nested" without "++" in Vim9
            script.
2022-03-04 20:10:38 +00:00
Bram Moolenaar
196c3850db patch 8.2.4504: when there is a partially matching map full map may not work
Problem:    When there is a partially matching map and modifyOtherKeys is
            active a full map may not work.
Solution:   Only simplify modifiers when there is no matching mapping.
            (closes #8792)
2022-03-04 19:22:36 +00:00
Bram Moolenaar
6aca4d3c2b patch 8.2.4503: Vim9: there is no point in supporting :Print and :mode
Problem:    Vim9: there is no point in supporting :Print and :mode.
Solution:   Do not recognize :Print and :mode as commands. (closes #9870)
2022-03-04 17:10:19 +00:00
Bram Moolenaar
d979d64fa2 patch 8.2.4502: in the GUI a modifier is not recognized after CTRL-X
Problem:    In the GUI a modifier is not recognized for the key typed after
            CTRL-X, which may result in a mapping to be used. (Daniel
            Steinberg)
Solution:   Recognize a modifier starting with CSI. (closes #9889)
2022-03-04 14:51:06 +00:00
Bram Moolenaar
21efafe4c2 patch 8.2.4501: with 'showbreak' set cursor displayed in wrong position
Problem:    With 'showbreak' set and after the end of the line the cursor
            may be displayed in the wrong position.
Solution:   Do not apply 'showbreak' after the end of the line. (closes #9884)
2022-03-03 20:04:03 +00:00
Bram Moolenaar
0e1574c406 patch 8.2.4500: Vim9: can declare a global variable on the command line
Problem:    Vim9: can declare a global variable on the command line.
Solution:   Disallow declaring a variable on the command line. (closes #9881)
2022-03-03 17:05:35 +00:00
Bram Moolenaar
28bf649a57 patch 8.2.4499: Vim9: at the script level declarations leak to next block
Problem:    Vim9: at the script level declarations leak from try block to
            catch and finally block.
Solution:   End the block and start a new one. (closes #9883)
2022-03-03 15:11:20 +00:00
Bram Moolenaar
1fc34225ac patch 8.2.4498: using <Plug> with "noremap" does not work
Problem:    Using <Plug> with "noremap" does not work.
Solution:   Always remap <Plug>. (closes #9879, closes #9789)
2022-03-03 13:56:24 +00:00
Bram Moolenaar
35d8c2010e patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Problem:    Wrong color for half of wide character next to pum scrollbar.
Solution:   Redraw the screen cell with the right color. (closes #9874)
2022-03-03 11:46:00 +00:00
Bram Moolenaar
fe9112e630 patch 8.2.4496: Coverity gives warnings after tags code refactoring
Problem:    Coverity gives warnings after tags code refactoring.
Solution:   Avoid the warnings. (Yegappan Lakshmanan, closes #9882)
2022-03-03 10:44:17 +00:00
Bram Moolenaar
e4e1a1e1c8 patch 8.2.4495: help test fails in 24 line terminal
Problem:    Help test fails in 24 line terminal.
Solution:   Use up to 23 lines for text.
2022-03-02 20:49:50 +00:00
Yegappan Lakshmanan
2f87a99b6e patch 8.2.4494: the find_tags() function is much too long
Problem:    The find_tags() function is much too long.
Solution:   Refactor the function. (Yegappan Lakshmanan, closes #9869)
2022-03-02 20:29:35 +00:00
Bram Moolenaar
b9c5108593 patch 8.2.4493: options test fails in the GUI
Problem:    Options test fails in the GUI.
Solution:   Do not save and restore 'term'.
2022-03-02 20:12:03 +00:00
Bram Moolenaar
8ccbbeb620 patch 8.2.4492: no error if an option is given a value with ":let &opt = val"
Problem:    No error if an option is given an invalid value with
            ":let &opt = val".
Solution:   Give the error. (closes #9864)
2022-03-02 19:49:38 +00:00
K.Takata
7f687aaca9 patch 8.2.4491: MS-Windows makefile dependencies are outdated
Problem:    MS-Windows makefile dependencies are outdated.
Solution:   Update dependencies. (Ken Takata, closes #9876)
2022-03-02 17:34:56 +00:00
Bram Moolenaar
8d5daf267e patch 8.2.4490: terminal focus reporting only works for xterm-like terminals
Problem:    Terminal focus reporting only works for xterm-like terminals.
            (Jonathan Rascher)
Solution:   Remove the "focus_mode" flag. (closes #9859)
2022-03-02 17:16:39 +00:00
40 changed files with 1977 additions and 1442 deletions

View File

@@ -198,7 +198,6 @@ SRC_ALL = \
src/testdir/view_util.vim \
src/testdir/test[0-9]*.ok \
src/testdir/test77a.ok \
src/testdir/test83-tags? \
src/testdir/test77a.com \
src/testdir/test_*.vim \
src/testdir/python2/*.py \
@@ -1000,6 +999,7 @@ LANG_GEN = \
runtime/doc/*-tr.1 \
runtime/doc/*-tr.UTF-8.1 \
runtime/lang/README.txt \
runtime/lang/Makefile \
runtime/lang/menu_*.vim \
runtime/keymap/README.txt \
runtime/keymap/*.vim \

View File

@@ -182,7 +182,7 @@ export def FTent()
break
endif
lnum += 1
endw
endwhile
setf dtd
enddef
@@ -482,7 +482,7 @@ export def FTprogress_asm()
break
endif
lnum += 1
endw
endwhile
setf progress
enddef
@@ -509,7 +509,7 @@ export def FTprogress_pascal()
break
endif
lnum += 1
endw
endwhile
setf progress
enddef

View File

@@ -80,6 +80,8 @@ modes.
where the map command applies. Disallow mapping of
{rhs}, to avoid nested and recursive mappings. Often
used to redefine a command.
Note: When <Plug> appears in the {rhs} this part is
always applied even if remapping is disallowed.
:unm[ap] {lhs} |mapmode-nvo| *:unm* *:unmap*

View File

@@ -1229,19 +1229,19 @@ $(OUTDIR)/netbeans.o: netbeans.c $(INCL) version.h
$(OUTDIR)/version.o: version.c $(INCL) version.h
$(OUTDIR)/vim9cmds.o: vim9cmds.c $(INCL) version.h
$(OUTDIR)/vim9cmds.o: vim9cmds.c $(INCL) vim9.h
$(OUTDIR)/vim9compile.o: vim9compile.c $(INCL) version.h
$(OUTDIR)/vim9compile.o: vim9compile.c $(INCL) vim9.h
$(OUTDIR)/vim9execute.o: vim9execute.c $(INCL) version.h
$(OUTDIR)/vim9execute.o: vim9execute.c $(INCL) vim9.h
$(OUTDIR)/vim9expr.o: vim9expr.c $(INCL) version.h
$(OUTDIR)/vim9expr.o: vim9expr.c $(INCL) vim9.h
$(OUTDIR)/vim9instr.o: vim9instr.c $(INCL) version.h
$(OUTDIR)/vim9instr.o: vim9instr.c $(INCL) vim9.h
$(OUTDIR)/vim9script.o: vim9script.c $(INCL) version.h
$(OUTDIR)/vim9script.o: vim9script.c $(INCL) vim9.h
$(OUTDIR)/vim9type.o: vim9type.c $(INCL) version.h
$(OUTDIR)/vim9type.o: vim9type.c $(INCL) vim9.h
$(OUTDIR)/viminfo.o: viminfo.c $(INCL) version.h

View File

@@ -1812,19 +1812,19 @@ $(OUTDIR)/userfunc.obj: $(OUTDIR) userfunc.c $(INCL)
$(OUTDIR)/version.obj: $(OUTDIR) version.c $(INCL) version.h
$(OUTDIR)/vim9cmds.obj: $(OUTDIR) vim9cmds.c $(INCL)
$(OUTDIR)/vim9cmds.obj: $(OUTDIR) vim9cmds.c $(INCL) vim9.h
$(OUTDIR)/vim9compile.obj: $(OUTDIR) vim9compile.c $(INCL)
$(OUTDIR)/vim9compile.obj: $(OUTDIR) vim9compile.c $(INCL) vim9.h
$(OUTDIR)/vim9execute.obj: $(OUTDIR) vim9execute.c $(INCL)
$(OUTDIR)/vim9execute.obj: $(OUTDIR) vim9execute.c $(INCL) vim9.h
$(OUTDIR)/vim9expr.obj: $(OUTDIR) vim9expr.c $(INCL)
$(OUTDIR)/vim9expr.obj: $(OUTDIR) vim9expr.c $(INCL) vim9.h
$(OUTDIR)/vim9instr.obj: $(OUTDIR) vim9instr.c $(INCL)
$(OUTDIR)/vim9instr.obj: $(OUTDIR) vim9instr.c $(INCL) vim9.h
$(OUTDIR)/vim9script.obj: $(OUTDIR) vim9script.c $(INCL)
$(OUTDIR)/vim9script.obj: $(OUTDIR) vim9script.c $(INCL) vim9.h
$(OUTDIR)/vim9type.obj: $(OUTDIR) vim9type.c $(INCL)
$(OUTDIR)/vim9type.obj: $(OUTDIR) vim9type.c $(INCL) vim9.h
$(OUTDIR)/viminfo.obj: $(OUTDIR) viminfo.c $(INCL) version.h

View File

@@ -3010,7 +3010,6 @@ shadow: runtime pixmaps
../../testdir/sautest \
../../testdir/samples \
../../testdir/dumps \
../../testdir/test83-tags? \
../../testdir/*.ok \
../../testdir/testluaplugin \
.

View File

@@ -921,16 +921,30 @@ do_autocmd(exarg_T *eap, char_u *arg_in, int forceit)
if ((STRNCMP(cmd, "++nested", 8) == 0 && VIM_ISWHITE(cmd[8])))
{
if (nested)
{
semsg(_(e_duplicate_argument_str), "++nested");
return;
}
nested = TRUE;
cmd = skipwhite(cmd + 8);
}
// Check for the old "nested" flag.
// Check for the old "nested" flag in legacy script.
if (STRNCMP(cmd, "nested", 6) == 0 && VIM_ISWHITE(cmd[6]))
{
if (in_vim9script())
{
// If there ever is a :nested command this error should
// be removed and "nested" accepted as the start of the
// command.
emsg(_(e_invalid_command_nested_did_you_mean_plusplus_nested));
return;
}
if (nested)
{
semsg(_(e_duplicate_argument_str), "nested");
return;
}
nested = TRUE;
cmd = skipwhite(cmd + 6);
}

View File

@@ -1037,9 +1037,10 @@ win_lbr_chartabsize(
* May have to add something for 'breakindent' and/or 'showbreak'
* string at start of line.
* Set *headp to the size of what we add.
* Do not use 'showbreak' at the NUL after the text.
*/
added = 0;
sbr = get_showbreak_value(wp);
sbr = c == NUL ? empty_option : get_showbreak_value(wp);
if ((*sbr != NUL || wp->w_p_bri) && wp->w_p_wrap && col != 0)
{
colnr_T sbrlen = 0;

View File

@@ -1346,7 +1346,8 @@ EXTERN char e_comma_required[]
EXTERN char e_commentstring_must_be_empty_or_contain_str[]
INIT(= N_("E537: 'commentstring' must be empty or contain %s"));
#endif
// E538 unused
EXTERN char e_pattern_found_in_every_line_str[]
INIT(= N_("E538: Pattern found in every line: %s"));
EXTERN char e_illegal_character_str[]
INIT(= N_("E539: Illegal character <%s>"));
#ifdef FEAT_STL_OPT
@@ -2760,8 +2761,9 @@ EXTERN char e_type_mismatch_for_v_variable[]
#endif
EXTERN char e_yank_register_changed_while_using_it[]
INIT(= N_("E1064: Yank register changed while using it"));
EXTERN char e_command_cannot_be_shortened[]
INIT(= N_("E1065: Command cannot be shortened: %s"));
#ifdef FEAT_EVAL
// E1065 unused
EXTERN char e_cannot_declare_a_register_str[]
INIT(= N_("E1066: Cannot declare a register: %s"));
EXTERN char e_separator_mismatch_str[]
@@ -2780,14 +2782,18 @@ EXTERN char e_no_white_space_allowed_after_dot[]
INIT(= N_("E1074: No white space allowed after dot"));
EXTERN char e_namespace_not_supported_str[]
INIT(= N_("E1075: Namespace not supported: %s"));
#ifndef FEAT_FLOAT
# ifndef FEAT_FLOAT
EXTERN char e_this_vim_is_not_compiled_with_float_support[]
INIT(= N_("E1076: This Vim is not compiled with float support"));
#endif
# endif
EXTERN char e_missing_argument_type_for_str[]
INIT(= N_("E1077: Missing argument type for %s"));
// E1078 unused
// E1079 unused
#endif
EXTERN char e_invalid_command_nested_did_you_mean_plusplus_nested[]
INIT(= N_("E1078: Invalid command \"nested\", did you mean \"++nested\"?"));
#ifdef FEAT_EVAL
EXTERN char e_cannot_declare_variable_on_command_line[]
INIT(= N_("E1079: Cannot declare a variable on the command line"));
EXTERN char e_invalid_assignment[]
INIT(= N_("E1080: Invalid assignment"));
EXTERN char e_cannot_unlet_str[]

View File

@@ -754,11 +754,20 @@ heredoc_get(exarg_T *eap, char_u *cmd, int script_get)
void
ex_var(exarg_T *eap)
{
char_u *p = eap->cmd;
int has_var;
if (!in_vim9script())
{
semsg(_(e_str_cannot_be_used_in_legacy_vim_script), ":var");
return;
}
has_var = checkforcmd_noparen(&p, "var", 3);
if (current_sctx.sc_sid == 0 && has_var)
{
emsg(_(e_cannot_declare_variable_on_command_line));
return;
}
ex_let(eap);
}
@@ -1518,8 +1527,11 @@ ex_let_option(
{
if (opt_type != gov_string || s != NULL)
{
set_option_value(arg, n, s, scope);
char *err = set_option_value(arg, n, s, scope);
arg_end = p;
if (err != NULL)
emsg(_(err));
}
else
emsg(_(e_string_required));
@@ -3437,7 +3449,7 @@ set_var_const(
if (in_vim9script() && is_export
&& SCRIPT_ID_VALID(current_sctx.sc_sid)
&& (si = SCRIPT_ITEM(current_sctx.sc_sid))
->sn_autoload_prefix != NULL)
->sn_autoload_prefix != NULL)
{
// In a vim9 autoload script an exported variable is put in the
// global namespace with the autoload prefix.

View File

@@ -5001,9 +5001,19 @@ ex_global(exarg_T *eap)
else if (ndone == 0)
{
if (type == 'v')
smsg(_("Pattern found in every line: %s"), pat);
{
if (in_vim9script())
semsg(_(e_pattern_found_in_every_line_str), pat);
else
smsg(_("Pattern found in every line: %s"), pat);
}
else
smsg(_("Pattern not found: %s"), pat);
{
if (in_vim9script())
semsg(_(e_pattern_not_found_str), pat);
else
smsg(_("Pattern not found: %s"), pat);
}
}
else
{

View File

@@ -58,6 +58,7 @@
#define EX_NONWHITE_OK 0x2000000 // command can be followed by non-white
#define EX_KEEPSCRIPT 0x4000000 // keep sctx of where command was invoked
#define EX_EXPR_ARG 0x8000000 // argument is an expression
#define EX_WHOLE 0x10000000 // command name cannot be shortened in Vim9
#define EX_FILES (EX_XFILE | EX_EXTRA) // multiple extra files allowed
#define EX_FILE1 (EX_FILES | EX_NOSPC) // 1 file, defaults to current file
@@ -221,7 +222,7 @@ EXCMD(CMD_brewind, "brewind", ex_brewind,
EX_BANG|EX_RANGE|EX_CMDARG|EX_TRLBAR,
ADDR_OTHER),
EXCMD(CMD_break, "break", ex_break,
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_breakadd, "breakadd", ex_breakadd,
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
@@ -281,7 +282,7 @@ EXCMD(CMD_call, "call", ex_call,
EX_RANGE|EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_LINES),
EXCMD(CMD_catch, "catch", ex_catch,
EX_EXTRA|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
EX_EXTRA|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_cbuffer, "cbuffer", ex_cbuffer,
EX_BANG|EX_RANGE|EX_WORD1|EX_TRLBAR,
@@ -413,7 +414,7 @@ EXCMD(CMD_confirm, "confirm", ex_wrongmodifier,
EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_const, "const", ex_let,
EX_EXTRA|EX_BANG|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
EX_EXTRA|EX_BANG|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_copen, "copen", ex_copen,
EX_RANGE|EX_COUNT|EX_TRLBAR,
@@ -548,16 +549,16 @@ EXCMD(CMD_echon, "echon", ex_echo,
EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_else, "else", ex_else,
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_elseif, "elseif", ex_else,
EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_emenu, "emenu", ex_emenu,
EX_NEEDARG|EX_EXTRA|EX_TRLBAR|EX_NOTRLCOM|EX_RANGE|EX_CMDWIN|EX_LOCK_OK,
ADDR_OTHER),
EXCMD(CMD_endif, "endif", ex_endif,
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_endinterface, "endinterface", ex_ni,
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
@@ -575,13 +576,13 @@ EXCMD(CMD_endfunction, "endfunction", ex_endfunction,
EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_endfor, "endfor", ex_endwhile,
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_endtry, "endtry", ex_endtry,
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_endwhile, "endwhile", ex_endwhile,
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_enew, "enew", ex_edit,
EX_BANG|EX_TRLBAR,
@@ -623,10 +624,10 @@ EXCMD(CMD_find, "find", ex_find,
EX_RANGE|EX_BANG|EX_FILE1|EX_CMDARG|EX_ARGOPT|EX_TRLBAR|EX_NEEDARG,
ADDR_OTHER),
EXCMD(CMD_final, "final", ex_let,
EX_EXTRA|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
EX_EXTRA|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_finally, "finally", ex_finally,
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_finish, "finish", ex_finish,
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
@@ -1601,7 +1602,7 @@ EXCMD(CMD_tfirst, "tfirst", ex_tag,
EX_RANGE|EX_BANG|EX_TRLBAR|EX_ZEROR,
ADDR_OTHER),
EXCMD(CMD_throw, "throw", ex_throw,
EX_EXTRA|EX_NEEDARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
EX_EXTRA|EX_NEEDARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_tjump, "tjump", ex_tag,
EX_BANG|EX_TRLBAR|EX_WORD1,
@@ -1694,7 +1695,7 @@ EXCMD(CMD_vglobal, "vglobal", ex_global,
EX_RANGE|EX_WHOLEFOLD|EX_EXTRA|EX_DFLALL|EX_CMDWIN|EX_LOCK_OK|EX_NONWHITE_OK,
ADDR_LINES),
EXCMD(CMD_var, "var", ex_var,
EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_version, "version", ex_version,
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
@@ -1763,7 +1764,7 @@ EXCMD(CMD_wall, "wall", do_wqall,
EX_BANG|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_while, "while", ex_while,
EX_EXTRA|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
EX_EXTRA|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_winsize, "winsize", ex_winsize,
EX_EXTRA|EX_NEEDARG|EX_TRLBAR,

View File

@@ -3745,13 +3745,28 @@ find_ex_command(
(size_t)len) == 0)
{
#ifdef FEAT_EVAL
if (full != NULL
&& cmdnames[(int)eap->cmdidx].cmd_name[len] == NUL)
if (full != NULL && cmdnames[eap->cmdidx].cmd_name[len] == NUL)
*full = TRUE;
#endif
break;
}
// :Print and :mode are not supported in Vim9 script.
// Some commands cannot be shortened in Vim9 script.
// ":continue" needs at least ":cont", since ":con" looks weird.
if (vim9 && eap->cmdidx != CMD_SIZE)
{
if (eap->cmdidx == CMD_mode || eap->cmdidx == CMD_Print)
eap->cmdidx = CMD_SIZE;
else if (((cmdnames[eap->cmdidx].cmd_argt & EX_WHOLE)
&& len < (int)STRLEN(cmdnames[eap->cmdidx].cmd_name))
|| (eap->cmdidx == CMD_continue && len < 4))
{
semsg(_(e_command_cannot_be_shortened), eap->cmd);
eap->cmdidx = CMD_SIZE;
}
}
// Do not recognize ":*" as the star command unless '*' is in
// 'cpoptions'.
if (eap->cmdidx == CMD_star && vim_strchr(p_cpo, CPO_STAR) == NULL)
@@ -3771,8 +3786,8 @@ find_ex_command(
eap->cmdidx = CMD_SIZE;
}
// ":fina" means ":finally" for backwards compatibility.
if (eap->cmdidx == CMD_final && p - eap->cmd == 4)
// ":fina" means ":finally" in legacy script, for backwards compatibility.
if (eap->cmdidx == CMD_final && p - eap->cmd == 4 && !vim9)
eap->cmdidx = CMD_finally;
#ifdef FEAT_EVAL

View File

@@ -1827,6 +1827,16 @@ ex_catch(exarg_T *eap)
cstack->cs_flags[idx] |= CSF_ACTIVE | CSF_CAUGHT;
did_emsg = got_int = did_throw = FALSE;
catch_exception((except_T *)cstack->cs_exception[idx]);
if (cstack->cs_idx >= 0
&& (cstack->cs_flags[cstack->cs_idx] & CSF_TRY))
{
// Variables declared in the previous block can no longer be
// used.
leave_block(cstack);
enter_block(cstack);
}
// It's mandatory that the current exception is stored in the cstack
// so that it can be discarded at the next ":catch", ":finally", or
// ":endtry" or when the catch clause is left by a ":continue",
@@ -1930,6 +1940,15 @@ ex_finally(exarg_T *eap)
*/
cleanup_conditionals(cstack, CSF_TRY, FALSE);
if (cstack->cs_idx >= 0
&& (cstack->cs_flags[cstack->cs_idx] & CSF_TRY))
{
// Variables declared in the previous block can no longer be
// used.
leave_block(cstack);
enter_block(cstack);
}
/*
* Make did_emsg, got_int, did_throw pending. If set, they overrule
* a pending ":continue", ":break", ":return", or ":finish". Then

View File

@@ -2331,7 +2331,7 @@ at_ctrl_x_key(void)
int c = *p;
if (typebuf.tb_len > 3
&& c == K_SPECIAL
&& (c == K_SPECIAL || c == CSI) // CSI is used by the GUI
&& p[1] == KS_MODIFIER
&& (p[2] & MOD_MASK_CTRL))
c = p[3] & 0x1f;
@@ -2424,6 +2424,13 @@ handle_mapping(
int keylen = *keylenp;
int i;
int local_State = get_real_state();
int is_plug_map = FALSE;
// If typehead starts with <Plug> then remap, even for a "noremap" mapping.
if (typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL
&& typebuf.tb_buf[typebuf.tb_off + 1] == KS_EXTRA
&& typebuf.tb_buf[typebuf.tb_off + 2] == KE_PLUG)
is_plug_map = TRUE;
/*
* Check for a mappable key sequence.
@@ -2441,7 +2448,7 @@ handle_mapping(
tb_c1 = typebuf.tb_buf[typebuf.tb_off];
if (no_mapping == 0 && is_maphash_valid()
&& (no_zero_mapping == 0 || tb_c1 != '0')
&& (typebuf.tb_maplen == 0
&& (typebuf.tb_maplen == 0 || is_plug_map
|| (p_remap
&& (typebuf.tb_noremap[typebuf.tb_off]
& (RM_NONE|RM_ABBR)) == 0))
@@ -2562,7 +2569,7 @@ handle_mapping(
for (n = mlen; --n >= 0; )
if (*s++ & (RM_NONE|RM_ABBR))
break;
if (n >= 0)
if (!is_plug_map && n >= 0)
continue;
if (keylen > typebuf.tb_len)
@@ -2591,7 +2598,7 @@ handle_mapping(
}
// If no partly match found, use the longest full match.
if (keylen != KEYLEN_PART_MAP)
if (keylen != KEYLEN_PART_MAP && mp_match != NULL)
{
mp = mp_match;
keylen = mp_match_len;
@@ -2636,7 +2643,7 @@ handle_mapping(
max_mlen = mlen + 1;
}
if ((mp == NULL || max_mlen >= mp_match_len) && keylen != KEYLEN_PART_MAP)
if ((mp == NULL || max_mlen > mp_match_len) && keylen != KEYLEN_PART_MAP)
{
int save_keylen = keylen;

View File

@@ -5013,6 +5013,8 @@ ex_make(exarg_T *eap)
int res;
char_u *au_name = NULL;
int_u save_qfid;
char_u *errorformat = p_efm;
int newlist = TRUE;
// Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal".
if (grep_internal(eap->cmdidx))
@@ -5059,11 +5061,13 @@ ex_make(exarg_T *eap)
incr_quickfix_busy();
res = qf_init(wp, fname, (eap->cmdidx != CMD_make
&& eap->cmdidx != CMD_lmake) ? p_gefm : p_efm,
(eap->cmdidx != CMD_grepadd
&& eap->cmdidx != CMD_lgrepadd),
qf_cmdtitle(*eap->cmdlinep), enc);
if (eap->cmdidx != CMD_make && eap->cmdidx != CMD_lmake)
errorformat = p_gefm;
if (eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd)
newlist = FALSE;
res = qf_init(wp, fname, errorformat, newlist, qf_cmdtitle(*eap->cmdlinep),
enc);
if (wp != NULL)
{
qi = GET_LOC_LIST(wp);
@@ -8102,8 +8106,7 @@ hgr_search_file(
// Convert a line if 'encoding' is not utf-8 and
// the line contains a non-ASCII character.
if (p_vc->vc_type != CONV_NONE
&& has_non_ascii(IObuff))
if (p_vc->vc_type != CONV_NONE && has_non_ascii(IObuff))
{
line = string_convert(p_vc, IObuff, NULL);
if (line == NULL)

View File

@@ -1495,8 +1495,9 @@ screen_puts_len(
int textlen,
int row,
int col,
int attr)
int attr_arg)
{
int attr = attr_arg;
unsigned off;
char_u *ptr = text;
int len = textlen;
@@ -1722,8 +1723,10 @@ screen_puts_len(
if (clear_next_cell)
{
// This only happens at the end, display one space next.
// Keep the attribute from before.
ptr = (char_u *)" ";
len = -1;
attr = ScreenAttrs[off];
}
}
else

2667
src/tag.c

File diff suppressed because it is too large Load Diff

View File

@@ -197,8 +197,7 @@ static char_u *vim_tgetstr(char *s, char_u **pp);
static int detected_8bit = FALSE; // detected 8-bit terminal
#if (defined(UNIX) || defined(VMS))
static int focus_mode = FALSE; // xterm's "focus reporting" availability
static int focus_state = FALSE; // TRUE if the terminal window gains focus
static int focus_state = MAYBE; // TRUE if the Vim window has focus
#endif
#ifdef FEAT_TERMRESPONSE
@@ -2047,7 +2046,7 @@ set_termname(char_u *term)
#endif
#ifdef FEAT_MOUSE_XTERM
// focus reporting is supported by xterm compatible terminals and tmux.
// Focus reporting is supported by xterm compatible terminals and tmux.
if (use_xterm_like_mouse(term))
{
char_u name[3];
@@ -2062,11 +2061,13 @@ set_termname(char_u *term)
name[1] = KE_FOCUSLOST;
add_termcode(name, (char_u *)"\033[O", FALSE);
focus_mode = TRUE;
focus_state = TRUE;
need_gather = TRUE;
}
#endif
#if (defined(UNIX) || defined(VMS))
// First time after setting 'term' a focus event is always reported.
focus_state = MAYBE;
#endif
#ifdef USE_TERM_CONSOLE
// DEFAULT_TERM indicates that it is the machine console.
@@ -3633,7 +3634,7 @@ starttermcap(void)
#if defined(UNIX) || defined(VMS)
// Enable xterm's focus reporting mode when 'esckeys' is set.
if (focus_mode && p_ek && *T_FE != NUL)
if (p_ek && *T_FE != NUL)
out_str(T_FE);
#endif
@@ -3691,7 +3692,7 @@ stoptermcap(void)
#if defined(UNIX) || defined(VMS)
// Disable xterm's focus reporting mode if 'esckeys' is set.
if (focus_mode && p_ek && *T_FD != NUL)
if (p_ek && *T_FD != NUL)
out_str(T_FD);
#endif
@@ -5812,11 +5813,10 @@ check_termcode(
* Handle FocusIn/FocusOut event sequences reported by XTerm.
* (CSI I/CSI O)
*/
if (focus_mode
if (key_name[0] == KS_EXTRA
# ifdef FEAT_GUI
&& !gui.in_use
# endif
&& key_name[0] == KS_EXTRA
)
{
if (key_name[1] == KE_FOCUSGAINED)

View File

@@ -0,0 +1,6 @@
| +0#0000e05#a8a8a8255@1|x+0#0000000#ffffff0@71|X
> +0#0000e05#a8a8a8255@1|s+0#0000000#ffffff0|e|c|o|n|d| |l|i|n|e| @61
|~+0#4040ff13&| @73
|~| @73
|~| @73
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|1|,|7|4| @9|A|l@1|

View File

@@ -0,0 +1,10 @@
|a+0&#ffffff0@1|0|b@1> @69
|a+0#0000001#e0e0e08@1|0|b@1| @9| +0#0000000#0000001|啊*0&#ffffff0| +&@56
|a+0#0000001#ffd7ff255@1|1|b@1| @9| +0#0000000#0000001| +0&#ffffff0|哦*&| +&@55
|a+0#0000001#ffd7ff255@1|2|b@1| @9| +0#0000000#0000001|呃*0&#ffffff0@1| +&@54
|a+0#0000001#ffd7ff255@1|3|b@1| @9| +0#0000000#0000001| +0&#ffffff0@58
|a+0#0000001#ffd7ff255@1|4|b@1| @9| +0#0000000#0000001| +0&#ffffff0@58
|a+0#0000001#ffd7ff255@1|5|b@1| @9| +0#0000000#0000001| +0&#ffffff0@58
|a+0#0000001#ffd7ff255@1|6|b@1| @9| +0#0000000#a8a8a8255| +0&#ffffff0@58
|a+0#0000001#ffd7ff255@1|7|b@1| @9| +0#0000000#a8a8a8255| +0&#ffffff0@58
|-+2&&@1| |K|e|y|w|o|r|d| |c|o|m|p|l|e|t|i|o|n| |(|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |1|0| +0#0000000&@32

View File

@@ -0,0 +1,6 @@
|~+0#4040ff13#ffffff0| @73
|~| @73
|~| @73
|~| @73
|E+0#ffffff16#e000002|1|0|7|9|:| |C|a|n@1|o|t| |d|e|c|l|a|r|e| |a| |v|a|r|i|a|b|l|e| |o|n| |t|h|e| |c|o|m@1|a|n|d| |l|i|n|e| +0#0000000#ffffff0@22
|P+0#00e0003&|r|e|s@1| |E|N|T|E|R| |o|r| |t|y|p|e| |c|o|m@1|a|n|d| |t|o| |c|o|n|t|i|n|u|e> +0#0000000&@35

View File

@@ -0,0 +1,6 @@
> +0&#ffffff0@74
|~+0#4040ff13&| @73
|~| @73
|~| @73
|~| @73
|1+0#0000000&|2|3| @53|0|,|0|-|1| @8|A|l@1|

View File

@@ -15,7 +15,6 @@ let script = [
\ '',
\ 'let save_columns = &columns',
\ 'let save_lines = &lines',
\ 'let save_term = &term',
\ 'set t_WS=',
\ ]
@@ -224,7 +223,6 @@ while 1
endif
endwhile
call add(script, 'let &term = save_term')
call add(script, 'let &columns = save_columns')
call add(script, 'let &lines = save_lines')

View File

@@ -1,2 +0,0 @@
!_TAG_FILE_ENCODING cp932 //
`ab Xtags2.txt /`ab

View File

@@ -1,102 +0,0 @@
!_TAG_FILE_SORTED 1 //
!_TAG_FILE_ENCODING cp932 //
abc1 Xtags3.txt /`ab
abc2 Xtags3.txt /`ab
abc3 Xtags3.txt /`ab
abc4 Xtags3.txt /`ab
abc5 Xtags3.txt /`ab
abc6 Xtags3.txt /`ab
abc7 Xtags3.txt /`ab
abc8 Xtags3.txt /`ab
abc9 Xtags3.txt /`ab
abc10 Xtags3.txt /`ab
abc11 Xtags3.txt /`ab
abc12 Xtags3.txt /`ab
abc13 Xtags3.txt /`ab
abc14 Xtags3.txt /`ab
abc15 Xtags3.txt /`ab
abc16 Xtags3.txt /`ab
abc17 Xtags3.txt /`ab
abc18 Xtags3.txt /`ab
abc19 Xtags3.txt /`ab
abc20 Xtags3.txt /`ab
abc21 Xtags3.txt /`ab
abc22 Xtags3.txt /`ab
abc23 Xtags3.txt /`ab
abc24 Xtags3.txt /`ab
abc25 Xtags3.txt /`ab
abc26 Xtags3.txt /`ab
abc27 Xtags3.txt /`ab
abc28 Xtags3.txt /`ab
abc29 Xtags3.txt /`ab
abc30 Xtags3.txt /`ab
abc31 Xtags3.txt /`ab
abc32 Xtags3.txt /`ab
abc33 Xtags3.txt /`ab
abc34 Xtags3.txt /`ab
abc35 Xtags3.txt /`ab
abc36 Xtags3.txt /`ab
abc37 Xtags3.txt /`ab
abc38 Xtags3.txt /`ab
abc39 Xtags3.txt /`ab
abc40 Xtags3.txt /`ab
abc41 Xtags3.txt /`ab
abc42 Xtags3.txt /`ab
abc43 Xtags3.txt /`ab
abc44 Xtags3.txt /`ab
abc45 Xtags3.txt /`ab
abc46 Xtags3.txt /`ab
abc47 Xtags3.txt /`ab
abc48 Xtags3.txt /`ab
abc49 Xtags3.txt /`ab
abc50 Xtags3.txt /`ab
abc51 Xtags3.txt /`ab
abc52 Xtags3.txt /`ab
abc53 Xtags3.txt /`ab
abc54 Xtags3.txt /`ab
abc55 Xtags3.txt /`ab
abc56 Xtags3.txt /`ab
abc57 Xtags3.txt /`ab
abc58 Xtags3.txt /`ab
abc59 Xtags3.txt /`ab
abc60 Xtags3.txt /`ab
abc61 Xtags3.txt /`ab
abc62 Xtags3.txt /`ab
abc63 Xtags3.txt /`ab
abc64 Xtags3.txt /`ab
abc65 Xtags3.txt /`ab
abc66 Xtags3.txt /`ab
abc67 Xtags3.txt /`ab
abc68 Xtags3.txt /`ab
abc69 Xtags3.txt /`ab
abc70 Xtags3.txt /`ab
abc71 Xtags3.txt /`ab
abc72 Xtags3.txt /`ab
abc73 Xtags3.txt /`ab
abc74 Xtags3.txt /`ab
abc75 Xtags3.txt /`ab
abc76 Xtags3.txt /`ab
abc77 Xtags3.txt /`ab
abc78 Xtags3.txt /`ab
abc79 Xtags3.txt /`ab
abc80 Xtags3.txt /`ab
abc81 Xtags3.txt /`ab
abc82 Xtags3.txt /`ab
abc83 Xtags3.txt /`ab
abc84 Xtags3.txt /`ab
abc85 Xtags3.txt /`ab
abc86 Xtags3.txt /`ab
abc87 Xtags3.txt /`ab
abc88 Xtags3.txt /`ab
abc89 Xtags3.txt /`ab
abc90 Xtags3.txt /`ab
abc91 Xtags3.txt /`ab
abc92 Xtags3.txt /`ab
abc93 Xtags3.txt /`ab
abc94 Xtags3.txt /`ab
abc95 Xtags3.txt /`ab
abc96 Xtags3.txt /`ab
abc97 Xtags3.txt /`ab
abc98 Xtags3.txt /`ab
abc99 Xtags3.txt /`ab
abc100 Xtags3.txt /`ab

View File

@@ -2116,6 +2116,9 @@ func Test_autocmd_nested()
close
bwipe! somefile
" nested without ++ does not work in Vim9 script
call assert_fails('vim9cmd au WinNew * nested echo fails', 'E1078:')
augroup Testing
au!
augroup END

View File

@@ -8,6 +8,7 @@ source check.vim
CheckOption breakindent
source view_util.vim
source screendump.vim
let s:input ="\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP"
@@ -849,6 +850,27 @@ func Test_window_resize_with_linebreak()
%bw!
endfunc
func Test_cursor_position_with_showbreak()
CheckScreendump
let lines =<< trim END
vim9script
&signcolumn = 'yes'
&showbreak = '+ '
var leftcol: number = win_getid()->getwininfo()->get(0, {})->get('textoff')
repeat('x', &columns - leftcol - 1)->setline(1)
'second line'->setline(2)
END
call writefile(lines, 'XscriptShowbreak')
let buf = RunVimInTerminal('-S XscriptShowbreak', #{rows: 6})
call term_sendkeys(buf, "AX")
call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak', {})
call StopVimInTerminal(buf)
call delete('XscriptShowbreak')
endfunc
func Test_no_spurious_match()
let s:input = printf('- y %s y %s', repeat('x', 50), repeat('x', 50))
call s:test_windows('setl breakindent breakindentopt=list:-1 formatlistpat=^- hls')

View File

@@ -68,6 +68,26 @@ func Test_global_print()
v/foo\|bar/p
call assert_notequal('', v:statusmsg)
" In Vim9 script this is an error
let caught = 'no'
try
vim9cmd v/foo\|bar/p
catch /E538/
let caught = 'yes'
call assert_match('E538: Pattern found in every line: foo\|bar', v:exception)
endtry
call assert_equal('yes', caught)
" In Vim9 script not matching is an error
let caught = 'no'
try
vim9cmd g/foobarnotfound/p
catch /E486/
let caught = 'yes'
call assert_match('E486: Pattern not found: foobarnotfound', v:exception)
endtry
call assert_equal('yes', caught)
close!
endfunc

View File

@@ -152,7 +152,7 @@ endfunc
" Test for setting the 'helpheight' option in the help window
func Test_help_window_height()
let &cmdheight = &lines - 24
let &cmdheight = &lines - 23
set helpheight=10
help
set helpheight=14

View File

@@ -606,6 +606,24 @@ func Test_pum_with_preview_win()
call delete('Xpreviewscript')
endfunc
func Test_scrollbar_on_wide_char()
CheckScreendump
let lines =<< trim END
call setline(1, ['a', ' 啊啊啊',
\ ' 哦哦哦',
\ ' 呃呃呃'])
call setline(5, range(10)->map({i, v -> 'aa' .. v .. 'bb'}))
END
call writefile(lines, 'Xwidescript')
let buf = RunVimInTerminal('-S Xwidescript', #{rows: 10})
call term_sendkeys(buf, "A\<C-N>")
call VerifyScreenDump(buf, 'Test_scrollbar_on_wide_char', {})
call StopVimInTerminal(buf)
call delete('Xwidescript')
endfunc
" Test for inserting the tag search pattern in insert mode
func Test_ins_compl_tag_sft()
call writefile([
@@ -1276,7 +1294,18 @@ func Test_z1_complete_no_history()
exe "normal owh\<C-X>\<C-K>"
exe "normal owh\<C-N>"
call assert_equal(currmess, execute('messages'))
close!
bwipe!
endfunc
" A mapping is not used for the key after CTRL-X.
func Test_no_mapping_for_ctrl_x_key()
new
inoremap <C-K> <Cmd>let was_mapped = 'yes'<CR>
setlocal dictionary=README.txt
call feedkeys("aexam\<C-X>\<C-K> ", 'xt')
call assert_equal('example ', getline(1))
call assert_false(exists('was_mapped'))
bwipe!
endfunc
" Test for different ways of setting the 'completefunc' option

View File

@@ -1536,4 +1536,34 @@ func Test_abbreviate_latin1_encoding()
set encoding=utf-8
endfunc
" Test for <Plug> always being mapped, even when used with "noremap".
func Test_plug_remap()
let g:foo = 0
nnoremap <Plug>(Increase_x) <Cmd>let g:foo += 1<CR>
nmap <F2> <Plug>(Increase_x)
nnoremap <F3> <Plug>(Increase_x)
call feedkeys("\<F2>", 'xt')
call assert_equal(1, g:foo)
call feedkeys("\<F3>", 'xt')
call assert_equal(2, g:foo)
nnoremap x <Nop>
nmap <F4> x<Plug>(Increase_x)x
nnoremap <F5> x<Plug>(Increase_x)x
call setline(1, 'Some text')
normal! gg$
call feedkeys("\<F4>", 'xt')
call assert_equal(3, g:foo)
call assert_equal('Some text', getline(1))
call feedkeys("\<F5>", 'xt')
call assert_equal(4, g:foo)
call assert_equal('Some te', getline(1))
nunmap <Plug>(Increase_x)
nunmap <F2>
nunmap <F3>
nunmap <F4>
nunmap <F5>
unlet g:foo
%bw!
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -369,6 +369,7 @@ func Test_set_errors()
call assert_fails('set sidescroll=-1', 'E487:')
call assert_fails('set tabstop=-1', 'E487:')
call assert_fails('set tabstop=10000', 'E474:')
call assert_fails('let &tabstop = 10000', 'E474:')
call assert_fails('set tabstop=5500000000', 'E474:')
call assert_fails('set textwidth=-1', 'E487:')
call assert_fails('set timeoutlen=-1', 'E487:')
@@ -384,6 +385,7 @@ func Test_set_errors()
call assert_fails('set comments=a', 'E525:')
call assert_fails('set foldmarker=x', 'E536:')
call assert_fails('set commentstring=x', 'E537:')
call assert_fails('let &commentstring = "x"', 'E537:')
call assert_fails('set complete=x', 'E539:')
call assert_fails('set rulerformat=%-', 'E539:')
call assert_fails('set rulerformat=%(', 'E542:')

View File

@@ -230,7 +230,6 @@ func Test_tag_symbolic()
endfunc
" Tests for tag search with !_TAG_FILE_ENCODING.
" Depends on the test83-tags2 and test83-tags3 files.
func Test_tag_file_encoding()
if has('vms')
throw 'Skipped: does not work on VMS'
@@ -262,18 +261,31 @@ func Test_tag_file_encoding()
" case2:
new
set tags=test83-tags2
let content = ['!_TAG_FILE_ENCODING cp932 //',
\ "\x82`\x82a\x82b Xtags2.txt /\x82`\x82a\x82b"]
call writefile(content, 'Xtags')
set tags=Xtags
tag /.
call assert_equal('Xtags2.txt', expand('%:t'))
call assert_equal('', getline('.'))
call delete('Xtags')
close
" case3:
new
set tags=test83-tags3
let contents = [
\ "!_TAG_FILE_SORTED 1 //",
\ "!_TAG_FILE_ENCODING cp932 //"]
for i in range(1, 100)
call add(contents, 'abc' .. i
\ .. " Xtags3.txt /\x82`\x82a\x82b")
endfor
call writefile(contents, 'Xtags')
set tags=Xtags
tag abc50
call assert_equal('Xtags3.txt', expand('%:t'))
call assert_equal('', getline('.'))
call delete('Xtags')
close
set tags&
@@ -324,6 +336,7 @@ func Test_tagjump_etags()
\ ], 'Xtags2')
tag main
call assert_equal(2, line('.'))
call assert_fails('tag bar', 'E426:')
" corrupted tag line
call writefile([
@@ -349,6 +362,27 @@ func Test_tagjump_etags()
\ ], 'Xtags')
call assert_fails('tag foo', 'E431:')
" end of file after a CTRL-L line
call writefile([
\ "\x0c",
\ "Xmain.c,64",
\ "void foo() {}\x7ffoo\x011,0",
\ "\x0c",
\ ], 'Xtags')
call assert_fails('tag main', 'E426:')
" error in an included tags file
call writefile([
\ "\x0c",
\ "Xtags2,include"
\ ], 'Xtags')
call writefile([
\ "\x0c",
\ "Xmain.c,64",
\ "void foo() {}",
\ ], 'Xtags2')
call assert_fails('tag foo', 'E431:')
call delete('Xtags')
call delete('Xtags2')
call delete('Xmain.c')
@@ -1427,6 +1461,16 @@ func Test_tagfile_errors()
endtry
call assert_equal(v:true, caught_431)
" tag name and file name are not separated by a tab
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
\ "foo Xfile 1"], 'Xtags')
call assert_fails('tag foo', 'E431:')
" file name and search pattern are not separated by a tab
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
\ "foo\tXfile 1;"], 'Xtags')
call assert_fails('tag foo', 'E431:')
call delete('Xtags')
call delete('Xfile')
set tags&

View File

@@ -2098,6 +2098,23 @@ func Test_modifyOtherKeys_mapped()
set timeoutlen&
endfunc
func Test_modifyOtherKeys_ambiguous_mapping()
new
set timeoutlen=10
map <C-J> a
map <C-J>x <Nop>
call setline(1, 'x')
" CTRL-J b should have trigger the <C-J> mapping and then insert "b"
call feedkeys(GetEscCodeCSI27('J', 5) .. "b\<Esc>", 'Lx!')
call assert_equal('xb', getline(1))
unmap <C-J>
unmap <C-J>x
set timeoutlen&
bwipe!
endfunc
" Whether Shift-Tab sends "ESC [ Z" or "ESC [ 27 ; 2 ; 9 ~" is unpredictable,
" both should work.
func Test_modifyOtherKeys_shift_tab()

View File

@@ -1965,6 +1965,11 @@ def Test_var_declaration_fails()
v9.CheckDefFailure(['var foo.bar = 2'], 'E1087:')
v9.CheckDefFailure(['var foo[3] = 2'], 'E1087:')
v9.CheckDefFailure(['const foo: number'], 'E1021:')
lines =<< trim END
va foo = 123
END
v9.CheckDefAndScriptFailure(lines, 'E1065:', 1)
enddef
def Test_var_declaration_inferred()
@@ -2480,23 +2485,6 @@ def Test_abort_after_error()
delete('Xtestscript')
enddef
func Test_declare_command_line()
CheckRunVimInTerminal
call Run_Test_declare_command_line()
endfunc
def Run_Test_declare_command_line()
# On the command line the type is parsed but not used.
# To get rid of the script context have to run this in another Vim instance.
var buf = g:RunVimInTerminal('', {'rows': 6})
term_sendkeys(buf, ":vim9 var abc: list<list<number>> = [ [1, 2, 3], [4, 5, 6] ]\<CR>")
g:TermWait(buf)
term_sendkeys(buf, ":echo abc\<CR>")
g:TermWait(buf)
g:WaitForAssert(() => assert_match('\[\[1, 2, 3\], \[4, 5, 6\]\]', term_getline(buf, 6)))
g:StopVimInTerminal(buf)
enddef
def Test_using_s_var_in_function()
var lines =<< trim END
vim9script

View File

@@ -1834,14 +1834,18 @@ def Test_no_space_after_command()
g #pat#cmd
END
v9.CheckDefAndScriptFailure(lines, 'E1242:', 1)
new
setline(1, 'some pat')
lines =<< trim END
g#pat#cmd
g#pat#print
END
v9.CheckDefAndScriptSuccess(lines)
lines =<< trim END
g# pat#cmd
g# pat#print
END
v9.CheckDefAndScriptSuccess(lines)
bwipe!
lines =<< trim END
s /pat/repl

View File

@@ -460,7 +460,7 @@ def Test_try_catch_throw()
endtry
catch /wrong/
add(l, 'caught')
fina
finally
add(l, 'finally')
endtry
assert_equal(['1', 'caught', 'finally'], l)
@@ -763,6 +763,30 @@ def Test_try_catch_throw()
v9.CheckDefAndScriptSuccess(lines)
enddef
def Test_try_var_decl()
var lines =<< trim END
vim9script
try
var in_try = 1
assert_equal(1, get(s:, 'in_try', -1))
throw "getout"
catch
var in_catch = 2
assert_equal(-1, get(s:, 'in_try', -1))
assert_equal(2, get(s:, 'in_catch', -1))
finally
var in_finally = 3
assert_equal(-1, get(s:, 'in_try', -1))
assert_equal(-1, get(s:, 'in_catch', -1))
assert_equal(3, get(s:, 'in_finally', -1))
endtry
assert_equal(-1, get(s:, 'in_try', -1))
assert_equal(-1, get(s:, 'in_catch', -1))
assert_equal(-1, get(s:, 'in_finally', -1))
END
v9.CheckScriptSuccess(lines)
enddef
def Test_try_ends_in_return()
var lines =<< trim END
vim9script
@@ -980,7 +1004,7 @@ enddef
def s:ReturnFinally(): string
try
return 'intry'
finall
finally
g:in_finally = 'finally'
endtry
return 'end'
@@ -3302,34 +3326,84 @@ enddef
func Test_no_redraw_when_restoring_cpo()
CheckScreendump
CheckFeature timers
call Run_test_no_redraw_when_restoring_cpo()
endfunc
let lines =<< trim END
def Run_test_no_redraw_when_restoring_cpo()
var lines =<< trim END
vim9script
export def Func()
enddef
END
call mkdir('Xdir/autoload', 'p')
call writefile(lines, 'Xdir/autoload/script.vim')
mkdir('Xdir/autoload', 'p')
writefile(lines, 'Xdir/autoload/script.vim')
let lines =<< trim END
lines =<< trim END
vim9script
set cpo+=M
exe 'set rtp^=' .. getcwd() .. '/Xdir'
au CmdlineEnter : ++once timer_start(0, (_) => script#Func())
setline(1, 'some text')
END
call writefile(lines, 'XTest_redraw_cpo')
let buf = g:RunVimInTerminal('-S XTest_redraw_cpo', {'rows': 6})
call term_sendkeys(buf, "V:")
call VerifyScreenDump(buf, 'Test_vim9_no_redraw', {})
writefile(lines, 'XTest_redraw_cpo')
var buf = g:RunVimInTerminal('-S XTest_redraw_cpo', {'rows': 6})
term_sendkeys(buf, "V:")
g:VerifyScreenDump(buf, 'Test_vim9_no_redraw', {})
" clean up
call term_sendkeys(buf, "\<Esc>u")
call g:StopVimInTerminal(buf)
call delete('XTest_redraw_cpo')
call delete('Xdir', 'rf')
# clean up
term_sendkeys(buf, "\<Esc>u")
g:StopVimInTerminal(buf)
delete('XTest_redraw_cpo')
delete('Xdir', 'rf')
enddef
func Test_reject_declaration()
CheckScreendump
call Run_test_reject_declaration()
endfunc
def Run_test_reject_declaration()
var buf = g:RunVimInTerminal('', {'rows': 6})
term_sendkeys(buf, ":vim9cmd var x: number\<CR>")
g:VerifyScreenDump(buf, 'Test_vim9_reject_declaration_1', {})
term_sendkeys(buf, ":\<CR>")
term_sendkeys(buf, ":vim9cmd g:foo = 123 | echo g:foo\<CR>")
g:VerifyScreenDump(buf, 'Test_vim9_reject_declaration_2', {})
# clean up
g:StopVimInTerminal(buf)
enddef
def Test_minimal_command_name_length()
var names = [
'cons',
'brea',
'cat',
'catc',
'con',
'el',
'els',
'elsei',
'endfo',
'en',
'end',
'endi',
'endw',
'endt',
'endtr',
'fina',
'finall',
'th',
'thr',
'thro',
'wh',
'whi',
'whil',
]
for name in names
v9.CheckDefAndScriptFailure([name .. ' '], 'E1065:')
endfor
enddef
def Test_unset_any_variable()
var lines =<< trim END
@@ -3549,32 +3623,37 @@ def Test_unsupported_commands()
var lines =<< trim END
ka
END
v9.CheckDefFailure(lines, 'E476:')
v9.CheckScriptFailure(['vim9script'] + lines, 'E492:')
v9.CheckDefAndScriptFailure(lines, ['E476:', 'E492:'])
lines =<< trim END
:1ka
END
v9.CheckDefFailure(lines, 'E476:')
v9.CheckScriptFailure(['vim9script'] + lines, 'E492:')
v9.CheckDefAndScriptFailure(lines, ['E476:', 'E492:'])
lines =<< trim END
t
END
v9.CheckDefFailure(lines, 'E1100:')
v9.CheckScriptFailure(['vim9script'] + lines, 'E1100:')
v9.CheckDefAndScriptFailure(lines, 'E1100:')
lines =<< trim END
x
END
v9.CheckDefFailure(lines, 'E1100:')
v9.CheckScriptFailure(['vim9script'] + lines, 'E1100:')
v9.CheckDefAndScriptFailure(lines, 'E1100:')
lines =<< trim END
xit
END
v9.CheckDefFailure(lines, 'E1100:')
v9.CheckScriptFailure(['vim9script'] + lines, 'E1100:')
v9.CheckDefAndScriptFailure(lines, 'E1100:')
lines =<< trim END
Print
END
v9.CheckDefAndScriptFailure(lines, ['E476: Invalid command: Print', 'E492: Not an editor command: Print'])
lines =<< trim END
mode 4
END
v9.CheckDefAndScriptFailure(lines, ['E476: Invalid command: mode 4', 'E492: Not an editor command: mode 4'])
enddef
def Test_mapping_line_number()

View File

@@ -754,6 +754,52 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4512,
/**/
4511,
/**/
4510,
/**/
4509,
/**/
4508,
/**/
4507,
/**/
4506,
/**/
4505,
/**/
4504,
/**/
4503,
/**/
4502,
/**/
4501,
/**/
4500,
/**/
4499,
/**/
4498,
/**/
4497,
/**/
4496,
/**/
4495,
/**/
4494,
/**/
4493,
/**/
4492,
/**/
4491,
/**/
4490,
/**/
4489,
/**/

View File

@@ -1883,7 +1883,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
lhs_T lhs;
long start_lnum = SOURCING_LNUM;
// Skip over the "var" or "[var, var]" to get to any "=".
// Skip over the "varname" or "[varname, varname]" to get to any "=".
p = skip_var_list(arg, TRUE, &var_count, &semicolon, TRUE);
if (p == NULL)
return *arg == '[' ? arg : NULL;