comparison src/normal.c @ 28399:d395fadbaf67 v8.2.4724

patch 8.2.4724: current instance of last search pattern not easily spotted Commit: https://github.com/vim/vim/commit/a43993897aa372159f682df37562f159994dc85c Author: LemonBoy <thatlemon@gmail.com> Date: Sat Apr 9 21:04:08 2022 +0100 patch 8.2.4724: current instance of last search pattern not easily spotted Problem: Current instance of last search pattern not easily spotted. Solution: Add CurSearch highlighting. (closes https://github.com/vim/vim/issues/10133)
author Bram Moolenaar <Bram@vim.org>
date Sat, 09 Apr 2022 22:15:03 +0200
parents d1702731786c
children d1982178f787
comparison
equal deleted inserted replaced
28398:8b474e8eff92 28399:d395fadbaf67
4151 (void)normal_search(cap, cap->cmdchar, cap->searchbuf, 4151 (void)normal_search(cap, cap->cmdchar, cap->searchbuf,
4152 (cap->arg || !EQUAL_POS(save_cursor, curwin->w_cursor)) 4152 (cap->arg || !EQUAL_POS(save_cursor, curwin->w_cursor))
4153 ? 0 : SEARCH_MARK, NULL); 4153 ? 0 : SEARCH_MARK, NULL);
4154 } 4154 }
4155 4155
4156
4156 /* 4157 /*
4157 * Handle "N" and "n" commands. 4158 * Handle "N" and "n" commands.
4158 * cap->arg is SEARCH_REV for "N", 0 for "n". 4159 * cap->arg is SEARCH_REV for "N", 0 for "n".
4159 */ 4160 */
4160 static void 4161 static void
4171 // in the buffer: Repeat with count + 1. 4172 // in the buffer: Repeat with count + 1.
4172 cap->count1 += 1; 4173 cap->count1 += 1;
4173 (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, NULL); 4174 (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, NULL);
4174 cap->count1 -= 1; 4175 cap->count1 -= 1;
4175 } 4176 }
4177
4178 #ifdef FEAT_SEARCH_EXTRA
4179 // Redraw the window to refresh the highlighted matches.
4180 if (i > 0 && p_hls && !no_hlsearch)
4181 redraw_later(SOME_VALID);
4182 #endif
4176 } 4183 }
4177 4184
4178 /* 4185 /*
4179 * Search for "pat" in direction "dir" ('/' or '?', 0 for repeat). 4186 * Search for "pat" in direction "dir" ('/' or '?', 0 for repeat).
4180 * Uses only cap->count1 and cap->oap from "cap". 4187 * Uses only cap->count1 and cap->oap from "cap".
4188 int opt, // extra flags for do_search() 4195 int opt, // extra flags for do_search()
4189 int *wrapped) 4196 int *wrapped)
4190 { 4197 {
4191 int i; 4198 int i;
4192 searchit_arg_T sia; 4199 searchit_arg_T sia;
4200 pos_T prev_cursor = curwin->w_cursor;
4193 4201
4194 cap->oap->motion_type = MCHAR; 4202 cap->oap->motion_type = MCHAR;
4195 cap->oap->inclusive = FALSE; 4203 cap->oap->inclusive = FALSE;
4196 cap->oap->use_reg_one = TRUE; 4204 cap->oap->use_reg_one = TRUE;
4197 curwin->w_set_curswant = TRUE; 4205 curwin->w_set_curswant = TRUE;
4211 #ifdef FEAT_FOLDING 4219 #ifdef FEAT_FOLDING
4212 if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) 4220 if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped)
4213 foldOpenCursor(); 4221 foldOpenCursor();
4214 #endif 4222 #endif
4215 } 4223 }
4224 #ifdef FEAT_SEARCH_EXTRA
4225 // Redraw the window to refresh the highlighted matches.
4226 if (!EQUAL_POS(curwin->w_cursor, prev_cursor) && p_hls && !no_hlsearch)
4227 redraw_later(SOME_VALID);
4228 #endif
4216 4229
4217 // "/$" will put the cursor after the end of the line, may need to 4230 // "/$" will put the cursor after the end of the line, may need to
4218 // correct that here 4231 // correct that here
4219 check_cursor(); 4232 check_cursor();
4220 return i; 4233 return i;