Compare commits

...

8 Commits

Author SHA1 Message Date
Bram Moolenaar
ef02f16609 patch 8.2.4899: with latin1 encoding CTRL-W might go before the cmdline
Problem:    With latin1 encoding CTRL-W might go before the start of the
            command line.
Solution:   Check already being at the start of the command line.
2022-05-07 10:49:10 +01:00
Bram Moolenaar
70d87690a3 patch 8.2.4898: Coverity complains about pointer usage
Problem:    Coverity complains about pointer usage.
Solution:   Move code for increment/decerment.
2022-05-07 10:03:27 +01:00
Bram Moolenaar
39be4981cd patch 8.2.4897: comment inside an expression in lambda ignores the rest
Problem:    Comment inside an expression in lambda ignores the rest of the
            expression.
Solution:   Truncate the line at the comment. (closes #10367)
2022-05-06 21:51:50 +01:00
Bram Moolenaar
a13e7acba9 patch 8.2.4896: expression in command block does not look after NL
Problem:    Expression in command block does not look after NL when command is
            typed.
Solution:   Skip over NL also when not in a script. (closes #10358)
2022-05-06 21:24:31 +01:00
Bram Moolenaar
d88934406c patch 8.2.4895: buffer overflow with invalid command with composing chars
Problem:    Buffer overflow with invalid command with composing chars.
Solution:   Check that the whole character fits in the buffer.
2022-05-06 20:38:47 +01:00
LemonBoy
5a7b6dc23c patch 8.2.4894: MS-Windows: not using italics
Problem:    MS-Windows: not using italics.
Solution:   Use italics.  Simplify the code. (closes #10359)
2022-05-06 18:38:41 +01:00
Bram Moolenaar
44433da534 patch 8.2.4893: distributed import files are not installed
Problem:    Distributed import files are not installed.
Solution:   Add rules to Makefile and NSIS.
2022-05-06 18:08:52 +01:00
Bram Moolenaar
ec89223478 patch 8.2.4892: test failures because of changed error messages
Problem:    Test failures because of changed error messages.
Solution:   Adjust the exptected error messages.
2022-05-06 17:53:06 +01:00
19 changed files with 147 additions and 100 deletions

View File

@@ -403,6 +403,9 @@ Section "$(str_section_exe)" id_section_exe
SetOutPath $0\autoload\xml
File ${VIMRT}\autoload\xml\*.*
SetOutPath $0\import\dist
File ${VIMRT}\import\dist\*.*
SetOutPath $0\bitmaps
File ${VIMSRC}\vim.ico
@@ -1044,6 +1047,7 @@ Section "un.$(str_unsection_exe)" id_unsection_exe
RMDir /r $0\compiler
RMDir /r $0\doc
RMDir /r $0\ftplugin
RMDir /r $0\import
RMDir /r $0\indent
RMDir /r $0\macros
RMDir /r $0\pack

View File

@@ -1052,6 +1052,7 @@ COLSUBDIR = /colors
SYNSUBDIR = /syntax
INDSUBDIR = /indent
AUTOSUBDIR = /autoload
IMPORTSUBDIR = /import
PLUGSUBDIR = /plugin
FTPLUGSUBDIR = /ftplugin
LANGSUBDIR = /lang
@@ -1074,6 +1075,7 @@ PODIR = po
### SYNSUBLOC location for syntax files
### INDSUBLOC location for indent files
### AUTOSUBLOC location for standard autoload files
### IMPORTSUBLOC location for standard import files
### PLUGSUBLOC location for standard plugin files
### FTPLUGSUBLOC location for ftplugin files
### LANGSUBLOC location for language files
@@ -1096,6 +1098,7 @@ COLSUBLOC = $(VIMRTLOC)$(COLSUBDIR)
SYNSUBLOC = $(VIMRTLOC)$(SYNSUBDIR)
INDSUBLOC = $(VIMRTLOC)$(INDSUBDIR)
AUTOSUBLOC = $(VIMRTLOC)$(AUTOSUBDIR)
IMPORTSUBLOC = $(VIMRTLOC)$(IMPORTSUBDIR)
PLUGSUBLOC = $(VIMRTLOC)$(PLUGSUBDIR)
FTPLUGSUBLOC = $(VIMRTLOC)$(FTPLUGSUBDIR)
LANGSUBLOC = $(VIMRTLOC)$(LANGSUBDIR)
@@ -1200,6 +1203,9 @@ INDSOURCE = ../runtime/indent
# Where to copy the standard plugin files from
AUTOSOURCE = ../runtime/autoload
# Where to copy the standard import files from
IMPORTSOURCE = ../runtime/import
# Where to copy the standard plugin files from
PLUGSOURCE = ../runtime/plugin
@@ -1475,6 +1481,7 @@ DEST_COL = $(DESTDIR)$(COLSUBLOC)
DEST_SYN = $(DESTDIR)$(SYNSUBLOC)
DEST_IND = $(DESTDIR)$(INDSUBLOC)
DEST_AUTO = $(DESTDIR)$(AUTOSUBLOC)
DEST_IMPORT = $(DESTDIR)$(IMPORTSUBLOC)
DEST_PLUG = $(DESTDIR)$(PLUGSUBLOC)
DEST_FTP = $(DESTDIR)$(FTPLUGSUBLOC)
DEST_LANG = $(DESTDIR)$(LANGSUBLOC)
@@ -2373,6 +2380,7 @@ installruntime: installrtbase installmacros installpack installtutor installspel
installrtbase: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(DEST_RT) \
$(DEST_HELP) $(DEST_PRINT) $(DEST_COL) $(DEST_SYN) $(DEST_IND) \
$(DEST_FTP) $(DEST_AUTO) $(DEST_AUTO)/dist $(DEST_AUTO)/xml \
$(DEST_IMPORT) $(DEST_IMPORT)/dist \
$(DEST_PLUG) $(DEST_TUTOR) $(DEST_SPELL) $(DEST_COMP)
-$(SHELL) ./installman.sh install $(DEST_MAN) "" $(INSTALLMANARGS)
# Generate the help tags with ":helptags" to handle all languages.
@@ -2451,6 +2459,9 @@ installrtbase: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(DEST_RT) \
cd $(DEST_AUTO)/dist; chmod $(HELPMOD) *.vim
cd $(AUTOSOURCE)/xml; $(INSTALL_DATA) *.vim $(DEST_AUTO)/xml
cd $(DEST_AUTO)/xml; chmod $(HELPMOD) *.vim
# install the standard import files
cd $(IMPORTSOURCE)/dist; $(INSTALL_DATA) *.vim $(DEST_IMPORT)/dist
cd $(DEST_IMPORT)/dist; chmod $(HELPMOD) *.vim
# install the standard plugin files
cd $(PLUGSOURCE); $(INSTALL_DATA) *.vim README.txt $(DEST_PLUG)
cd $(DEST_PLUG); chmod $(HELPMOD) *.vim README.txt
@@ -2686,7 +2697,8 @@ $(DESTDIR)$(exec_prefix) $(DEST_BIN) \
$(DEST_PRINT) $(DEST_COL) $(DEST_SYN) $(DEST_IND) $(DEST_FTP) \
$(DEST_LANG) $(DEST_KMAP) $(DEST_COMP) $(DEST_MACRO) \
$(DEST_PACK) $(DEST_TOOLS) $(DEST_TUTOR) $(DEST_SPELL) \
$(DEST_AUTO) $(DEST_AUTO)/dist $(DEST_AUTO)/xml $(DEST_PLUG):
$(DEST_AUTO) $(DEST_AUTO)/dist $(DEST_AUTO)/xml \
$(DEST_IMPORT) $(DEST_IMPORT)/dist $(DEST_PLUG):
$(MKDIR_P) $@
-chmod $(DIRMOD) $@
@@ -2872,8 +2884,10 @@ uninstall_runtime:
-rm -rf $(DEST_FTP)/*.vim $(DEST_FTP)/README.txt $(DEST_FTP)/logtalk.dict
-rm -f $(DEST_AUTO)/*.vim $(DEST_AUTO)/README.txt
-rm -f $(DEST_AUTO)/dist/*.vim $(DEST_AUTO)/xml/*.vim
-rm -f $(DEST_IMPORT)/dist/*.vim
-rm -f $(DEST_PLUG)/*.vim $(DEST_PLUG)/README.txt
-rmdir $(DEST_FTP) $(DEST_AUTO)/dist $(DEST_AUTO)/xml $(DEST_AUTO)
-rmdir $(DEST_IMPORT)/dist $(DEST_IMPORT)
-rmdir $(DEST_PLUG) $(DEST_RT)
# This will fail when other Vim versions are installed, no worries.
-rmdir $(DEST_VIM)

View File

@@ -2175,7 +2175,8 @@ eval_next_non_blank(char_u *arg, evalarg_T *evalarg, int *getnext)
*getnext = FALSE;
if (in_vim9script()
&& evalarg != NULL
&& (evalarg->eval_cookie != NULL || evalarg->eval_cctx != NULL)
&& (evalarg->eval_cookie != NULL || evalarg->eval_cctx != NULL
|| *p == NL)
&& (*p == NUL || *p == NL
|| (vim9_comment_start(p) && VIM_ISWHITE(p[-1]))))
{
@@ -2207,8 +2208,15 @@ eval_next_line(char_u *arg, evalarg_T *evalarg)
garray_T *gap = &evalarg->eval_ga;
char_u *line;
if (arg != NULL && *arg == NL)
return skipwhite(arg + 1);
if (arg != NULL)
{
if (*arg == NL)
return skipwhite(arg + 1);
// Truncate before a trailing comment, so that concatenating the lines
// won't turn the rest into a comment.
if (*skipwhite(arg) == '#')
*arg = NUL;
}
if (evalarg->eval_cookie != NULL)
line = evalarg->eval_getline(0, evalarg->eval_cookie, 0,

View File

@@ -3435,7 +3435,7 @@ append_command(char_u *cmd)
STRCAT(IObuff, ": ");
d = IObuff + STRLEN(IObuff);
while (*s != NUL && d - IObuff < IOSIZE - 7)
while (*s != NUL && d - IObuff + 5 < IOSIZE)
{
if (enc_utf8 ? (s[0] == 0xc2 && s[1] == 0xa0) : *s == 0xa0)
{
@@ -3443,6 +3443,8 @@ append_command(char_u *cmd)
STRCPY(d, "<a0>");
d += 4;
}
else if (d - IObuff + (*mb_ptr2len)(s) + 1 >= IOSIZE)
break;
else
MB_COPY_CHAR(s, d);
}

View File

@@ -1082,10 +1082,13 @@ cmdline_erase_chars(
{
while (p > ccline.cmdbuff && vim_isspace(p[-1]))
--p;
i = vim_iswordc(p[-1]);
while (p > ccline.cmdbuff && !vim_isspace(p[-1])
&& vim_iswordc(p[-1]) == i)
--p;
if (p > ccline.cmdbuff)
{
i = vim_iswordc(p[-1]);
while (p > ccline.cmdbuff && !vim_isspace(p[-1])
&& vim_iswordc(p[-1]) == i)
--p;
}
}
else
--p;

View File

@@ -6605,25 +6605,31 @@ update_tcap(int attr)
# ifdef FEAT_TERMGUICOLORS
# define KSSIZE 20
struct ks_tbl_s
typedef enum
{
int code; // value of KS_
char *vtp; // code in vtp mode
char *vtp2; // code in vtp2 mode
char buf[KSSIZE]; // save buffer in non-vtp mode
char vbuf[KSSIZE]; // save buffer in vtp mode
char v2buf[KSSIZE]; // save buffer in vtp2 mode
char arr[KSSIZE]; // real buffer
CMODE_INDEXED = 0, // Use cmd.exe 4bit palette.
CMODE_RGB, // Use 24bit RGB colors using VTP.
CMODE_256COL, // Emulate xterm's 256-color palette using VTP.
CMODE_LAST,
} cmode_T;
struct ks_tbl_S
{
int code; // value of KS_
char *vtp; // code in RGB mode
char *vtp2; // code in 256color mode
char buf[CMODE_LAST][KSSIZE]; // real buffer
};
static struct ks_tbl_s ks_tbl[] =
static struct ks_tbl_S ks_tbl[] =
{
{(int)KS_ME, "\033|0m", "\033|0m"}, // normal
{(int)KS_MR, "\033|7m", "\033|7m"}, // reverse
{(int)KS_MD, "\033|1m", "\033|1m"}, // bold
{(int)KS_SO, "\033|91m", "\033|91m"}, // standout: bright red text
{(int)KS_SE, "\033|39m", "\033|39m"}, // standout end: default color
{(int)KS_CZH, "\033|95m", "\033|95m"}, // italic: bright magenta text
{(int)KS_CZH, "\033|3m", "\033|3m"}, // italic
{(int)KS_CZR, "\033|0m", "\033|0m"}, // italic end
{(int)KS_US, "\033|4m", "\033|4m"}, // underscore
{(int)KS_UE, "\033|24m", "\033|24m"}, // underscore end
@@ -6664,18 +6670,11 @@ swap_tcap(void)
{
# ifdef FEAT_TERMGUICOLORS
static int init_done = FALSE;
static int curr_mode;
struct ks_tbl_s *ks;
static cmode_T curr_mode;
struct ks_tbl_S *ks;
struct builtin_term *bt;
int mode;
enum
{
CMODEINDEX,
CMODE24,
CMODE256
};
cmode_T mode;
// buffer initialization
if (!init_done)
{
for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++)
@@ -6683,67 +6682,36 @@ swap_tcap(void)
bt = find_first_tcap(DEFAULT_TERM, ks->code);
if (bt != NULL)
{
STRNCPY(ks->buf, bt->bt_string, KSSIZE);
STRNCPY(ks->vbuf, ks->vtp, KSSIZE);
STRNCPY(ks->v2buf, ks->vtp2, KSSIZE);
// Preserve the original value.
STRNCPY(ks->buf[CMODE_INDEXED], bt->bt_string, KSSIZE);
STRNCPY(ks->buf[CMODE_RGB], ks->vtp, KSSIZE);
STRNCPY(ks->buf[CMODE_256COL], ks->vtp2, KSSIZE);
STRNCPY(ks->arr, bt->bt_string, KSSIZE);
bt->bt_string = &ks->arr[0];
bt->bt_string = ks->buf[CMODE_INDEXED];
}
}
init_done = TRUE;
curr_mode = CMODEINDEX;
curr_mode = CMODE_INDEXED;
}
if (p_tgc)
mode = CMODE24;
mode = CMODE_RGB;
else if (t_colors >= 256)
mode = CMODE256;
mode = CMODE_256COL;
else
mode = CMODEINDEX;
mode = CMODE_INDEXED;
if (mode == curr_mode)
return;
for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++)
{
bt = find_first_tcap(DEFAULT_TERM, ks->code);
if (bt != NULL)
{
switch (curr_mode)
{
case CMODEINDEX:
STRNCPY(&ks->buf[0], bt->bt_string, KSSIZE);
break;
case CMODE24:
STRNCPY(&ks->vbuf[0], bt->bt_string, KSSIZE);
break;
default:
STRNCPY(&ks->v2buf[0], bt->bt_string, KSSIZE);
}
}
bt->bt_string = ks->buf[mode];
}
if (mode != curr_mode)
{
for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++)
{
bt = find_first_tcap(DEFAULT_TERM, ks->code);
if (bt != NULL)
{
switch (mode)
{
case CMODEINDEX:
STRNCPY(bt->bt_string, &ks->buf[0], KSSIZE);
break;
case CMODE24:
STRNCPY(bt->bt_string, &ks->vbuf[0], KSSIZE);
break;
default:
STRNCPY(bt->bt_string, &ks->v2buf[0], KSSIZE);
}
}
}
curr_mode = mode;
}
curr_mode = mode;
# endif
}

View File

@@ -773,6 +773,9 @@ func Test_cmdline_remove_char()
call feedkeys(":abc def\<S-Left>\<C-U>\<C-B>\"\<CR>", 'tx')
call assert_equal('"def', @:, e)
" This was going before the start in latin1.
call feedkeys(": \<C-W>\<CR>", 'tx')
endfor
let &encoding = encoding_save
@@ -3353,6 +3356,17 @@ func Test_cmdline_complete_scriptnames()
set wildmenu&
endfunc
" this was going over the end of IObuff
func Test_report_error_with_composing()
let caught = 'no'
try
exe repeat('0', 987) .. "0\xdd\x80\xdd\x80\xdd\x80\xdd\x80"
catch /E492:/
let caught = 'yes'
endtry
call assert_equal('yes', caught)
endfunc
" Test for expanding 2-letter and 3-letter :substitute command arguments.
" These commands don't accept an argument.
func Test_cmdline_complete_substitute_short()

View File

@@ -141,7 +141,7 @@ func Test_source_sfile()
if RunVim([], [], '--clean -s Xscript')
call assert_equal([
\ 'E1274: No script file name to substitute for "<script>"',
\ 'E498: no :source file name to substitute for "<sfile>"'],
\ 'E498: No :source file name to substitute for "<sfile>"'],
\ readfile('Xresult'))
endif
call delete('Xscript')

View File

@@ -70,6 +70,16 @@ func Test_lambda_vim9cmd_linebreak()
exe 'sleep ' .. [20, 100, 500, 500, 500][g:run_nr] .. 'm'
call assert_equal('done', g:result)
unlet g:result
let lines =<< trim END
g:result = [0]->map((_, v) =>
1 # inline comment
+
2
)
assert_equal([3], g:result)
END
call v9.CheckDefAndScriptSuccess(lines)
endfunc
func Test_lambda_with_partial()

View File

@@ -711,7 +711,7 @@ func Test_tcl_exit()
call assert_fails('tcl exit x', 'expected integer but got "x"')
tcl set foo "foo"
call assert_fails('tcl exit 3', 'E572: exit code 3')
call assert_fails('tcl exit 3', 'E572: Exit code 3')
" The Tcl interpreter should have been deleted and a new one
" is re-created with the next :tcl command.

View File

@@ -705,6 +705,11 @@ func Test_usercmd_with_block()
END
call v9.CheckScriptSuccess(lines)
call assert_equal('true', g:result)
unlet g:result
call feedkeys(":EchoCond\<CR>", 'xt')
call assert_equal('true', g:result)
delcommand EchoCond
unlet g:result

View File

@@ -293,7 +293,7 @@ def Test_assign_concat()
var ls: list<string> = []
ls[-1] ..= 'foo'
END
v9.CheckDefExecAndScriptFailure(lines, 'E684: list index out of range: -1', 2)
v9.CheckDefExecAndScriptFailure(lines, 'E684: List index out of range: -1', 2)
enddef
def Test_assign_register()
@@ -1641,7 +1641,7 @@ def Test_assign_list()
l[g:idx : 1] = [0]
echo l
END
v9.CheckDefExecAndScriptFailure(lines, 'E684: list index out of range: 3')
v9.CheckDefExecAndScriptFailure(lines, 'E684: List index out of range: 3')
lines =<< trim END
var l = [1, 2]

View File

@@ -2157,7 +2157,7 @@ def Test_job_getchannel()
CheckFeature job
else
v9.CheckDefAndScriptFailure(['job_getchannel("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1'])
assert_fails('job_getchannel(test_null_job())', 'E916: not a valid job')
assert_fails('job_getchannel(test_null_job())', 'E916: Not a valid job')
endif
enddef
@@ -2166,7 +2166,7 @@ def Test_job_info()
CheckFeature job
else
v9.CheckDefAndScriptFailure(['job_info("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1'])
assert_fails('job_info(test_null_job())', 'E916: not a valid job')
assert_fails('job_info(test_null_job())', 'E916: Not a valid job')
endif
enddef
@@ -4071,8 +4071,8 @@ def Test_substitute()
assert_equal('AX234', res)
if has('job')
assert_fails('"text"->substitute(".*", () => test_null_job(), "")', 'E908: using an invalid value as a String: job')
assert_fails('"text"->substitute(".*", () => test_null_channel(), "")', 'E908: using an invalid value as a String: channel')
assert_fails('"text"->substitute(".*", () => test_null_job(), "")', 'E908: Using an invalid value as a String: job')
assert_fails('"text"->substitute(".*", () => test_null_channel(), "")', 'E908: Using an invalid value as a String: channel')
endif
v9.CheckDefAndScriptFailure(['substitute(1, "b", "1", "d")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
v9.CheckDefAndScriptFailure(['substitute("a", 2, "1", "d")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])

View File

@@ -3114,7 +3114,7 @@ def Test_expr8_any_index_slice()
v9.CheckDefExecAndScriptFailure(['echo g:testblob[2]'], 'E979:', 1)
v9.CheckDefExecAndScriptFailure(['echo g:testblob[-3]'], 'E979:', 1)
v9.CheckDefExecAndScriptFailure(['echo g:testlist[4]'], 'E684: list index out of range: 4', 1)
v9.CheckDefExecAndScriptFailure(['echo g:testlist[4]'], 'E684: List index out of range: 4', 1)
v9.CheckDefExecAndScriptFailure(['echo g:testlist[-5]'], 'E684:', 1)
v9.CheckDefExecAndScriptFailure(['echo g:testdict["a" : "b"]'], 'E719:', 1)

View File

@@ -3709,7 +3709,7 @@ def Run_Test_opfunc_error()
var buf = g:RunVimInTerminal('-S XTest_opfunc_error', {rows: 6, wait_for_ruler: 0})
g:WaitForAssert(() => assert_match('Press ENTER', term_getline(buf, 6)))
g:WaitForAssert(() => assert_match('E684: list index out of range: 0', term_getline(buf, 5)))
g:WaitForAssert(() => assert_match('E684: List index out of range: 0', term_getline(buf, 5)))
# clean up
g:StopVimInTerminal(buf)

View File

@@ -1527,7 +1527,7 @@ def Test_func_redefine_error()
source Xtestscript.vim
catch /E684/
# function name should contain <SNR> every time
assert_match('E684: list index out of range', v:exception)
assert_match('E684: List index out of range', v:exception)
assert_match('function <SNR>\d\+_Func, line 1', v:throwpoint)
endtry
endfor

View File

@@ -3077,7 +3077,7 @@ func Test_nested_if_else_errors()
endif
END
call writefile(code, 'Xtest')
call AssertException(['source Xtest'], 'Vim(else):E583: multiple :else')
call AssertException(['source Xtest'], 'Vim(else):E583: Multiple :else')
" :elseif after :else
let code =<< trim END

View File

@@ -746,6 +746,22 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4899,
/**/
4898,
/**/
4897,
/**/
4896,
/**/
4895,
/**/
4894,
/**/
4893,
/**/
4892,
/**/
4891,
/**/

View File

@@ -2018,20 +2018,6 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
lhs.lhs_name = NULL;
sp = p;
p = skipwhite(p);
op = p;
oplen = assignment_len(p, &heredoc);
if (var_count > 0 && oplen == 0)
// can be something like "[1, 2]->func()"
return arg;
if (oplen > 0 && (!VIM_ISWHITE(*sp) || !IS_WHITE_OR_NUL(op[oplen])))
{
error_white_both(op, oplen);
return NULL;
}
if (eap->cmdidx == CMD_increment || eap->cmdidx == CMD_decrement)
{
if (VIM_ISWHITE(eap->cmd[2]))
@@ -2044,6 +2030,23 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
oplen = 2;
incdec = TRUE;
}
else
{
sp = p;
p = skipwhite(p);
op = p;
oplen = assignment_len(p, &heredoc);
if (var_count > 0 && oplen == 0)
// can be something like "[1, 2]->func()"
return arg;
if (oplen > 0 && (!VIM_ISWHITE(*sp) || !IS_WHITE_OR_NUL(op[oplen])))
{
error_white_both(op, oplen);
return NULL;
}
}
if (heredoc)
{