Compare commits

...

6 Commits

Author SHA1 Message Date
Bram Moolenaar
a90afb9a59 patch 8.2.1224: Vim9: arguments from partial are not used
Problem:    Vim9: arguments from partial are not used.
Solution:   Put the partial arguments on the stack. (closes #6460)
2020-07-15 22:38:56 +02:00
Bram Moolenaar
e30f64b4b5 patch 8.2.1223: Vim9: invalid type error for function default value
Problem:    Vim9: invalid type error for function default value.
Solution:   Use right argument index. (closes #6458)
2020-07-15 19:48:20 +02:00
Bram Moolenaar
657a826c07 patch 8.2.1222: using valgrind in Vim command started by test doesn't work
Problem:    When using valgrind a Vim command started by a test uses the same
            log file name which gets overwritten.
Solution:   Fix regexp to rename the log file.
2020-07-15 18:29:18 +02:00
Bram Moolenaar
02f9e6a60f patch 8.2.1221: memory leak when updating popup window
Problem:    Memory leak when updating popup window.
Solution:   Clear search highlighting.
2020-07-15 18:27:08 +02:00
Bram Moolenaar
452143c6bf patch 8.2.1220: memory access error when dragging a popup window
Problem:    memory access error when dragging a popup window over a buffer
            with folding.
Solution:   Avoid going over the end of the cache. (closes #6438)
2020-07-15 17:38:21 +02:00
Bram Moolenaar
5966ea105e patch 8.2.1219: symlink not followed if dirname ends in //
Problem:    Symlink not followed if dirname ends in //.
Solution:   Resolve symlink earlier. (Tomáš Janoušek, closes #6454)
2020-07-15 15:30:05 +02:00
14 changed files with 191 additions and 32 deletions

View File

@@ -3287,10 +3287,12 @@ ml_append_buf(
#endif
/*
* Replace line lnum, with buffering, in current buffer.
* Replace line "lnum", with buffering, in current buffer.
*
* If "copy" is TRUE, make a copy of the line, otherwise the line has been
* copied to allocated memory already.
* If "copy" is FALSE the "line" may be freed to add text properties!
* Do not use it after calling ml_replace().
*
* Check: The caller of this function should probably also call
* changed_lines(), unless update_screen(NOT_VALID) is used.
@@ -4366,6 +4368,11 @@ makeswapname(
char_u *fname_res = fname;
#ifdef HAVE_READLINK
char_u fname_buf[MAXPATHL];
// Expand symlink in the file name, so that we put the swap file with the
// actual file instead of with the symlink.
if (resolve_symlink(fname, fname_buf) == OK)
fname_res = fname_buf;
#endif
#if defined(UNIX) || defined(MSWIN) // Need _very_ long file names
@@ -4375,7 +4382,7 @@ makeswapname(
if (after_pathsep(dir_name, s) && len > 1 && s[-1] == s[-2])
{ // Ends with '//', Use Full path
r = NULL;
if ((s = make_percent_swname(dir_name, fname)) != NULL)
if ((s = make_percent_swname(dir_name, fname_res)) != NULL)
{
r = modname(s, (char_u *)".swp", FALSE);
vim_free(s);
@@ -4384,13 +4391,6 @@ makeswapname(
}
#endif
#ifdef HAVE_READLINK
// Expand symlink in the file name, so that we put the swap file with the
// actual file instead of with the symlink.
if (resolve_symlink(fname, fname_buf) == OK)
fname_res = fname_buf;
#endif
r = buf_modname(
(buf->b_p_sn || buf->b_shortname),
fname_res,

View File

@@ -2839,10 +2839,10 @@ check_termcode_mouse(
/*
* Compute the buffer line position from the screen position "rowp" / "colp" in
* window "win".
* "plines_cache" can be NULL (no cache) or an array with "win->w_height"
* entries that caches the plines_win() result from a previous call. Entry is
* zero if not computed yet. There must be no text or setting changes since
* the entry is put in the cache.
* "plines_cache" can be NULL (no cache) or an array with "Rows" entries that
* caches the plines_win() result from a previous call. Entry is zero if not
* computed yet. There must be no text or setting changes since the entry is
* put in the cache.
* Returns TRUE if the position is below the last line.
*/
int
@@ -2871,7 +2871,10 @@ mouse_comp_pos(
{
int cache_idx = lnum - win->w_topline;
if (plines_cache != NULL && plines_cache[cache_idx] > 0)
// Only "Rows" lines are cached, with folding we'll run out of entries
// and use the slow way.
if (plines_cache != NULL && cache_idx < Rows
&& plines_cache[cache_idx] > 0)
count = plines_cache[cache_idx];
else
{
@@ -2892,7 +2895,7 @@ mouse_comp_pos(
else
#endif
count = plines_win(win, lnum, TRUE);
if (plines_cache != NULL)
if (plines_cache != NULL && cache_idx < Rows)
plines_cache[cache_idx] = count;
}
if (count > row)

View File

@@ -3855,6 +3855,11 @@ update_popups(void (*win_update)(win_T *wp))
// Back to the normal zindex.
screen_zindex = 0;
}
#if defined(FEAT_SEARCH_EXTRA)
// In case win_update() called start_search_hl().
end_search_hl();
#endif
}
/*

View File

@@ -3,8 +3,14 @@
@34|╔+0#0000001#ffd7ff255|═@3|╗| +0#0000000#ffffff0@34
@34|║+0#0000001#ffd7ff255|1@3|║| +0#0000000#ffffff0@34
|!+0#ffffff16#00e0003|/|b|i|n|/|s|h| |[|r|u|n@1|i|n|g|]| @15|║+0#0000001#ffd7ff255|2@3|║| +0#ffffff16#00e0003@34
> +0#0000000#ffffff0@33|╚+0#0000001#ffd7ff255|═@3|⇲| +0#0000000#ffffff0@34
|~+0#4040ff13&| @73
|~| @73
|[+3#0000000&|N|o| |N|a|m|e|]| @65
>++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@14|╚+0#0000001#ffd7ff255|═@3|⇲|-+0#0000e05#a8a8a8255@34
|1+0#0000000#ffffff0@1| @72
|++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@55
|2+0#0000000#ffffff0|3| @72
|++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@55
|3+0#0000000#ffffff0|5| @72
|++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@55
|4+0#0000000#ffffff0|7| @72
|++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@55
|[+3#0000000#ffffff0|N|o| |N|a|m|e|]| |[|+|]| @61
| +0&&@74

View File

@@ -3,8 +3,14 @@
@14|╔+0#0000001#ffd7ff255|═@3|╗| +0#0000000#ffffff0@54
@14|║+0#0000001#ffd7ff255|1@3|║| +0#0000000#ffffff0@54
|!+0#ffffff16#00e0003|/|b|i|n|/|s|h| |[|r|u|n@1|║+0#0000001#ffd7ff255|2@3|║| +0#ffffff16#00e0003@54
> +0#0000000#ffffff0@13|╚+0#0000001#ffd7ff255|═@3|⇲| +0#0000000#ffffff0@54
|~+0#4040ff13&| @73
|~| @73
|[+3#0000000&|N|o| |N|a|m|e|]| @65
|:+0&&|c|a|l@1| |D|r|a|g|i|t|(|)| @60
>++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |╚+0#0000001#ffd7ff255|═@3|⇲|-+0#0000e05#a8a8a8255@54
|1+0#0000000#ffffff0@1| @72
|++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@55
|2+0#0000000#ffffff0|3| @72
|++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@55
|3+0#0000000#ffffff0|5| @72
|++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@55
|4+0#0000000#ffffff0|7| @72
|++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@55
|[+3#0000000#ffffff0|N|o| |N|a|m|e|]| |[|+|]| @61
|:+0&&|c|a|l@1| |D|r|a|g|i|t|L|e|f|t|(|)| @56

View File

@@ -0,0 +1,16 @@
|v+0&#ffffff0|i|m|>| @70
@75
@75
@75
|!+0#ffffff16#00e0003|/|b|i|n|/|s|h| |[|r|u|n@1|i|n|g|]| @56
>++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@55
|1+0#0000000#ffffff0@1| @72
|++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@55
|2+0#0000000#ffffff0|3| @72
|++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@55
|3+0#0000000#ffffff0|5| @72
|++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@14|╔+0#0000001#ffd7ff255|═@3|╗|-+0#0000e05#a8a8a8255@34
|4+0#0000000#ffffff0|7| @31|║+0#0000001#ffd7ff255|1@3|║| +0#0000000#ffffff0@34
|++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@14|║+0#0000001#ffd7ff255|2@3|║|-+0#0000e05#a8a8a8255@34
|[+3#0000000#ffffff0|N|o| |N|a|m|e|]| |[|+|]| @20|╚+0#0000001#ffd7ff255|═@3|⇲| +3#0000000#ffffff0@34
|:+0&&|c|a|l@1| |D|r|a|g|i|t|D|o|w|n|(|)| @56

View File

@@ -0,0 +1,16 @@
|v+0&#ffffff0|i|m|>| @70
@75
@75
@75
|!+0#ffffff16#00e0003|/|b|i|n|/|s|h| |[|r|u|n@1|i|n|g|]| @56
>++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@55
|1+0#0000000#ffffff0@1| @72
|++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@55
|2+0#0000000#ffffff0|3| @72
|++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |f|o|l|d| |-@55
|3+0#0000000#ffffff0|5| @72
|++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |╔+0#0000001#ffd7ff255|═@3|╗|-+0#0000e05#a8a8a8255@54
|4+0#0000000#ffffff0|7| @11|║+0#0000001#ffd7ff255|1@3|║| +0#0000000#ffffff0@54
|++0#0000e05#a8a8a8255|-@1| |1@1| |l|i|n|e|s|:| |║+0#0000001#ffd7ff255|2@3|║|-+0#0000e05#a8a8a8255@54
|[+3#0000000#ffffff0|N|o| |N|a|m|e|]| |[|+|]| |╚+0#0000001#ffd7ff255|═@3|⇲| +3#0000000#ffffff0@54
|:+0&&|c|a|l@1| |D|r|a|g|i|t|D|o|w|n|L|e|f|t|(|)| @52

View File

@@ -268,7 +268,7 @@ func GetVimCommand(...)
" If using valgrind, make sure every run uses a different log file.
if cmd =~ 'valgrind.*--log-file='
let cmd = substitute(cmd, '--log-file=\(^\s*\)', '--log-file=\1.' . g:valgrind_cnt, '')
let cmd = substitute(cmd, '--log-file=\(\S*\)', '--log-file=\1.' . g:valgrind_cnt, '')
let g:valgrind_cnt += 1
endif

View File

@@ -584,9 +584,16 @@ func Test_popup_drag_termwin()
" create a popup that covers the terminal window
let lines =<< trim END
set foldmethod=marker
call setline(1, range(100))
for nr in range(7)
call setline(nr * 12 + 1, "fold {{{")
call setline(nr * 12 + 11 , "end }}}")
endfor
%foldclose
set shell=/bin/sh noruler
let $PS1 = 'vim> '
terminal
terminal ++rows=4
$wincmd w
let winid = popup_create(['1111', '2222'], #{
\ drag: 1,
@@ -594,19 +601,33 @@ func Test_popup_drag_termwin()
\ border: [],
\ line: 3,
\ })
func Dragit()
func DragitLeft()
call feedkeys("\<F3>\<LeftMouse>\<F4>\<LeftDrag>\<LeftRelease>", "xt")
endfunc
func DragitDown()
call feedkeys("\<F4>\<LeftMouse>\<F5>\<LeftDrag>\<LeftRelease>", "xt")
endfunc
func DragitDownLeft()
call feedkeys("\<F5>\<LeftMouse>\<F6>\<LeftDrag>\<LeftRelease>", "xt")
endfunc
map <silent> <F3> :call test_setmouse(3, &columns / 2)<CR>
map <silent> <F4> :call test_setmouse(3, &columns / 2 - 20)<CR>
map <silent> <F5> :call test_setmouse(12, &columns / 2)<CR>
map <silent> <F6> :call test_setmouse(12, &columns / 2 - 20)<CR>
END
call writefile(lines, 'XtestPopupTerm')
let buf = RunVimInTerminal('-S XtestPopupTerm', #{rows: 10})
let buf = RunVimInTerminal('-S XtestPopupTerm', #{rows: 16})
call VerifyScreenDump(buf, 'Test_popupwin_term_01', {})
call term_sendkeys(buf, ":call Dragit()\<CR>")
call term_sendkeys(buf, ":call DragitLeft()\<CR>")
call VerifyScreenDump(buf, 'Test_popupwin_term_02', {})
call term_sendkeys(buf, ":call DragitDown()\<CR>")
call VerifyScreenDump(buf, 'Test_popupwin_term_03', {})
call term_sendkeys(buf, ":call DragitDownLeft()\<CR>")
call VerifyScreenDump(buf, 'Test_popupwin_term_04', {})
" clean up
call StopVimInTerminal(buf)
call delete('XtestPopupTerm')

View File

@@ -377,4 +377,34 @@ func Test_swap_prompt_splitwin()
call delete('Xfile1')
endfunc
func Test_swap_symlink()
if !has("unix")
return
endif
call writefile(['text'], 'Xtestfile')
silent !ln -s -f Xtestfile Xtestlink
set dir=.
" Test that swap file uses the name of the file when editing through a
" symbolic link (so that editing the file twice is detected)
edit Xtestlink
call assert_match('Xtestfile\.swp$', s:swapname())
bwipe!
call mkdir('Xswapdir')
exe 'set dir=' . getcwd() . '/Xswapdir//'
" Check that this also works when 'directory' ends with '//'
edit Xtestlink
call assert_match('Xtestfile\.swp$', s:swapname())
bwipe!
set dir&
call delete('Xtestfile')
call delete('Xtestlink')
call delete('Xswapdir', 'rf')
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -104,11 +104,19 @@ def MyDefaultArgs(name = 'string'): string
return name
enddef
def MyDefaultSecond(name: string, second: bool = true): string
return second ? name : 'none'
enddef
def Test_call_default_args()
assert_equal('string', MyDefaultArgs())
assert_equal('one', MyDefaultArgs('one'))
assert_fails('call MyDefaultArgs("one", "two")', 'E118:')
assert_equal('test', MyDefaultSecond('test'))
assert_equal('test', MyDefaultSecond('test', true))
assert_equal('none', MyDefaultSecond('test', false))
CheckScriptFailure(['def Func(arg: number = asdf)', 'enddef', 'defcompile'], 'E1001:')
CheckScriptFailure(['def Func(arg: number = "text")', 'enddef', 'defcompile'], 'E1013: argument 1: type mismatch, expected number but got string')
enddef
@@ -1047,5 +1055,23 @@ def Test_closure_in_map()
delete('XclosureDir', 'rf')
enddef
def Test_partial_call()
let Xsetlist = function('setloclist', [0])
Xsetlist([], ' ', {'title': 'test'})
assert_equal({'title': 'test'}, getloclist(0, {'title': 1}))
Xsetlist = function('setloclist', [0, [], ' '])
Xsetlist({'title': 'test'})
assert_equal({'title': 'test'}, getloclist(0, {'title': 1}))
Xsetlist = function('setqflist')
Xsetlist([], ' ', {'title': 'test'})
assert_equal({'title': 'test'}, getqflist({'title': 1}))
Xsetlist = function('setqflist', [[], ' '])
Xsetlist({'title': 'test'})
assert_equal({'title': 'test'}, getqflist({'title': 1}))
enddef
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker

View File

@@ -754,6 +754,18 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1224,
/**/
1223,
/**/
1222,
/**/
1221,
/**/
1220,
/**/
1219,
/**/
1218,
/**/

View File

@@ -6865,7 +6865,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
val_type = ((type_T **)stack->ga_data)[stack->ga_len - 1];
if (ufunc->uf_arg_types[arg_idx] == &t_unknown)
ufunc->uf_arg_types[arg_idx] = val_type;
else if (check_type(ufunc->uf_arg_types[i], val_type, FALSE)
else if (check_type(ufunc->uf_arg_types[arg_idx], val_type, FALSE)
== FAIL)
{
arg_type_mismatch(ufunc->uf_arg_types[arg_idx], val_type,

View File

@@ -575,14 +575,32 @@ call_by_name(char_u *name, int argcount, ectx_T *ectx, isn_T *iptr)
}
static int
call_partial(typval_T *tv, int argcount, ectx_T *ectx)
call_partial(typval_T *tv, int argcount_arg, ectx_T *ectx)
{
int argcount = argcount_arg;
char_u *name = NULL;
int called_emsg_before = called_emsg;
if (tv->v_type == VAR_PARTIAL)
{
partial_T *pt = tv->vval.v_partial;
partial_T *pt = tv->vval.v_partial;
int i;
if (pt->pt_argc > 0)
{
// Make space for arguments from the partial, shift the "argcount"
// arguments up.
if (ga_grow(&ectx->ec_stack, pt->pt_argc) == FAIL)
return FAIL;
for (i = 1; i <= argcount; ++i)
*STACK_TV_BOT(-i + pt->pt_argc) = *STACK_TV_BOT(-i);
ectx->ec_stack.ga_len += pt->pt_argc;
argcount += pt->pt_argc;
// copy the arguments from the partial onto the stack
for (i = 0; i < pt->pt_argc; ++i)
copy_tv(&pt->pt_argv[i], STACK_TV_BOT(-argcount + i));
}
if (pt->pt_func != NULL)
{