]> granicus.if.org Git - vim/commitdiff
patch 8.1.1655: popup window border drawn wrong with multi-byte char v8.1.1655
authorBram Moolenaar <Bram@vim.org>
Mon, 8 Jul 2019 21:30:22 +0000 (23:30 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 8 Jul 2019 21:30:22 +0000 (23:30 +0200)
Problem:    Popup window border drawn wrong with multi-byte char. (Marcin
            Szamotulski)
Solution:   Correct check in mb_fix_col(). (closes #4635)

src/mbyte.c
src/testdir/dumps/Test_popupwin_24.dump [new file with mode: 0644]
src/testdir/test_popupwin.vim
src/version.c

index 94adddf7ef9b27632f643c35bfe0f89ca4e860c1..2b764006628900c4e264392567cf551437bef61c 100644 (file)
@@ -4266,14 +4266,18 @@ mb_lefthalve(int row, int col)
     int
 mb_fix_col(int col, int row)
 {
+    int off;
+
     col = check_col(col);
     row = check_row(row);
+    off = LineOffset[row] + col;
     if (has_mbyte && ScreenLines != NULL && col > 0
            && ((enc_dbcs
-                   && ScreenLines[LineOffset[row] + col] != NUL
+                   && ScreenLines[off] != NUL
                    && dbcs_screen_head_off(ScreenLines + LineOffset[row],
-                                        ScreenLines + LineOffset[row] + col))
-               || (enc_utf8 && ScreenLines[LineOffset[row] + col] == 0)))
+                                        ScreenLines + off))
+               || (enc_utf8 && ScreenLines[off] == 0
+                                                 && ScreenLinesUC[off] == 0)))
        return col - 1;
     return col;
 }
diff --git a/src/testdir/dumps/Test_popupwin_24.dump b/src/testdir/dumps/Test_popupwin_24.dump
new file mode 100644 (file)
index 0000000..f5386c9
--- /dev/null
@@ -0,0 +1,12 @@
+>1+0&#ffffff0| @73
+|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| |║+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| |╚+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| @20|╚+0&#585858255|═@11|╝| +0&#ffffff0@5|x+0&#5fd7ff255@13| +0&#ffffff0@2|#+0&#5fd7ff255|x@11|#| +0&#ffffff0@1
+|6| |e+0&#5fd7ff255|a@11|f| +0&#ffffff0@58
+|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| |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| |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
+|1|0| @19| +0&#5fd7ff255@13| +0&#ffffff0@5|└+0#0000001#ffd7ff255|─@4|┘| +0#0000000#ffffff0@25
+|1@1| @72
+|:|c|a|l@1| |M|u|l|t|i|B|y|t|e|(|)| @39|1|,|1| @10|T|o|p| 
index f952a42fe7bd261e3487ed29b0f9aeed3f59e988..0ec4f7600458eb99242a918ea163c79daeaff1bf 100644 (file)
@@ -113,6 +113,9 @@ func Test_popup_with_border_and_padding()
        call popup_create(['hello border', 'with corners'], {'line': 2, 'col': 60, 'border': [], 'borderhighlight': ['BlueColor'], 'borderchars': ['x', '#']})
        let winid = popup_create(['hello border', 'with numbers'], {'line': 6, 'col': 3, 'border': [], 'borderhighlight': ['BlueColor'], 'borderchars': ['0', '1', '2', '3', '4', '5', '6', '7']})
        call popup_create(['hello border', 'just blanks'], {'line': 7, 'col': 23, 'border': [], 'borderhighlight': ['BlueColor'], 'borderchars': [' ']})
+       func MultiByte()
+         call popup_create(['hello'], {'line': 8, 'col': 43, 'border': [], 'borderchars': ['─', '│', '─', '│', '┌', '┐', '┘', '└']})
+       endfunc
   END
   call writefile(lines, 'XtestPopupBorder')
   let buf = RunVimInTerminal('-S XtestPopupBorder', {'rows': 12})
@@ -122,6 +125,12 @@ func Test_popup_with_border_and_padding()
   call term_sendkeys(buf, ":call popup_setoptions(winid, {'borderchars': ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']})\<CR>")
   call VerifyScreenDump(buf, 'Test_popupwin_23', {})
 
+  " check multi-byte border only with 'ambiwidth' single
+  if &ambiwidth == 'single'
+    call term_sendkeys(buf, ":call MultiByte()\<CR>")
+    call VerifyScreenDump(buf, 'Test_popupwin_24', {})
+  endif
+
   call StopVimInTerminal(buf)
   call delete('XtestPopupBorder')
 
index d35560adc583fdd631524923577e35ba8448d9b8..62b95579dc7ae386360db0568b13d623619a4b82 100644 (file)
@@ -777,6 +777,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1655,
 /**/
     1654,
 /**/