mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
vim-patch:9.1.1535: the maximum search count uses hard-coded value 99 (#34873)
Problem: The maximum search count uses a hard-coded value of 99
(Andres Monge, Joschua Kesper)
Solution: Make it configurable using the 'maxsearchcount' option.
related: vim/vim#8855
fixes: vim/vim#17527
closes: vim/vim#17695
b7b7fa04bf
Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
@ -2840,6 +2840,9 @@ static const char *validate_num_option(OptIndex opt_idx, OptInt *newval, char *e
|
||||
return e_invarg;
|
||||
}
|
||||
|
||||
// if you increase this, also increase SEARCH_STAT_BUF_LEN in search.c
|
||||
enum { MAX_SEARCH_COUNT = 9999, };
|
||||
|
||||
switch (opt_idx) {
|
||||
case kOptHelpheight:
|
||||
case kOptTitlelen:
|
||||
@ -2972,6 +2975,13 @@ static const char *validate_num_option(OptIndex opt_idx, OptInt *newval, char *e
|
||||
return e_cannot_have_more_than_hundred_quickfix;
|
||||
}
|
||||
break;
|
||||
case kOptMaxsearchcount:
|
||||
if (value <= 0) {
|
||||
return e_positive;
|
||||
} else if (value > MAX_SEARCH_COUNT) {
|
||||
return e_invarg;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -413,6 +413,7 @@ EXTERN OptInt p_mmd; ///< 'maxmapdepth'
|
||||
EXTERN OptInt p_mmp; ///< 'maxmempattern'
|
||||
EXTERN OptInt p_mis; ///< 'menuitems'
|
||||
EXTERN char *p_mopt; ///< 'messagesopt'
|
||||
EXTERN OptInt p_msc; ///< 'maxsearchcount'
|
||||
EXTERN char *p_msm; ///< 'mkspellmem'
|
||||
EXTERN int p_ml; ///< 'modeline'
|
||||
EXTERN int p_mle; ///< 'modelineexpr'
|
||||
|
@ -5655,6 +5655,22 @@ local options = {
|
||||
type = 'number',
|
||||
varname = 'p_mmp',
|
||||
},
|
||||
{
|
||||
abbreviation = 'msc',
|
||||
defaults = 999,
|
||||
desc = [=[
|
||||
Maximum number of matches shown for the search count status |shm-S|
|
||||
When the number of matches exceeds this value, Vim shows ">" instead
|
||||
of the exact count to keep searching fast.
|
||||
Note: larger values may impact performance.
|
||||
The value must be between 1 and 9999.
|
||||
]=],
|
||||
full_name = 'maxsearchcount',
|
||||
scope = { 'global' },
|
||||
short_desc = N_('maximum number for the search count feature'),
|
||||
type = 'number',
|
||||
varname = 'p_msc',
|
||||
},
|
||||
{
|
||||
abbreviation = 'mis',
|
||||
defaults = 25,
|
||||
@ -7884,7 +7900,8 @@ local options = {
|
||||
is shown), the "search hit BOTTOM, continuing at TOP" and
|
||||
"search hit TOP, continuing at BOTTOM" messages are only
|
||||
indicated by a "W" (Mnemonic: Wrapped) letter before the
|
||||
search count statistics.
|
||||
search count statistics. The maximum limit can be set with
|
||||
the 'maxsearchcount' option.
|
||||
|
||||
This gives you the opportunity to avoid that a change between buffers
|
||||
requires you to hit <Enter>, but still gives as useful a message as
|
||||
|
@ -1427,7 +1427,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char *pat, size_t patlen
|
||||
|| (!(fdo_flags & kOptFdoFlagSearch)
|
||||
&& hasFolding(curwin, curwin->w_cursor.lnum, NULL,
|
||||
NULL))),
|
||||
SEARCH_STAT_DEF_MAX_COUNT,
|
||||
(int)p_msc,
|
||||
SEARCH_STAT_DEF_TIMEOUT);
|
||||
}
|
||||
|
||||
@ -2704,7 +2704,7 @@ static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, searchst
|
||||
static int cnt = 0;
|
||||
static bool exact_match = false;
|
||||
static int incomplete = 0;
|
||||
static int last_maxcount = SEARCH_STAT_DEF_MAX_COUNT;
|
||||
static int last_maxcount = 0;
|
||||
static int chgtick = 0;
|
||||
static char *lastpat = NULL;
|
||||
static size_t lastpatlen = 0;
|
||||
@ -2717,7 +2717,7 @@ static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, searchst
|
||||
stat->cnt = cnt;
|
||||
stat->exact_match = exact_match;
|
||||
stat->incomplete = incomplete;
|
||||
stat->last_maxcount = last_maxcount;
|
||||
stat->last_maxcount = (int)p_msc;
|
||||
return;
|
||||
}
|
||||
last_maxcount = maxcount;
|
||||
@ -2801,7 +2801,7 @@ void f_searchcount(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
pos_T pos = curwin->w_cursor;
|
||||
char *pattern = NULL;
|
||||
int maxcount = SEARCH_STAT_DEF_MAX_COUNT;
|
||||
int maxcount = (int)p_msc;
|
||||
int timeout = SEARCH_STAT_DEF_TIMEOUT;
|
||||
bool recompute = true;
|
||||
searchstat_T stat;
|
||||
|
@ -63,8 +63,9 @@ enum {
|
||||
|
||||
// Values for searchcount()
|
||||
enum { SEARCH_STAT_DEF_TIMEOUT = 40, };
|
||||
enum { SEARCH_STAT_DEF_MAX_COUNT = 999, };
|
||||
enum { SEARCH_STAT_BUF_LEN = 14, };
|
||||
// 'W ': 2 +
|
||||
// '[>9999/>9999]': 13 + 1 (NUL)
|
||||
enum { SEARCH_STAT_BUF_LEN = 16, };
|
||||
|
||||
enum {
|
||||
/// Maximum number of characters that can be fuzzy matched
|
||||
|
Reference in New Issue
Block a user