To: vim_dev@googlegroups.com Subject: Patch 8.2.2542 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2542 Problem: Highlight of char beyond line end is not correct. (Chuan Wei Foo) Solution: Fix counting NUL as one cell. Draw one more character if the EOL is part of the match. (closes #7883) Files: src/match.c, src/testdir/test_search.vim, src/testdir/dumps/Test_hlsearch_1.dump, src/testdir/dumps/Test_hlsearch_2.dump *** ../vim-8.2.2541/src/match.c 2020-08-15 16:33:24.497747330 +0200 --- src/match.c 2021-02-22 21:54:05.036185632 +0100 *************** *** 792,798 **** // highlight empty match, try again after // it if (has_mbyte) ! shl->endcol += (*mb_ptr2len)(*line + shl->endcol); else ++shl->endcol; } --- 792,806 ---- // highlight empty match, try again after // it if (has_mbyte) ! { ! char_u *p = *line + shl->endcol; ! ! if (*p == NUL) ! // consistent with non-mbyte ! ++shl->endcol; ! else ! shl->endcol += (*mb_ptr2len)(p); ! } else ++shl->endcol; } *************** *** 842,859 **** int prevcol_hl_flag = FALSE; matchitem_T *cur; // points to the match list // we're not really at that column when skipping some text if ((long)(wp->w_p_wrap ? wp->w_skipcol : wp->w_leftcol) > prevcol) ++prevcol; ! if (!search_hl->is_addpos && prevcol == (long)search_hl->startcol) prevcol_hl_flag = TRUE; else { cur = wp->w_match_head; while (cur != NULL) { ! if (!cur->hl.is_addpos && prevcol == (long)cur->hl.startcol) { prevcol_hl_flag = TRUE; break; --- 850,880 ---- int prevcol_hl_flag = FALSE; matchitem_T *cur; // points to the match list + #if defined(FEAT_PROP_POPUP) + // don't do this in a popup window + if (popup_is_popup(wp)) + return FALSE; + #endif + // we're not really at that column when skipping some text if ((long)(wp->w_p_wrap ? wp->w_skipcol : wp->w_leftcol) > prevcol) ++prevcol; ! // Highlight a character after the end of the line if the match started ! // at the end of the line or when the match continues in the next line ! // (match includes the line break). ! if (!search_hl->is_addpos && (prevcol == (long)search_hl->startcol ! || (prevcol > (long)search_hl->startcol ! && search_hl->endcol == MAXCOL))) prevcol_hl_flag = TRUE; else { cur = wp->w_match_head; while (cur != NULL) { ! if (!cur->hl.is_addpos && (prevcol == (long)cur->hl.startcol ! || (prevcol > (long)cur->hl.startcol ! && cur->hl.endcol == MAXCOL))) { prevcol_hl_flag = TRUE; break; *** ../vim-8.2.2541/src/testdir/test_search.vim 2021-01-04 12:41:49.511891327 +0100 --- src/testdir/test_search.vim 2021-02-22 21:52:14.904619430 +0100 *************** *** 944,949 **** --- 944,969 ---- call delete('Xis_search_script') endfunc + func Test_hlsearch_dump() + CheckOption hlsearch + CheckScreendump + + call writefile([ + \ 'set hlsearch cursorline', + \ 'call setline(1, ["xxx", "xxx", "xxx"])', + \ '/.*', + \ '2', + \ ], 'Xhlsearch_script') + let buf = RunVimInTerminal('-S Xhlsearch_script', {'rows': 6, 'cols': 50}) + call VerifyScreenDump(buf, 'Test_hlsearch_1', {}) + + call term_sendkeys(buf, "/\\_.*\") + call VerifyScreenDump(buf, 'Test_hlsearch_2', {}) + + call StopVimInTerminal(buf) + call delete('Xhlsearch_script') + endfunc + func Test_incsearch_substitute() CheckOption incsearch *** ../vim-8.2.2541/src/testdir/dumps/Test_hlsearch_1.dump 2021-02-22 22:05:43.797413161 +0100 --- src/testdir/dumps/Test_hlsearch_1.dump 2021-02-22 21:51:30.360794447 +0100 *************** *** 0 **** --- 1,6 ---- + |x+0&#ffff4012@2| | +0&#ffffff0@45 + >x+8&#ffff4012@2| | +8&#ffffff0@45 + |x+0&#ffff4012@2| | +0&#ffffff0@45 + |~+0#4040ff13&| @48 + |~| @48 + | +0#0000000&@31|2|,|1| @10|A|l@1| *** ../vim-8.2.2541/src/testdir/dumps/Test_hlsearch_2.dump 2021-02-22 22:05:43.801413145 +0100 --- src/testdir/dumps/Test_hlsearch_2.dump 2021-02-22 21:52:34.652541759 +0100 *************** *** 0 **** --- 1,6 ---- + |x+0&#ffff4012@2| | +0&#ffffff0@45 + |x+0&#ffff4012@2| | +0&#ffffff0@45 + >x+8&#ffff4012@2| | +8&#ffffff0@45 + |~+0#4040ff13&| @48 + |~| @48 + |/+0#0000000&|\|_|.|*| @26|3|,|1| @10|A|l@1| *** ../vim-8.2.2541/src/version.c 2021-02-21 23:12:14.130105982 +0100 --- src/version.c 2021-02-22 22:05:20.437506193 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2542, /**/ -- Compilation process failed successfully. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///