Compare commits

...

10 Commits

Author SHA1 Message Date
Bram Moolenaar
8ce4b7ed85 patch 8.2.1384: no ATTENTION prompt for :vimgrep first match file
Problem:    No ATTENTION prompt for :vimgrep first match file.
Solution:   When there is an existing swap file do not keep the dummy buffer.
            (closes #6649)
2020-08-07 18:12:18 +02:00
Bram Moolenaar
9470a4d88a patch 8.2.1383: test 49 is old style
Problem:    Test 49 is old style.
Solution:   Convert test cases to new style. (Yegappan Lakshmanan,
            closes #6638)
2020-08-07 16:49:11 +02:00
Bram Moolenaar
8e1986e389 patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Problem:    Vim9: using :import in filetype plugin gives an error.
Solution:   Allow commands with the EX_LOCK_OK flag. (closes #6636)
2020-08-06 22:11:06 +02:00
Bram Moolenaar
56b8dc331d patch 8.2.1381: MS-Windows: crash with Python 3.5 when stdin is redirected
Problem:    MS-Windows: crash with Python 3.5 when stdin is redirected.
Solution:   Reconnect stdin. (Yasuhiro Matsumoto, Ken Takata, closes #6641)
2020-08-06 21:47:11 +02:00
Bram Moolenaar
3d945cc925 patch 8.2.1380: Vim9: return type of getreg() is always a string
Problem:    Vim9: return type of getreg() is always a string.
Solution:   Use list of strings when there are three arguments. (closes #6633)
2020-08-06 21:26:59 +02:00
Bram Moolenaar
ae95a3946b patch 8.2.1379: curly braces expression ending in " }" does not work
Problem:    Curly braces expression ending in " }" does not work.
Solution:   Skip over white space when checking for "}". (closes #6634)
2020-08-06 16:38:12 +02:00
Bram Moolenaar
bbd3e3c357 patch 8.2.1378: cannot put space between function name and paren
Problem:    Cannot put space between function name and paren.
Solution:   Allow this for backwards compatibility.
2020-08-06 11:23:36 +02:00
Bram Moolenaar
b8d732e93e patch 8.2.1377: triggering the ATTENTION prompt causes typeahead mess up
Problem:    Triggering the ATTENTION prompt causes typeahead to be messed up.
Solution:   Increment tb_change_cnt. (closes #6541)
2020-08-05 22:07:26 +02:00
Bram Moolenaar
803af686e2 patch 8.2.1376: Vim9: expression mapping causes error for using :import
Problem:    Vim9: expression mapping causes error for using :import.
Solution:   Add EX_LOCK_OK to :import and :export. (closes 3606)
2020-08-05 16:20:03 +02:00
Bram Moolenaar
c5da1fb7ea patch 8.2.1375: Vim9: method name with digit not accepted
Problem:    Vim9: method name with digit not accepted.
Solution:   Use eval_isnamec() instead of eval_isnamec1(). (closes #6613)
2020-08-05 15:43:44 +02:00
22 changed files with 1385 additions and 1199 deletions

View File

@@ -588,6 +588,8 @@ ifdef PYTHON3
CFLAGS += -DFEAT_PYTHON3
ifeq (yes, $(DYNAMIC_PYTHON3))
CFLAGS += -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"$(DYNAMIC_PYTHON3_DLL)\"
else
CFLAGS += -DPYTHON3_DLL=\"$(DYNAMIC_PYTHON3_DLL)\"
endif
endif

View File

@@ -1026,6 +1026,9 @@ PYTHON_LIB = $(PYTHON)\libs\python$(PYTHON_VER).lib
! ifndef PYTHON3_VER
PYTHON3_VER = 36
! endif
! ifndef DYNAMIC_PYTHON3_DLL
DYNAMIC_PYTHON3_DLL = python$(PYTHON3_VER).dll
! endif
! message Python3 requested (version $(PYTHON3_VER)) - root dir is "$(PYTHON3)"
! if "$(DYNAMIC_PYTHON3)" == "yes"
! message Python3 DLL will be loaded dynamically
@@ -1035,9 +1038,10 @@ PYTHON3_OBJ = $(OUTDIR)\if_python3.obj
PYTHON3_INC = /I "$(PYTHON3)\Include" /I "$(PYTHON3)\PC"
! if "$(DYNAMIC_PYTHON3)" == "yes"
CFLAGS = $(CFLAGS) -DDYNAMIC_PYTHON3 \
-DDYNAMIC_PYTHON3_DLL=\"python$(PYTHON3_VER).dll\"
-DDYNAMIC_PYTHON3_DLL=\"$(DYNAMIC_PYTHON3_DLL)\"
PYTHON3_LIB = /nodefaultlib:python$(PYTHON3_VER).lib
! else
CFLAGS = $(CFLAGS) -DPYTHON3_DLL=\"$(DYNAMIC_PYTHON3_DLL)\"
PYTHON3_LIB = $(PYTHON3)\libs\python$(PYTHON3_VER).lib
! endif
!endif

View File

@@ -817,7 +817,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
{
if (eval1(&start, &tv, NULL) == FAIL) // recursive!
return FAIL;
if (*start == '}')
if (*skipwhite(start) == '}')
return NOTDONE;
}

View File

@@ -3198,9 +3198,12 @@ eval7(
{
int flags = evalarg == NULL ? 0 : evalarg->eval_flags;
if (**arg == '(')
if ((in_vim9script() ? **arg : *skipwhite(*arg)) == '(')
{
// "name(..." recursive!
*arg = skipwhite(*arg);
ret = eval_func(arg, evalarg, s, len, rettv, flags, NULL);
}
else if (flags & EVAL_CONSTANT)
ret = FAIL;
else if (evaluate)

View File

@@ -393,6 +393,15 @@ ret_remove(int argcount UNUSED, type_T **argtypes)
return &t_any;
}
static type_T *
ret_getreg(int argcount, type_T **argtypes UNUSED)
{
// Assume that if the third argument is passed it's non-zero
if (argcount == 3)
return &t_list_string;
return &t_string;
}
static type_T *ret_f_function(int argcount, type_T **argtypes);
/*
@@ -641,7 +650,7 @@ static funcentry_T global_functions[] =
{"getpid", 0, 0, 0, ret_number, f_getpid},
{"getpos", 1, 1, FEARG_1, ret_list_number, f_getpos},
{"getqflist", 0, 1, 0, ret_list_or_dict_0, f_getqflist},
{"getreg", 0, 3, FEARG_1, ret_string, f_getreg},
{"getreg", 0, 3, FEARG_1, ret_getreg, f_getreg},
{"getreginfo", 0, 1, FEARG_1, ret_dict_any, f_getreginfo},
{"getregtype", 0, 1, FEARG_1, ret_string, f_getregtype},
{"gettabinfo", 0, 1, FEARG_1, ret_list_dict_any, f_gettabinfo},

View File

@@ -572,7 +572,7 @@ EXCMD(CMD_exit, "exit", ex_exit,
EX_RANGE|EX_WHOLEFOLD|EX_BANG|EX_FILE1|EX_ARGOPT|EX_DFLALL|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
ADDR_LINES),
EXCMD(CMD_export, "export", ex_export,
EX_EXTRA|EX_NOTRLCOM,
EX_EXTRA|EX_NOTRLCOM|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_exusage, "exusage", ex_exusage,
EX_TRLBAR,
@@ -698,7 +698,7 @@ EXCMD(CMD_imenu, "imenu", ex_menu,
EX_RANGE|EX_ZEROR|EX_EXTRA|EX_TRLBAR|EX_NOTRLCOM|EX_CTRLV|EX_CMDWIN|EX_LOCK_OK,
ADDR_OTHER),
EXCMD(CMD_import, "import", ex_import,
EX_EXTRA|EX_NOTRLCOM,
EX_EXTRA|EX_NOTRLCOM|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_inoremap, "inoremap", ex_map,
EX_EXTRA|EX_TRLBAR|EX_NOTRLCOM|EX_CTRLV|EX_CMDWIN|EX_LOCK_OK,

View File

@@ -2087,7 +2087,7 @@ do_one_cmd(
// Do allow ":checktime" (it is postponed).
// Do allow ":edit" (check for an argument later).
// Do allow ":file" with no arguments (check for an argument later).
if (!(ea.argt & EX_CMDWIN)
if (!(ea.argt & (EX_CMDWIN | EX_LOCK_OK))
&& ea.cmdidx != CMD_checktime
&& ea.cmdidx != CMD_edit
&& ea.cmdidx != CMD_file

View File

@@ -447,6 +447,8 @@ flush_buffers(flush_buffers_T flush_typeahead)
typebuf.tb_silent = 0;
cmd_silent = FALSE;
typebuf.tb_no_abbr_cnt = 0;
if (++typebuf.tb_change_cnt == 0)
typebuf.tb_change_cnt = 1;
}
/*

View File

@@ -907,6 +907,47 @@ python3_loaded(void)
static wchar_t *py_home_buf = NULL;
#if defined(MSWIN) && (PY_VERSION_HEX >= 0x030500f0)
// Python 3.5 or later will abort inside Py_Initialize() when stdin is
// redirected. Reconnect stdin to CONIN$.
// Note that the python DLL is linked to its own stdio DLL which can be
// differ from Vim's stdio.
static void
reset_stdin(void)
{
FILE *(*py__acrt_iob_func)(unsigned) = NULL;
FILE *(*pyfreopen)(const char *, const char *, FILE *) = NULL;
HINSTANCE hinst;
# ifdef DYNAMIC_PYTHON3
hinst = hinstPy3;
# else
hinst = GetModuleHandle(PYTHON3_DLL);
# endif
if (hinst == NULL)
return;
// Get "freopen" and "stdin" which are used in the python DLL.
// "stdin" is defined as "__acrt_iob_func(0)" in VC++ 2015 or later.
py__acrt_iob_func = get_dll_import_func(hinst, "__acrt_iob_func");
if (py__acrt_iob_func)
{
HINSTANCE hpystdiodll = find_imported_module_by_funcname(hinst,
"__acrt_iob_func");
if (hpystdiodll)
pyfreopen = (void*)GetProcAddress(hpystdiodll, "freopen");
}
// Reconnect stdin to CONIN$.
if (pyfreopen)
pyfreopen("CONIN$", "r", py__acrt_iob_func(0));
else
freopen("CONIN$", "r", stdin);
}
#else
# define reset_stdin()
#endif
static int
Python3_Init(void)
{
@@ -939,6 +980,7 @@ Python3_Init(void)
PyImport_AppendInittab("vim", Py3Init_vim);
reset_stdin();
Py_Initialize();
// Initialise threads, and below save the state using

View File

@@ -6015,6 +6015,23 @@ vgr_process_args(
return OK;
}
/*
* Return TRUE if "buf" had an existing swap file, the current swap file does
* not end in ".swp".
*/
static int
existing_swapfile(buf_T *buf)
{
if (buf->b_ml.ml_mfp != NULL)
{
char_u *fname = buf->b_ml.ml_mfp->mf_fname;
size_t len = STRLEN(fname);
return fname[len - 1] != 'p' || fname[len - 2] != 'w';
}
return FALSE;
}
/*
* Search for a pattern in a list of files and populate the quickfix list with
* the matches.
@@ -6125,7 +6142,8 @@ vgr_process_files(
buf = NULL;
}
else if (buf != *first_match_buf
|| (cmd_args->flags & VGR_NOJUMP))
|| (cmd_args->flags & VGR_NOJUMP)
|| existing_swapfile(buf))
{
unload_dummy_buffer(buf, dirname_start);
// Keeping the buffer, remove the dummy flag.

View File

@@ -91,6 +91,9 @@ set encoding=utf-8
let s:test_script_fname = expand('%')
au! SwapExists * call HandleSwapExists()
func HandleSwapExists()
if exists('g:ignoreSwapExists')
return
endif
" Ignore finding a swap file for the test script (the user might be
" editing it and do ":make test_name") and the output file.
" Report finding another swap file and chose 'q' to avoid getting stuck.

View File

@@ -1,18 +1,9 @@
Results of test49.vim:
*** Test 52: OK (1247112011)
*** Test 53: OK (131071)
*** Test 54: OK (2047)
*** Test 55: OK (1023)
*** Test 56: OK (511)
*** Test 57: OK (2147450880)
*** Test 58: OK (624945)
*** Test 59: OK (2038431743)
*** Test 60: OK (311511339)
*** Test 61: OK (374889517)
*** Test 62: OK (286331153)
*** Test 63: OK (236978127)
*** Test 64: OK (1499645335)
*** Test 65: OK (70187)
*** Test 66: OK (5464)
*** Test 67: OK (212514423)
*** Test 68: OK (212514423)

File diff suppressed because it is too large Load Diff

View File

@@ -532,4 +532,26 @@ func Test_setreg_basic()
call assert_fails('call setreg(1, ["", "", [], ""])', 'E730:')
endfunc
func Test_curly_assignment()
let s:svar = 'svar'
let g:gvar = 'gvar'
let lname = 'gvar'
let gname = 'gvar'
let {'s:'.lname} = {'g:'.gname}
call assert_equal('gvar', s:gvar)
let s:gvar = ''
let { 's:'.lname } = { 'g:'.gname }
call assert_equal('gvar', s:gvar)
let s:gvar = ''
let { 's:' . lname } = { 'g:' . gname }
call assert_equal('gvar', s:gvar)
let s:gvar = ''
let { 's:' .. lname } = { 'g:' .. gname }
call assert_equal('gvar', s:gvar)
unlet s:svar
unlet s:gvar
unlet g:gvar
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -599,6 +599,11 @@ func Test_expr_eval_error()
call assert_fails("let v = -{}", 'E728:')
endfunc
func Test_white_in_function_call()
let text = substitute ( 'some text' , 't' , 'T' , 'g' )
call assert_equal('some TexT', text)
endfunc
" Test for float value comparison
func Test_float_compare()
CheckFeature float

View File

@@ -2837,6 +2837,26 @@ func Test_vimgrep_with_no_last_search_pat()
call delete('Xresult')
endfunc
func Test_vimgrep_existing_swapfile()
call writefile(['match apple with apple'], 'Xapple')
call writefile(['swapfile'], '.Xapple.swp')
let g:foundSwap = 0
let g:ignoreSwapExists = 1
augroup grep
au SwapExists * let foundSwap = 1 | let v:swapchoice = 'e'
augroup END
vimgrep apple Xapple
call assert_equal(1, g:foundSwap)
call assert_match('.Xapple.swo', swapname(''))
call delete('Xapple')
call delete('Xapple.swp')
augroup grep
au! SwapExists
augroup END
unlet g:ignoreSwapExists
endfunc
func XfreeTests(cchar)
call s:setup_commands(a:cchar)

View File

@@ -1674,18 +1674,22 @@ def Echo(arg: any): string
return arg
enddef
def s:EchoArg(arg: any): string
def s:Echo4Arg(arg: any): string
return arg
enddef
def Test_expr7_call()
assert_equal('yes', 'yes'->Echo())
assert_equal('yes', 'yes'
->s:EchoArg())
->s:Echo4Arg())
assert_equal(1, !range(5)->empty())
assert_equal([0, 1, 2], --3->range())
call CheckDefFailure(["let x = 'yes'->Echo"], 'E107:')
call CheckScriptFailure([
"vim9script",
"let x = substitute ('x', 'x', 'x', 'x')"
], 'E121:')
enddef

View File

@@ -1202,6 +1202,12 @@ def Test_filter_return_type()
assert_equal(6, res)
enddef
def Test_getreg_return_type()
let s1: string = getreg('"')
let s2: string = getreg('"', 1)
let s3: list<string> = getreg('"', 1, 1)
enddef
def Wrong_dict_key_type(items: list<number>): list<number>
return filter(items, {_, val -> get({val: 1}, 'x')})
enddef

View File

@@ -1351,6 +1351,66 @@ def Test_vim9_import_export()
delete('Xvim9_script')
enddef
func g:Trigger()
source Ximport.vim
return "echo 'yes'\<CR>"
endfunc
def Test_import_export_expr_map()
# check that :import and :export work when buffer is locked
let export_lines =<< trim END
vim9script
export def That(): string
return 'yes'
enddef
END
writefile(export_lines, 'Xexport_that.vim')
let import_lines =<< trim END
vim9script
import That from './Xexport_that.vim'
assert_equal('yes', That())
END
writefile(import_lines, 'Ximport.vim')
nnoremap <expr> trigger g:Trigger()
feedkeys('trigger', "xt")
delete('Xexport.vim')
delete('Ximport.vim')
nunmap trigger
enddef
def Test_import_in_filetype()
# check that :import works when the buffer is locked
mkdir('ftplugin', 'p')
let export_lines =<< trim END
vim9script
export let That = 'yes'
END
writefile(export_lines, 'ftplugin/Xexport_that.vim')
let import_lines =<< trim END
vim9script
import That from './Xexport_that.vim'
assert_equal('yes', That)
g:did_load_mytpe = 1
END
writefile(import_lines, 'ftplugin/qf.vim')
let save_rtp = &rtp
&rtp = getcwd() .. ',' .. &rtp
filetype plugin on
copen
assert_equal(1, g:did_load_mytpe)
quit!
delete('Xexport.vim')
delete('ftplugin', 'rf')
&rtp = save_rtp
enddef
def Test_vim9script_fails()
CheckScriptFailure(['scriptversion 2', 'vim9script'], 'E1039:')
CheckScriptFailure(['vim9script', 'scriptversion 2'], 'E1040:')

File diff suppressed because it is too large Load Diff

View File

@@ -754,6 +754,26 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1384,
/**/
1383,
/**/
1382,
/**/
1381,
/**/
1380,
/**/
1379,
/**/
1378,
/**/
1377,
/**/
1376,
/**/
1375,
/**/
1374,
/**/

View File

@@ -3854,7 +3854,7 @@ compile_subscript(
}
if (ASCII_ISALPHA(*p) && p[1] == ':')
p += 2;
for ( ; eval_isnamec1(*p); ++p)
for ( ; eval_isnamec(*p); ++p)
;
if (*p != '(')
{