mirror of
				https://github.com/vim/vim.git
				synced 2025-10-30 09:47:20 -04:00 
			
		
		
		
	patch 8.2.4759: CurSearch highlight does not work for multi-line match
Problem: CurSearch highlight does not work for multi-line match. Solution: Check cursor position before adjusting columns. (closes #10133)
This commit is contained in:
		
							
								
								
									
										21
									
								
								src/match.c
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								src/match.c
									
									
									
									
									
								
							| @@ -396,6 +396,7 @@ next_search_hl_pos( | ||||
| 	shl->rm.endpos[0].lnum = 0; | ||||
| 	shl->rm.endpos[0].col = end; | ||||
| 	shl->is_addpos = TRUE; | ||||
| 	shl->has_cursor = FALSE; | ||||
| 	posmatch->cur = found + 1; | ||||
| 	return 1; | ||||
|     } | ||||
| @@ -655,6 +656,7 @@ prepare_search_hl_line( | ||||
| 	shl->lines = 0; | ||||
| 	shl->attr_cur = 0; | ||||
| 	shl->is_addpos = FALSE; | ||||
| 	shl->has_cursor = FALSE; | ||||
| 	if (cur != NULL) | ||||
| 	    cur->pos.cur = 0; | ||||
| 	next_search_hl(wp, search_hl, shl, lnum, mincol, | ||||
| @@ -679,6 +681,17 @@ prepare_search_hl_line( | ||||
| 		shl->lines = shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum; | ||||
| 	    else | ||||
| 		shl->lines = 1; | ||||
|  | ||||
| 	    // check if the cursor is in the match before changing the columns | ||||
| 	    if (wp->w_cursor.lnum >= shl->lnum | ||||
| 			&& wp->w_cursor.lnum | ||||
| 					  <= shl->lnum + shl->rm.endpos[0].lnum | ||||
| 			&& (wp->w_cursor.lnum > shl->lnum | ||||
| 				|| wp->w_cursor.col >= shl->rm.startpos[0].col) | ||||
| 			&& (wp->w_cursor.lnum < shl->lnum + shl->lines | ||||
| 				  || wp->w_cursor.col < shl->rm.endpos[0].col)) | ||||
| 		shl->has_cursor = TRUE; | ||||
|  | ||||
| 	    // Highlight one character for an empty match. | ||||
| 	    if (shl->startcol == shl->endcol) | ||||
| 	    { | ||||
| @@ -775,14 +788,8 @@ update_search_hl( | ||||
| # endif | ||||
| 		// Highlight the match were the cursor is using the CurSearch | ||||
| 		// group. | ||||
| 		if (shl == search_hl | ||||
| 			&& wp->w_cursor.lnum >= shl->lnum | ||||
| 			&& wp->w_cursor.lnum < shl->lnum + shl->lines | ||||
| 			&& wp->w_cursor.col >= shl->startcol | ||||
| 			&& wp->w_cursor.col < shl->endcol) | ||||
| 		{ | ||||
| 		if (shl == search_hl && shl->has_cursor) | ||||
| 		    shl->attr_cur = HL_ATTR(HLF_LC); | ||||
| 		} | ||||
|  | ||||
| 	    } | ||||
| 	    else if (col == shl->endcol) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user