Skip to content

Commit 3dabd71

Browse files
committed
patch 8.1.1655: popup window border drawn wrong with multi-byte char
Problem: Popup window border drawn wrong with multi-byte char. (Marcin Szamotulski) Solution: Correct check in mb_fix_col(). (closes #4635)
1 parent 8a7383b commit 3dabd71

4 files changed

Lines changed: 30 additions & 3 deletions

File tree

src/mbyte.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4266,14 +4266,18 @@ mb_lefthalve(int row, int col)
42664266
int
42674267
mb_fix_col(int col, int row)
42684268
{
4269+
int off;
4270+
42694271
col = check_col(col);
42704272
row = check_row(row);
4273+
off = LineOffset[row] + col;
42714274
if (has_mbyte && ScreenLines != NULL && col > 0
42724275
&& ((enc_dbcs
4273-
&& ScreenLines[LineOffset[row] + col] != NUL
4276+
&& ScreenLines[off] != NUL
42744277
&& dbcs_screen_head_off(ScreenLines + LineOffset[row],
4275-
ScreenLines + LineOffset[row] + col))
4276-
|| (enc_utf8 && ScreenLines[LineOffset[row] + col] == 0)))
4278+
ScreenLines + off))
4279+
|| (enc_utf8 && ScreenLines[off] == 0
4280+
&& ScreenLinesUC[off] == 0)))
42774281
return col - 1;
42784282
return col;
42794283
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
>1+0&#ffffff0| @73
2+
|2| |╔+0&#5fd7ff255|═@11|╗| +0&#ffffff0@5|╔+0&#dadada255|═@11|╗+0&#8a8a8a255| +0&#ffffff0@5|x+0&#5fd7ff255@13| +0&#ffffff0@2|#+0&#5fd7ff255|x@11|#| +0&#ffffff0@1
3+
|3| |║+0&#5fd7ff255|h+0#0000001#ffd7ff255|e|l@1|o| |b|o|r|d|e|r|║+0#0000000#5fd7ff255| +0&#ffffff0@5|║+0&#a8a8a8255|h+0#0000001#ffd7ff255|e|l@1|o| |b|o|r|d|e|r|║+0#0000000#8a8a8a255| +0&#ffffff0@5|x+0&#5fd7ff255|h+0#0000001#ffd7ff255|e|l@1|o| |b|o|r|d|e|r|x+0#0000000#5fd7ff255| +0&#ffffff0@2|x+0&#5fd7ff255|h+0#0000001#ffd7ff255|e|l@1|o| |b|o|r|d|e|r|x+0#0000000#5fd7ff255| +0&#ffffff0@1
4+
|4| |╚+0&#5fd7ff255|═@11|╝| +0&#ffffff0@5|║+0&#a8a8a8255|a+0#0000001#ffd7ff255|n|d| |m|o|r|e| @3|║+0#0000000#8a8a8a255| +0&#ffffff0@5|x+0&#5fd7ff255|l+0#0000001#ffd7ff255|i|n|e|s| |o|n|l|y| @1|x+0#0000000#5fd7ff255| +0&#ffffff0@2|x+0&#5fd7ff255|w+0#0000001#ffd7ff255|i|t|h| |c|o|r|n|e|r|s|x+0#0000000#5fd7ff255| +0&#ffffff0@1
5+
|5| @20|╚+0&#585858255|═@11|╝| +0&#ffffff0@5|x+0&#5fd7ff255@13| +0&#ffffff0@2|#+0&#5fd7ff255|x@11|#| +0&#ffffff0@1
6+
|6| |e+0&#5fd7ff255|a@11|f| +0&#ffffff0@58
7+
|7| |d+0&#5fd7ff255|h+0#0000001#ffd7ff255|e|l@1|o| |b|o|r|d|e|r|b+0#0000000#5fd7ff255| +0&#ffffff0@5| +0&#5fd7ff255@13| +0&#ffffff0@38
8+
|8| |d+0&#5fd7ff255|w+0#0000001#ffd7ff255|i|t|h| |n|u|m|b|e|r|s|b+0#0000000#5fd7ff255| +0&#ffffff0@5| +0&#5fd7ff255|h+0#0000001#ffd7ff255|e|l@1|o| |b|o|r|d|e|r| +0#0000000#5fd7ff255| +0&#ffffff0@5|┌+0#0000001#ffd7ff255|─@4|┐| +0#0000000#ffffff0@25
9+
|9| |h+0&#5fd7ff255|c@11|g| +0&#ffffff0@5| +0&#5fd7ff255|j+0#0000001#ffd7ff255|u|s|t| |b|l|a|n|k|s| | +0#0000000#5fd7ff255| +0&#ffffff0@5|│+0#0000001#ffd7ff255|h|e|l@1|o|│| +0#0000000#ffffff0@25
10+
|1|0| @19| +0&#5fd7ff255@13| +0&#ffffff0@5|└+0#0000001#ffd7ff255|─@4|┘| +0#0000000#ffffff0@25
11+
|1@1| @72
12+
|:|c|a|l@1| |M|u|l|t|i|B|y|t|e|(|)| @39|1|,|1| @10|T|o|p|

src/testdir/test_popupwin.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ func Test_popup_with_border_and_padding()
113113
call popup_create(['hello border', 'with corners'], {'line': 2, 'col': 60, 'border': [], 'borderhighlight': ['BlueColor'], 'borderchars': ['x', '#']})
114114
let winid = popup_create(['hello border', 'with numbers'], {'line': 6, 'col': 3, 'border': [], 'borderhighlight': ['BlueColor'], 'borderchars': ['0', '1', '2', '3', '4', '5', '6', '7']})
115115
call popup_create(['hello border', 'just blanks'], {'line': 7, 'col': 23, 'border': [], 'borderhighlight': ['BlueColor'], 'borderchars': [' ']})
116+
func MultiByte()
117+
call popup_create(['hello'], {'line': 8, 'col': 43, 'border': [], 'borderchars': ['', '', '', '', '', '', '', '']})
118+
endfunc
116119
END
117120
call writefile(lines, 'XtestPopupBorder')
118121
let buf = RunVimInTerminal('-S XtestPopupBorder', {'rows': 12})
@@ -122,6 +125,12 @@ func Test_popup_with_border_and_padding()
122125
call term_sendkeys(buf, ":call popup_setoptions(winid, {'borderchars': ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']})\<CR>")
123126
call VerifyScreenDump(buf, 'Test_popupwin_23', {})
124127

128+
" check multi-byte border only with 'ambiwidth' single
129+
if &ambiwidth == 'single'
130+
call term_sendkeys(buf, ":call MultiByte()\<CR>")
131+
call VerifyScreenDump(buf, 'Test_popupwin_24', {})
132+
endif
133+
125134
call StopVimInTerminal(buf)
126135
call delete('XtestPopupBorder')
127136

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+
1655,
780782
/**/
781783
1654,
782784
/**/

0 commit comments

Comments
 (0)