Compare commits

...

2 Commits

Author SHA1 Message Date
3b675c276c patch 8.2.4964: MS-Windows GUI: mouse event test is flaky
Problem:    MS-Windows GUI: mouse event test is flaky.
Solution:   Add a short delay after generating a mouse event.
2022-05-16 13:34:44 +01:00
386c24cd26 patch 8.2.4963: expanding path with "/**" may overrun end of buffer
Problem:    Expanding path with "/**" may overrun end of buffer.
Solution:   Use vim_snprintf().
2022-05-16 12:37:36 +01:00
3 changed files with 41 additions and 32 deletions

View File

@ -3589,6 +3589,7 @@ unix_expandpath(
int didstar) // expanded "**" once already
{
char_u *buf;
size_t buflen;
char_u *path_end;
char_u *p, *s, *e;
int start_len = gap->ga_len;
@ -3612,7 +3613,8 @@ unix_expandpath(
}
// make room for file name
buf = alloc(STRLEN(path) + BASENAMELEN + 5);
buflen = STRLEN(path) + BASENAMELEN + 5;
buf = alloc(buflen);
if (buf == NULL)
return 0;
@ -3737,14 +3739,14 @@ unix_expandpath(
{
// For "**" in the pattern first go deeper in the tree to
// find matches.
STRCPY(buf + len, "/**");
STRCPY(buf + len + 3, path_end);
vim_snprintf((char *)buf + len, buflen - len,
"/**%s", path_end);
++stardepth;
(void)unix_expandpath(gap, buf, len + 1, flags, TRUE);
--stardepth;
}
STRCPY(buf + len, path_end);
vim_snprintf((char *)buf + len, buflen - len, "%s", path_end);
if (mch_has_exp_wildcard(path_end)) // handle more wildcards
{
// need to expand another component of the path

View File

@ -1198,6 +1198,17 @@ func Test_gui_mouse_event()
set mousemodel&
endfunc
" Move the mouse to the top-left in preparation for mouse events
func PrepareForMouseEvent(args)
call extend(a:args, #{row: 1, col:1})
call test_gui_event('mouse', a:args)
call feedkeys('', 'Lx!')
" on MS-Windows the event may have a slight delay
if has('win32')
sleep 20m
endif
endfunc
func Test_gui_mouse_move_event()
let args = #{move: 1, button: 0, multiclick: 0, modifiers: 0}
@ -1205,67 +1216,59 @@ func Test_gui_mouse_move_event()
set mousemev&
call assert_false(&mousemev)
let n_event = 0
nnoremap <special> <MouseMove> :let n_event += 1<CR>
let g:n_event = 0
nnoremap <special> <MouseMove> :let g:n_event += 1<CR>
" start at mouse pos (1,1), clear counter
call extend(args, #{row: 1, col:1})
call test_gui_event('mouse', args)
call feedkeys('', 'Lx!')
let n_event = 0
call PrepareForMouseEvent(args)
let g:n_event = 0
call extend(args, #{row: 30, col:300})
call extend(args, #{row: 30, col: 300})
call test_gui_event('mouse', args)
call feedkeys('', 'Lx!')
call extend(args, #{row: 100, col:300})
call extend(args, #{row: 100, col: 300})
call test_gui_event('mouse', args)
call feedkeys('', 'Lx!')
" no events since mousemev off
call assert_equal(0, n_event)
call assert_equal(0, g:n_event)
" turn on mouse events and try the same thing
set mousemev
call extend(args, #{row: 1, col:1})
call test_gui_event('mouse', args)
call feedkeys('', 'Lx!')
let n_event = 0
call PrepareForMouseEvent(args)
let g:n_event = 0
call extend(args, #{row: 30, col:300})
call extend(args, #{row: 30, col: 300})
call test_gui_event('mouse', args)
call feedkeys('', 'Lx!')
call extend(args, #{row: 100, col:300})
call extend(args, #{row: 100, col: 300})
call test_gui_event('mouse', args)
call feedkeys('', 'Lx!')
call assert_equal(2, n_event)
call assert_equal(2, g:n_event)
" wiggle the mouse around, shouldn't get events
call extend(args, #{row: 1, col:1})
call test_gui_event('mouse', args)
call feedkeys('', 'Lx!')
let n_event = 0
call PrepareForMouseEvent(args)
let g:n_event = 0
call extend(args, #{row: 1, col:2})
call extend(args, #{row: 1, col: 2})
call test_gui_event('mouse', args)
call feedkeys('', 'Lx!')
call extend(args, #{row: 2, col:2})
call extend(args, #{row: 2, col: 2})
call test_gui_event('mouse', args)
call feedkeys('', 'Lx!')
call extend(args, #{row: 2, col:1})
call extend(args, #{row: 2, col: 1})
call test_gui_event('mouse', args)
call feedkeys('', 'Lx!')
call extend(args, #{row: 1, col:1})
call test_gui_event('mouse', args)
call feedkeys('', 'Lx!')
call assert_equal(0, n_event)
call PrepareForMouseEvent(args)
call assert_equal(0, g:n_event)
unlet g:n_event
unmap <MouseMove>
set mousemev&
endfunc

View File

@ -746,6 +746,10 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4964,
/**/
4963,
/**/
4962,
/**/