mirror of
https://github.com/vim/vim.git
synced 2025-10-17 07:44:28 -04:00
patch 8.2.4249: the timeout limit for spell suggestions is always 5000
Problem: The timeout limit for spell suggestions is always 5000 milli seconds. Solution: Add the "timeout" entry to 'spellsuggest'.
This commit is contained in:
@@ -7363,6 +7363,12 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
suggestions is never more than the value of 'lines'
|
suggestions is never more than the value of 'lines'
|
||||||
minus two.
|
minus two.
|
||||||
|
|
||||||
|
timeout:{millisec} Limit the time searching for suggestions to
|
||||||
|
{millisec} milli seconds. Applies to the following
|
||||||
|
methods. When omitted the limit is 5000. When
|
||||||
|
negative there is no limit. {only works when built
|
||||||
|
with the +reltime feature}
|
||||||
|
|
||||||
file:{filename} Read file {filename}, which must have two columns,
|
file:{filename} Read file {filename}, which must have two columns,
|
||||||
separated by a slash. The first column contains the
|
separated by a slash. The first column contains the
|
||||||
bad word, the second column the suggested good word.
|
bad word, the second column the suggested good word.
|
||||||
|
@@ -197,6 +197,8 @@ typedef struct trystate_S
|
|||||||
#define PFD_PREFIXTREE 0xfe // walking through the prefix tree
|
#define PFD_PREFIXTREE 0xfe // walking through the prefix tree
|
||||||
#define PFD_NOTSPECIAL 0xfd // highest value that's not special
|
#define PFD_NOTSPECIAL 0xfd // highest value that's not special
|
||||||
|
|
||||||
|
static long spell_suggest_timeout = 5000;
|
||||||
|
|
||||||
static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int maxcount, int banbadword, int need_cap, int interactive);
|
static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int maxcount, int banbadword, int need_cap, int interactive);
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
static void spell_suggest_expr(suginfo_T *su, char_u *expr);
|
static void spell_suggest_expr(suginfo_T *su, char_u *expr);
|
||||||
@@ -429,7 +431,10 @@ spell_check_sps(void)
|
|||||||
else if (STRCMP(buf, "double") == 0)
|
else if (STRCMP(buf, "double") == 0)
|
||||||
f = SPS_DOUBLE;
|
f = SPS_DOUBLE;
|
||||||
else if (STRNCMP(buf, "expr:", 5) != 0
|
else if (STRNCMP(buf, "expr:", 5) != 0
|
||||||
&& STRNCMP(buf, "file:", 5) != 0)
|
&& STRNCMP(buf, "file:", 5) != 0
|
||||||
|
&& (STRNCMP(buf, "timeout:", 8) != 0
|
||||||
|
|| (!VIM_ISDIGIT(buf[8])
|
||||||
|
&& !(buf[8] == '-' && VIM_ISDIGIT(buf[9])))))
|
||||||
f = -1;
|
f = -1;
|
||||||
|
|
||||||
if (f == -1 || (sps_flags != 0 && f != 0))
|
if (f == -1 || (sps_flags != 0 && f != 0))
|
||||||
@@ -842,6 +847,7 @@ spell_find_suggest(
|
|||||||
sps_copy = vim_strsave(p_sps);
|
sps_copy = vim_strsave(p_sps);
|
||||||
if (sps_copy == NULL)
|
if (sps_copy == NULL)
|
||||||
return;
|
return;
|
||||||
|
spell_suggest_timeout = 5000;
|
||||||
|
|
||||||
// Loop over the items in 'spellsuggest'.
|
// Loop over the items in 'spellsuggest'.
|
||||||
for (p = sps_copy; *p != NUL; )
|
for (p = sps_copy; *p != NUL; )
|
||||||
@@ -864,6 +870,9 @@ spell_find_suggest(
|
|||||||
else if (STRNCMP(buf, "file:", 5) == 0)
|
else if (STRNCMP(buf, "file:", 5) == 0)
|
||||||
// Use list of suggestions in a file.
|
// Use list of suggestions in a file.
|
||||||
spell_suggest_file(su, buf + 5);
|
spell_suggest_file(su, buf + 5);
|
||||||
|
else if (STRNCMP(buf, "timeout:", 8) == 0)
|
||||||
|
// Limit the time searching for suggestions.
|
||||||
|
spell_suggest_timeout = atol((char *)buf + 8);
|
||||||
else if (!did_intern)
|
else if (!did_intern)
|
||||||
{
|
{
|
||||||
// Use internal method once.
|
// Use internal method once.
|
||||||
@@ -1325,9 +1334,10 @@ suggest_trie_walk(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef FEAT_RELTIME
|
#ifdef FEAT_RELTIME
|
||||||
// The loop may take an indefinite amount of time. Break out after five
|
// The loop may take an indefinite amount of time. Break out after some
|
||||||
// sectonds. TODO: add an option for the time limit.
|
// time.
|
||||||
profile_setlimit(5000, &time_limit);
|
if (spell_suggest_timeout > 0)
|
||||||
|
profile_setlimit(spell_suggest_timeout, &time_limit);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Loop to find all suggestions. At each round we either:
|
// Loop to find all suggestions. At each round we either:
|
||||||
@@ -2659,7 +2669,8 @@ suggest_trie_walk(
|
|||||||
ui_breakcheck();
|
ui_breakcheck();
|
||||||
breakcheckcount = 1000;
|
breakcheckcount = 1000;
|
||||||
#ifdef FEAT_RELTIME
|
#ifdef FEAT_RELTIME
|
||||||
if (profile_passed_limit(&time_limit))
|
if (spell_suggest_timeout > 0
|
||||||
|
&& profile_passed_limit(&time_limit))
|
||||||
got_int = TRUE;
|
got_int = TRUE;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -446,6 +446,16 @@ func Test_spellsuggest_expr_errors()
|
|||||||
delfunc MySuggest3
|
delfunc MySuggest3
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_spellsuggest_timeout()
|
||||||
|
set spellsuggest=timeout:30
|
||||||
|
set spellsuggest=timeout:-123
|
||||||
|
set spellsuggest=timeout:999999
|
||||||
|
call assert_fails('set spellsuggest=timeout', 'E474:')
|
||||||
|
call assert_fails('set spellsuggest=timeout:x', 'E474:')
|
||||||
|
call assert_fails('set spellsuggest=timeout:-x', 'E474:')
|
||||||
|
call assert_fails('set spellsuggest=timeout:--9', 'E474:')
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_spellinfo()
|
func Test_spellinfo()
|
||||||
new
|
new
|
||||||
let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
|
let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4249,
|
||||||
/**/
|
/**/
|
||||||
4248,
|
4248,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user