diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-11-25 19:15:05 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-11-25 19:27:38 +0000 |
commit | c5d770d311841ea5230426cc4c868e8db27300a8 (patch) | |
tree | dd21f70127b4b8b5f109baefc8ecc5016f507c91 /src/nvim/search.c | |
parent | 9be89f131f87608f224f0ee06d199fcd09d32176 (diff) | |
parent | 081beb3659bd6d8efc3e977a160b1e72becbd8a2 (diff) | |
download | rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.gz rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.bz2 rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.zip |
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'src/nvim/search.c')
-rw-r--r-- | src/nvim/search.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c index ff6e135df1..debc5697d1 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -113,7 +113,7 @@ static int last_idx = 0; // index in spats[] for RE_LAST static uint8_t lastc[2] = { NUL, NUL }; // last character searched for static Direction lastcdir = FORWARD; // last direction of character search static bool last_t_cmd = true; // last search t_cmd -static char lastc_bytes[MB_MAXBYTES + 1]; +static char lastc_bytes[MAX_SCHAR_SIZE + 1]; static int lastc_bytelen = 1; // >1 for multi-byte char // copy of spats[], for keeping the search patterns while executing autocmds @@ -380,6 +380,11 @@ char *last_search_pattern(void) return spats[RE_SEARCH].pat; } +size_t last_search_pattern_len(void) +{ + return spats[RE_SEARCH].patlen; +} + /// Return true when case should be ignored for search pattern "pat". /// Uses the 'ignorecase' and 'smartcase' options. int ignorecase(char *pat) @@ -1299,7 +1304,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char *pat, size_t patlen memset(msgbuf + pat_len, ' ', (size_t)(r - msgbuf)); } } - msg_outtrans(msgbuf, 0); + msg_outtrans(msgbuf, 0, false); msg_clr_eos(); msg_check(); @@ -1545,14 +1550,11 @@ int searchc(cmdarg_T *cap, bool t_cmd) *lastc = (uint8_t)c; set_csearch_direction(dir); set_csearch_until(t_cmd); - lastc_bytelen = utf_char2bytes(c, lastc_bytes); - if (cap->ncharC1 != 0) { - lastc_bytelen += utf_char2bytes(cap->ncharC1, - lastc_bytes + lastc_bytelen); - if (cap->ncharC2 != 0) { - lastc_bytelen += utf_char2bytes(cap->ncharC2, - lastc_bytes + lastc_bytelen); - } + if (cap->nchar_len) { + lastc_bytelen = cap->nchar_len; + memcpy(lastc_bytes, cap->nchar_composing, (size_t)cap->nchar_len); + } else { + lastc_bytelen = utf_char2bytes(c, lastc_bytes); } } } else { // repeat previous search @@ -3729,7 +3731,7 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool && action == ACTION_SHOW_ALL && files[i].matched) { msg_putchar('\n'); // cursor below last one if (!got_int) { // don't display if 'q' typed at "--more--" message - msg_home_replace_hl(new_fname); + msg_home_replace(new_fname); msg_puts(_(" (includes previously listed match)")); prev_fname = NULL; } @@ -3770,7 +3772,7 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool if (new_fname != NULL) { // using "new_fname" is more reliable, e.g., when // 'includeexpr' is set. - msg_outtrans(new_fname, HL_ATTR(HLF_D)); + msg_outtrans(new_fname, HLF_D, false); } else { // Isolate the file name. // Include the surrounding "" or <> if present. @@ -3804,7 +3806,7 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool } char save_char = p[i]; p[i] = NUL; - msg_outtrans(p, HL_ATTR(HLF_D)); + msg_outtrans(p, HLF_D, false); p[i] = save_char; } @@ -3856,7 +3858,7 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool vim_snprintf(IObuff, IOSIZE, _("Scanning included file: %s"), new_fname); - msg_trunc(IObuff, true, HL_ATTR(HLF_R)); + msg_trunc(IObuff, true, HLF_R); } else if (p_verbose >= 5) { verbose_enter(); smsg(0, _("Searching included file %s"), new_fname); @@ -4030,7 +4032,7 @@ search_line: } if (!got_int) { // don't display if 'q' typed // at "--more--" message - msg_home_replace_hl(curr_fname); + msg_home_replace(curr_fname); } prev_fname = curr_fname; } @@ -4231,7 +4233,7 @@ static void show_pat_in_path(char *line, int type, bool did_show, int action, FI msg_puts(IObuff); snprintf(IObuff, IOSIZE, "%4" PRIdLINENR, *lnum); // Show line nr. // Highlight line numbers. - msg_puts_attr(IObuff, HL_ATTR(HLF_N)); + msg_puts_hl(IObuff, HLF_N, false); msg_puts(" "); } msg_prt_line(line, false); |