@@ -792,7 +792,15 @@ update_search_hl(
792792 // highlight empty match, try again after
793793 // it
794794 if (has_mbyte )
795- shl -> endcol += (* mb_ptr2len )(* line + shl -> endcol );
795+ {
796+ char_u * p = * line + shl -> endcol ;
797+
798+ if (* p == NUL )
799+ // consistent with non-mbyte
800+ ++ shl -> endcol ;
801+ else
802+ shl -> endcol += (* mb_ptr2len )(p );
803+ }
796804 else
797805 ++ shl -> endcol ;
798806 }
@@ -842,18 +850,31 @@ get_prevcol_hl_flag(win_T *wp, match_T *search_hl, long curcol)
842850 int prevcol_hl_flag = FALSE;
843851 matchitem_T * cur ; // points to the match list
844852
853+ #if defined(FEAT_PROP_POPUP )
854+ // don't do this in a popup window
855+ if (popup_is_popup (wp ))
856+ return FALSE;
857+ #endif
858+
845859 // we're not really at that column when skipping some text
846860 if ((long )(wp -> w_p_wrap ? wp -> w_skipcol : wp -> w_leftcol ) > prevcol )
847861 ++ prevcol ;
848862
849- if (!search_hl -> is_addpos && prevcol == (long )search_hl -> startcol )
863+ // Highlight a character after the end of the line if the match started
864+ // at the end of the line or when the match continues in the next line
865+ // (match includes the line break).
866+ if (!search_hl -> is_addpos && (prevcol == (long )search_hl -> startcol
867+ || (prevcol > (long )search_hl -> startcol
868+ && search_hl -> endcol == MAXCOL )))
850869 prevcol_hl_flag = TRUE;
851870 else
852871 {
853872 cur = wp -> w_match_head ;
854873 while (cur != NULL )
855874 {
856- if (!cur -> hl .is_addpos && prevcol == (long )cur -> hl .startcol )
875+ if (!cur -> hl .is_addpos && (prevcol == (long )cur -> hl .startcol
876+ || (prevcol > (long )cur -> hl .startcol
877+ && cur -> hl .endcol == MAXCOL )))
857878 {
858879 prevcol_hl_flag = TRUE;
859880 break ;
0 commit comments