Skip to content

Commit f914a33

Browse files
committed
patch 8.1.1717: last char in menu popup window highlighted
Problem: Last char in menu popup window highlighted. Solution: Do not highlight an extra character twice.
1 parent ab0a789 commit f914a33

4 files changed

Lines changed: 84 additions & 5 deletions

File tree

src/screen.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3219,10 +3219,10 @@ win_line(
32193219
int syntax_attr = 0; /* attributes desired by syntax */
32203220
int has_syntax = FALSE; /* this buffer has syntax highl. */
32213221
int save_did_emsg;
3222-
int eol_hl_off = 0; /* 1 if highlighted char after EOL */
32233222
int draw_color_col = FALSE; /* highlight colorcolumn */
32243223
int *color_cols = NULL; /* pointer to according columns array */
32253224
#endif
3225+
int eol_hl_off = 0; /* 1 if highlighted char after EOL */
32263226
#ifdef FEAT_TEXT_PROP
32273227
int text_prop_count;
32283228
int text_prop_next = 0; // next text property to use
@@ -5557,11 +5557,11 @@ win_line(
55575557
/*
55585558
* At end of the text line or just after the last character.
55595559
*/
5560-
if (c == NUL
5560+
if ((c == NUL
55615561
#if defined(LINE_ATTR)
55625562
|| did_line_attr == 1
55635563
#endif
5564-
)
5564+
) && eol_hl_off == 0)
55655565
{
55665566
#ifdef FEAT_SEARCH_EXTRA
55675567
long prevcol = (long)(ptr - line) - (c == NUL);
@@ -5687,9 +5687,7 @@ win_line(
56875687
++off;
56885688
}
56895689
++vcol;
5690-
#ifdef FEAT_SYN_HL
56915690
eol_hl_off = 1;
5692-
#endif
56935691
}
56945692
}
56955693

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
>1+0&#ffffff0| @73
2+
|2| @73
3+
|3| @31|╔+0#0000001#ffd7ff255|═@6|╗| +0#0000000#ffffff0@32
4+
|4| @31|║+0#0000001#ffd7ff255| |o+0#0000000#40ff4011|n|e| +0#0000001#ffd7ff255@2|║| +0#0000000#ffffff0@32
5+
|5| @31|║+0#0000001#ffd7ff255| |t|w|o| @2|║| +0#0000000#ffffff0@32
6+
|6| @31|║+0#0000001#ffd7ff255| |t|h|r|e@1| |║| +0#0000000#ffffff0@32
7+
|7| @31|╚+0#0000001#ffd7ff255|═@6|╝| +0#0000000#ffffff0@32
8+
|8| @73
9+
|9| @73
10+
@57|1|,|1| @10|T|o|p|

src/testdir/test_popupwin.vim

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,29 @@ func Test_popup_menu_screenshot()
12151215
call delete('XtestPopupMenu')
12161216
endfunc
12171217

1218+
func Test_popup_menu_narrow()
1219+
if !CanRunVimInTerminal()
1220+
throw 'Skipped: cannot make screendumps'
1221+
endif
1222+
1223+
let lines =<< trim END
1224+
call setline(1, range(1, 20))
1225+
hi PopupSelected ctermbg=green
1226+
call popup_menu(['one', 'two', 'three'], #{callback: 'MenuDone'})
1227+
func MenuDone(id, res)
1228+
echomsg "selected " .. a:res
1229+
endfunc
1230+
END
1231+
call writefile(lines, 'XtestPopupNarrowMenu')
1232+
let buf = RunVimInTerminal('-S XtestPopupNarrowMenu', #{rows: 10})
1233+
call VerifyScreenDump(buf, 'Test_popupwin_menu_04', {})
1234+
1235+
" clean up
1236+
call term_sendkeys(buf, "x")
1237+
call StopVimInTerminal(buf)
1238+
call delete('XtestPopupNarrowMenu')
1239+
endfunc
1240+
12181241
func Test_popup_title()
12191242
if !CanRunVimInTerminal()
12201243
throw 'Skipped: cannot make screendumps'
@@ -2093,4 +2116,50 @@ func Test_popup_cursorline()
20932116
call delete('XtestPopupCursorLine')
20942117
endfunc
20952118

2119+
func Test_previewpopup()
2120+
if !CanRunVimInTerminal()
2121+
throw 'Skipped: cannot make screendumps'
2122+
endif
2123+
call writefile([
2124+
\ "!_TAG_FILE_ENCODING\tutf-8\t//",
2125+
\ "another\tXtagfile\t/^this is another",
2126+
\ "theword\tXtagfile\t/^theword"],
2127+
\ 'Xtags')
2128+
call writefile(range(1,20)
2129+
\ + ['theword is here']
2130+
\ + range(22, 27)
2131+
\ + ['this is another place']
2132+
\ + range(29, 40),
2133+
\ "Xtagfile")
2134+
let lines =<< trim END
2135+
set tags=Xtags
2136+
call setline(1, [
2137+
\ 'one',
2138+
\ 'two',
2139+
\ 'three',
2140+
\ 'four',
2141+
\ 'five',
2142+
\ 'six',
2143+
\ 'seven',
2144+
\ 'find theword somewhere',
2145+
\ 'nine',
2146+
\ 'this is another word'])
2147+
set previewpopup=height:4,width:40
2148+
END
2149+
call writefile(lines, 'XtestPreviewPopup')
2150+
let buf = RunVimInTerminal('-S XtestPreviewPopup', #{rows: 14})
2151+
2152+
call term_sendkeys(buf, "/theword\<CR>\<C-W>}")
2153+
call term_sendkeys(buf, ":\<CR>")
2154+
call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_1', {})
2155+
2156+
call term_sendkeys(buf, "/another\<CR>\<C-W>}")
2157+
call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_2', {})
2158+
2159+
call StopVimInTerminal(buf)
2160+
call delete('Xtags')
2161+
call delete('Xtagfile')
2162+
call delete('XtestPreviewPopup')
2163+
endfunc
2164+
20962165
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,8 @@ static char *(features[]) =
777777

778778
static int included_patches[] =
779779
{ /* Add new patch number below this line */
780+
/**/
781+
1717,
780782
/**/
781783
1716,
782784
/**/

0 commit comments

Comments
 (0)