Patch 8.2.5047

8 views
Skip to first unread message

Bram Moolenaar

unread,
May 31, 2022, 8:44:03 AM5/31/22
to vim...@googlegroups.com

Patch 8.2.5047
Problem: CurSearch highlight is often wrong.
Solution: Remember the last highlighted position and redraw when needed.
Files: src/globals.h, src/match.c, src/drawscreen.c, src/change.c,
src/testdir/test_search.vim,
src/testdir/dumps/Test_hlsearch_cursearch_changed_1.dump


*** ../vim-8.2.5046/src/globals.h 2022-05-27 17:26:50.542119974 +0100
--- src/globals.h 2022-05-31 13:01:22.683998362 +0100
***************
*** 75,81 ****
EXTERN int screen_cur_col INIT(= 0);

#ifdef FEAT_SEARCH_EXTRA
! EXTERN match_T screen_search_hl; // used for 'hlsearch' highlight matching
#endif

#ifdef FEAT_FOLDING
--- 75,88 ----
EXTERN int screen_cur_col INIT(= 0);

#ifdef FEAT_SEARCH_EXTRA
! // used for 'hlsearch' highlight matching
! EXTERN match_T screen_search_hl;
!
! // last lnum where CurSearch was displayed
! EXTERN linenr_T search_hl_has_cursor_lnum INIT(= 0);
!
! // don't use 'hlsearch' temporarily
! EXTERN int no_hlsearch INIT(= FALSE);
#endif

#ifdef FEAT_FOLDING
***************
*** 1418,1428 ****
EXTERN int stl_syntax INIT(= 0);
#endif

- #ifdef FEAT_SEARCH_EXTRA
- // don't use 'hlsearch' temporarily
- EXTERN int no_hlsearch INIT(= FALSE);
- #endif
-
#if defined(FEAT_BEVAL) && !defined(NO_X11_INCLUDES)
EXTERN BalloonEval *balloonEval INIT(= NULL);
EXTERN int balloonEvalForTerm INIT(= FALSE);
--- 1425,1430 ----
*** ../vim-8.2.5046/src/match.c 2022-04-23 12:05:47.398319460 +0100
--- src/match.c 2022-05-31 13:41:43.658892701 +0100
***************
*** 798,804 ****
--- 798,808 ----
// Highlight the match were the cursor is using the CurSearch
// group.
if (shl == search_hl && shl->has_cursor)
+ {
shl->attr_cur = HL_ATTR(HLF_LC);
+ if (shl->attr_cur != shl->attr)
+ search_hl_has_cursor_lnum = lnum;
+ }

}
else if (col == shl->endcol)
*** ../vim-8.2.5046/src/drawscreen.c 2022-05-07 20:01:10.050731702 +0100
--- src/drawscreen.c 2022-05-31 13:16:31.229768681 +0100
***************
*** 1618,1623 ****
--- 1618,1636 ----
}
#endif
}
+
+ #ifdef FEAT_SEARCH_EXTRA
+ if (search_hl_has_cursor_lnum > 0)
+ {
+ // CurSearch was used last time, need to redraw the line with it to
+ // avoid having two matches highlighted with CurSearch.
+ if (mod_top == 0 || mod_top > search_hl_has_cursor_lnum)
+ mod_top = search_hl_has_cursor_lnum;
+ if (mod_bot == 0 || mod_bot < search_hl_has_cursor_lnum + 1)
+ mod_bot = search_hl_has_cursor_lnum + 1;
+ }
+ #endif
+
#ifdef FEAT_FOLDING
if (mod_top != 0 && hasAnyFolding(wp))
{
***************
*** 1684,1689 ****
--- 1697,1706 ----
}
wp->w_redraw_top = 0; // reset for next time
wp->w_redraw_bot = 0;
+ #ifdef FEAT_SEARCH_EXTRA
+ search_hl_has_cursor_lnum = 0;
+ #endif
+

// When only displaying the lines at the top, set top_end. Used when
// window has scrolled down for msg_scrolled.
*** ../vim-8.2.5046/src/change.c 2022-05-27 17:26:50.538119977 +0100
--- src/change.c 2022-05-31 13:31:50.719805667 +0100
***************
*** 663,668 ****
--- 663,672 ----
}
#endif
}
+ #ifdef FEAT_SEARCH_EXTRA
+ if (wp == curwin && xtra != 0 && search_hl_has_cursor_lnum >= lnum)
+ search_hl_has_cursor_lnum += xtra;
+ #endif
}

// Call update_screen() later, which checks out what needs to be redrawn,
*** ../vim-8.2.5046/src/testdir/test_search.vim 2022-04-22 20:06:55.852991660 +0100
--- src/testdir/test_search.vim 2022-05-31 12:57:34.908193630 +0100
***************
*** 1079,1084 ****
--- 1079,1089 ----
call term_sendkeys(buf, "h\<C-L>")
call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_multiple_line_5', {})

+ " check clearing CurSearch when using it for another match
+ call term_sendkeys(buf, "G?^abcd\<CR>Y")
+ call term_sendkeys(buf, "kkP")
+ call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_changed_1', {})
+
call StopVimInTerminal(buf)
call delete('Xhlsearch_cursearch')
endfunc
*** ../vim-8.2.5046/src/testdir/dumps/Test_hlsearch_cursearch_changed_1.dump 2022-05-31 13:41:11.890939324 +0100
--- src/testdir/dumps/Test_hlsearch_cursearch_changed_1.dump 2022-05-31 13:33:26.031650689 +0100
***************
*** 0 ****
--- 1,9 ----
+ |-+0&#ffffff0@2| @56
+ |a+0&#ffff4012|b|c|d|e+0&#ffffff0|f|g| @52
+ >a+0&#4040ff13|b|c|d|e+0&#ffffff0|f|g| @52
+ |h|i|j|k|l| @54
+ |-@2| @56
+ |a+0&#ffff4012|b|c|d|e+0&#ffffff0|f|g| @52
+ |h|i|j|k|l| @54
+ |~+0#4040ff13&| @58
+ | +0#0000000&@41|3|,|1| @10|A|l@1|
*** ../vim-8.2.5046/src/version.c 2022-05-30 20:58:48.914049575 +0100
--- src/version.c 2022-05-31 13:34:16.715569948 +0100
***************
*** 736,737 ****
--- 736,739 ----
{ /* Add new patch number below this line */
+ /**/
+ 5047,
/**/

--
CUSTOMER: You're not fooling anyone y'know. Look, isn't there something
you can do?
DEAD PERSON: I feel happy... I feel happy.
[whop]
CUSTOMER: Ah, thanks very much.
MORTICIAN: Not at all. See you on Thursday.
CUSTOMER: Right.
The Quest for the Holy Grail (Monty Python)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages