Compare commits

...

4 Commits

Author SHA1 Message Date
b073da8929 patch 8.1.1677: tests get stuck when running into an existing swapfile
Problem:    Tests get stuck when running into an existing swapfile.
Solution:   Set v:swapchoice to "q" and report an error. (Daniel Hahler,
            closes #4644)
2019-07-13 14:47:26 +02:00
017c269938 patch 8.1.1676: "maxwidth" of popup window does not always work properly
Problem:    "maxwidth" of popup window does not always work properly.
Solution:   Adjust the computation. (Naruhiko Nishino, closes #4653)
2019-07-13 14:17:51 +02:00
7b73f914c4 patch 8.1.1675: listener list not correctly updated on listener_remove()
Problem:    Listener list not correctly updated on listener_remove().
Solution:   Only set "prev" when not removing a listener.  Return one if the
            listener was found and removed.
2019-07-13 13:03:02 +02:00
4e63f9425e patch 8.1.1674: script to check a colorscheme can be improved
Problem:    Script to check a colorscheme can be improved.
Solution:   Match the whole group name. Don't warn for what is usually omitted.
2019-07-12 22:46:47 +02:00
7 changed files with 108 additions and 26 deletions

View File

@ -8,7 +8,7 @@ set cpo&vim
func! Test_check_colors()
let l:savedview = winsaveview()
call cursor(1,1)
let err={}
let err = {}
" 1) Check g:colors_name is existing
if !search('\<\%(g:\)\?colors_name\>', 'cnW')
@ -81,36 +81,39 @@ func! Test_check_colors()
\ 'WarningMsg',
\ 'WildMenu',
\ ]
let groups={}
let groups = {}
for group in hi_groups
if search('\c@suppress\s\+'.group, 'cnW')
if search('\c@suppress\s\+\<' .. group .. '\>', 'cnW')
" skip check, if the script contains a line like
" @suppress Visual:
let groups[group] = 'Ignoring '.group
continue
endif
if search('hi\%[ghlight]!\= \+link \+'.group, 'cnW') " Linked group
if search('hi\%[ghlight]!\= \+link \+' .. group, 'cnW') " Linked group
continue
endif
if !search('hi\%[ghlight] \+'.group, 'cnW')
let groups[group] = 'No highlight definition for '.group
if !search('hi\%[ghlight] \+\<' .. group .. '\>', 'cnW')
let groups[group] = 'No highlight definition for ' .. group
continue
endif
if !search('hi\%[ghlight] \+'.group. '.*fg=', 'cnW')
let groups[group] = 'Missing foreground color for '.group
if !search('hi\%[ghlight] \+\<' .. group .. '\>.*[bf]g=', 'cnW')
let groups[group] = 'Missing foreground or background color for ' .. group
continue
endif
if search('hi\%[ghlight] \+'.group. '.*guibg=', 'cnW') &&
\ !search('hi\%[ghlight] \+'.group. '.*ctermbg=', 'cnW')
let groups[group] = 'Missing bg terminal color for '.group
if search('hi\%[ghlight] \+\<' .. group .. '\>.*guibg=', 'cnW') &&
\ !search('hi\%[ghlight] \+\<' .. group .. '\>.*ctermbg=', 'cnW')
\ && group != 'Cursor'
let groups[group] = 'Missing bg terminal color for ' .. group
continue
endif
if !search('hi\%[ghlight] \+'.group. '.*guifg=', 'cnW')
let groups[group] = 'Missing guifg definition for '.group
if !search('hi\%[ghlight] \+\<' .. group .. '\>.*guifg=', 'cnW')
\ && group !~ '^Diff'
let groups[group] = 'Missing guifg definition for ' .. group
continue
endif
if !search('hi\%[ghlight] \+'.group. '.*ctermfg=', 'cnW')
let groups[group] = 'Missing ctermfg definition for '.group
if !search('hi\%[ghlight] \+\<' .. group .. '\>.*ctermfg=', 'cnW')
\ && group !~ '^Diff'
\ && group != 'Cursor'
let groups[group] = 'Missing ctermfg definition for ' .. group
continue
endif
" do not check for background colors, they could be intentionally left out
@ -120,10 +123,10 @@ func! Test_check_colors()
" 3) Check, that it does not set background highlighting
" Doesn't ':hi Normal ctermfg=253 ctermfg=233' also set the background sometimes?
let bg_set='\(set\?\|setl\(ocal\)\?\) .*\(background\|bg\)=\(dark\|light\)'
let bg_let='let \%([&]\%([lg]:\)\?\)\%(background\|bg\)\s*=\s*\([''"]\?\)\w\+\1'
let bg_pat='\%('.bg_set. '\|'.bg_let.'\)'
let line=search(bg_pat, 'cnW')
let bg_set = '\(set\?\|setl\(ocal\)\?\) .*\(background\|bg\)=\(dark\|light\)'
let bg_let = 'let \%([&]\%([lg]:\)\?\)\%(background\|bg\)\s*=\s*\([''"]\?\)\w\+\1'
let bg_pat = '\%(' .. bg_set .. '\|' .. bg_let .. '\)'
let line = search(bg_pat, 'cnW')
if search(bg_pat, 'cnW')
exe line
if search('hi \U\w\+\s\+\S', 'cbnW')
@ -145,7 +148,7 @@ func! Test_check_colors()
" if exists("syntax_on")
" syntax reset
" endif
let pat='hi\%[ghlight]\s*clear\n\s*if\s*exists(\([''"]\)syntax_on\1)\n\s*syn\%[tax]\s*reset\n\s*endif'
let pat = 'hi\%[ghlight]\s*clear\n\s*if\s*exists(\([''"]\)syntax_on\1)\n\s*syn\%[tax]\s*reset\n\s*endif'
if !search(pat, 'cnW')
let err['init'] = 'No initialization'
endif
@ -160,7 +163,7 @@ func! Test_check_colors()
let ft_groups = []
" let group = '\%('.join(hi_groups, '\|').'\)' " More efficient than a for loop, but less informative
for group in hi_groups
let pat='\Chi\%[ghlight]!\= *\%[link] \+\zs'.group.'\w\+\>\ze \+.' " Skips `hi clear`
let pat = '\Chi\%[ghlight]!\= *\%[link] \+\zs' .. group .. '\w\+\>\ze \+.' " Skips `hi clear`
if search(pat, 'cW')
call add(ft_groups, matchstr(getline('.'), pat))
endif
@ -172,7 +175,7 @@ func! Test_check_colors()
" 8) Were debugPC and debugBreakpoint defined?
for group in ['debugPC', 'debugBreakpoint']
let pat='\Chi\%[ghlight]!\= *\%[link] \+\zs'.group.'\>'
let pat = '\Chi\%[ghlight]!\= *\%[link] \+\zs' .. group .. '\>'
if search(pat, 'cnW')
let line = search(pat, 'cW')
let err['filetype'] = get(err, 'filetype', 'Should not define: ') . matchstr(getline('.'), pat). ' '

View File

@ -325,15 +325,17 @@ f_listener_flush(typval_T *argvars, typval_T *rettv UNUSED)
* listener_remove() function
*/
void
f_listener_remove(typval_T *argvars, typval_T *rettv UNUSED)
f_listener_remove(typval_T *argvars, typval_T *rettv)
{
listener_T *lnr;
listener_T *next;
listener_T *prev = NULL;
listener_T *prev;
int id = tv_get_number(argvars);
buf_T *buf;
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
{
prev = NULL;
for (lnr = buf->b_listener; lnr != NULL; lnr = next)
{
next = lnr->lr_next;
@ -345,9 +347,12 @@ f_listener_remove(typval_T *argvars, typval_T *rettv UNUSED)
buf->b_listener = lnr->lr_next;
free_callback(&lnr->lr_callback);
vim_free(lnr);
rettv->vval.v_number = 1;
return;
}
prev = lnr;
}
}
}
/*

View File

@ -799,6 +799,8 @@ popup_height(win_T *wp)
int
popup_width(win_T *wp)
{
// w_leftcol is how many columns of the core are left of the screen
// w_popup_rightoff is how many columns of the core are right of the screen
return wp->w_width + wp->w_leftcol
+ wp->w_popup_padding[3] + wp->w_popup_border[3]
+ wp->w_popup_padding[1] + wp->w_popup_border[1]
@ -924,7 +926,11 @@ popup_adjust_position(win_T *wp)
wp->w_width = maxwidth;
}
if (wp->w_width < len)
{
wp->w_width = len;
if (wp->w_maxwidth > 0 && wp->w_width > wp->w_maxwidth)
wp->w_width = wp->w_maxwidth;
}
// do not use the width of lines we're not going to show
if (wp->w_maxheight > 0
&& lnum - wp->w_topline + 1 + wrapped > wp->w_maxheight)

View File

@ -0,0 +1,13 @@
>╔+0#0000001#ffd7ff255|═@2|╗| +0#0000000#ffffff0@9|╔+0#0000001#ffd7ff255|═@11|╗| +0#0000000#ffffff0@2|╔+0#0000001#ffd7ff255|═@12|╗| +0#0000000#ffffff0@27
|║+0#0000001#ffd7ff255| @2|║| +0#0000000#ffffff0@9|║+0#0000001#ffd7ff255| @11|║| +0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @12|║| +0#0000000#ffffff0@27
|║+0#0000001#ffd7ff255| |x+0&#e0e0e08| +0&#ffd7ff255|║| +0#0000000#ffffff0@9|║+0#0000001#ffd7ff255| |1+0&#e0e0e08|2|3|4|5|6|7|8|9||| +0&#ffd7ff255|║| +0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |1+0&#e0e0e08|2|3|4|5|6|7|8|9||| +0&#ffd7ff255| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@27
|║+0#0000001#ffd7ff255| @2|║| +0#0000000#ffffff0@9|║+0#0000001#ffd7ff255| @11|║| +0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |1|2|3|4|5|6|7|8|9||| | +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@27
|╚+0#0000001#ffd7ff255|═@2|╝| +0#0000000#ffffff0@9|╚+0#0000001#ffd7ff255|═@11|╝| +0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |1|2|3|4|5|6|7|8|9||| | +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@27
|6| @30|║+0#0000001#ffd7ff255| @12|║| +0#0000000#ffffff0@27
|╔+0#0000001#ffd7ff255|═@11|╗| +0#0000000#ffffff0|╔+0#0000001#ffd7ff255|═@11|╗| +0#0000000#ffffff0@2|╚+0#0000001#ffd7ff255|═@12|╝| +0#0000000#ffffff0@27
|║+0#0000001#ffd7ff255| @11|║| +0#0000000#ffffff0|║+0#0000001#ffd7ff255| @11|║| +0#0000000#ffffff0@45
|║+0#0000001#ffd7ff255| |1+0&#e0e0e08|2|3|4|5|6|7|8|9||| +0&#ffd7ff255|║| +0#0000000#ffffff0|║+0#0000001#ffd7ff255| |1+0&#e0e0e08|2|3|4|5|6|7|8|9||| +0&#ffd7ff255|║| +0#0000000#ffffff0@45
|║+0#0000001#ffd7ff255| @11|║| +0#0000000#ffffff0|║+0#0000001#ffd7ff255| @11|║| +0#0000000#ffffff0@45
|╚+0#0000001#ffd7ff255|═@11|╝| +0#4040ff13#ffffff0|╚+0#0000001#ffd7ff255|═@11|╝| +0#4040ff13#ffffff0@45
|~| @73
| +0#0000000&@56|1|,|1| @10|A|l@1|

View File

@ -68,10 +68,14 @@ set encoding=utf-8
let s:test_script_fname = expand('%')
au! SwapExists * call HandleSwapExists()
func HandleSwapExists()
" Only ignore finding a swap file for the test script (the user might be
" 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.
if expand('<afile>') == 'messages' || expand('<afile>') =~ s:test_script_fname
let v:swapchoice = 'e'
else
call assert_report('Unexpected swap file: ' .. v:swapname)
let v:swapchoice = 'q'
endif
endfunc

View File

@ -1819,3 +1819,46 @@ func Test_popupwin_buf_close()
call assert_equal([], bufinfo.popups)
exe 'bwipe! ' .. buf
endfunc
func Test_popup_menu_with_maxwidth()
if !CanRunVimInTerminal()
throw 'Skipped: cannot make screendumps'
endif
let lines =<< trim END
call setline(1, range(1, 10))
hi ScrollThumb ctermbg=blue
hi ScrollBar ctermbg=red
func PopupMenu(lines, line, col, scrollbar = 0)
return popup_menu(a:lines, {
\ 'maxwidth': 10,
\ 'maxheight': 3,
\ 'pos' : 'topleft',
\ 'col' : a:col,
\ 'line' : a:line,
\ 'scrollbar' : a:scrollbar,
\ })
endfunc
call PopupMenu(['x'], 1, 1)
call PopupMenu(['123456789|'], 1, 16)
call PopupMenu(['123456789|' .. ' '], 7, 1)
call PopupMenu([repeat('123456789|', 100)], 7, 16)
call PopupMenu(repeat(['123456789|' .. ' '], 5), 1, 33, 1)
END
call writefile(lines, 'XtestPopupMenuMaxWidth')
let buf = RunVimInTerminal('-S XtestPopupMenuMaxWidth', {'rows': 13})
call VerifyScreenDump(buf, 'Test_popupwin_menu_maxwidth_1', {})
" close the menu popupwin.
call term_sendkeys(buf, " ")
call term_sendkeys(buf, " ")
call term_sendkeys(buf, " ")
call term_sendkeys(buf, " ")
call term_sendkeys(buf, " ")
" clean up
call StopVimInTerminal(buf)
call delete('XtestPopupMenuMaxWidth')
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@ -777,6 +777,14 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1677,
/**/
1676,
/**/
1675,
/**/
1674,
/**/
1673,
/**/