Compare commits

...

6 Commits

Author SHA1 Message Date
Bram Moolenaar
13b8205b44 patch 8.2.0950: tagjump test fails
Problem:    Tagjump test fails.
Solution:   Adjust expected text of the prompt.
2020-06-10 17:13:48 +02:00
Bram Moolenaar
ea1233fccf patch 8.2.0949: strptime() does not use DST
Problem:    Strptime() does not use DST.
Solution:   Set the tm_isdst field to -1. (Tomáš Janoušek, closes #6230)
2020-06-10 16:54:13 +02:00
Bram Moolenaar
d281b7c227 patch 8.2.0948: spell test fails
Problem:    Spell test fails.
Solution:   Adjust expected text of the prompt.
2020-06-10 16:39:32 +02:00
Bram Moolenaar
ab54032f29 patch 8.2.0947: readdirex() doesn't handle broken link properly
Problem:    Readdirex() doesn't handle broken link properly.
Solution:   Small fixes to readdirex(). (Christian Brabandt, closes #6226,
            closes #6213)
2020-06-10 15:55:36 +02:00
Bram Moolenaar
eebd555733 patch 8.2.0946: cannot use "q" to cancel a number prompt
Problem:    Cannot use "q" to cancel a number prompt.
Solution:   Recognize "q" instead of ignoring it.
2020-06-10 15:45:57 +02:00
Bram Moolenaar
152e79e94b patch 8.2.0945: cannot use "z=" when 'spell' is off
Problem:    Cannot use "z=" when 'spell' is off.
Solution:   Make "z=" work even when 'spell' is off. (Christian Brabandt,
            Gary Johnson, closes #6227)
2020-06-10 15:32:08 +02:00
12 changed files with 161 additions and 23 deletions

View File

@@ -9537,9 +9537,8 @@ spellbadword([{sentence}])
echo spellbadword("the quik brown fox")
< ['quik', 'bad'] ~
The spelling information for the current window is used. The
'spell' option must be set and the value of 'spelllang' is
used.
The spelling information for the current window and the value
of 'spelllang' are used.
Can also be used as a |method|: >
GetText()->spellbadword()
@@ -9564,8 +9563,7 @@ spellsuggest({word} [, {max} [, {capital}]])
although it may appear capitalized.
The spelling information for the current window is used. The
'spell' option must be set and the values of 'spelllang' and
'spellsuggest' are used.
values of 'spelllang' and 'spellsuggest' are used.
Can also be used as a |method|: >
GetWord()->spellsuggest()

View File

@@ -7596,9 +7596,30 @@ f_spellbadword(typval_T *argvars UNUSED, typval_T *rettv)
char_u *word = (char_u *)"";
hlf_T attr = HLF_COUNT;
int len = 0;
#ifdef FEAT_SPELL
int wo_spell_save = curwin->w_p_spell;
if (!curwin->w_p_spell)
{
did_set_spelllang(curwin);
curwin->w_p_spell = TRUE;
}
if (*curwin->w_s->b_p_spl == NUL)
{
emsg(_(e_no_spell));
curwin->w_p_spell = wo_spell_save;
return;
}
#endif
if (rettv_list_alloc(rettv) == FAIL)
{
#ifdef FEAT_SPELL
curwin->w_p_spell = wo_spell_save;
#endif
return;
}
#ifdef FEAT_SPELL
if (argvars[0].v_type == VAR_UNKNOWN)
@@ -7611,7 +7632,7 @@ f_spellbadword(typval_T *argvars UNUSED, typval_T *rettv)
curwin->w_set_curswant = TRUE;
}
}
else if (curwin->w_p_spell && *curbuf->b_s.b_p_spl != NUL)
else if (*curbuf->b_s.b_p_spl != NUL)
{
char_u *str = tv_get_string_chk(&argvars[0]);
int capcol = -1;
@@ -7633,6 +7654,7 @@ f_spellbadword(typval_T *argvars UNUSED, typval_T *rettv)
}
}
}
curwin->w_p_spell = wo_spell_save;
#endif
list_append_string(rettv->vval.v_list, word, len);
@@ -7658,13 +7680,32 @@ f_spellsuggest(typval_T *argvars UNUSED, typval_T *rettv)
int i;
listitem_T *li;
int need_capital = FALSE;
int wo_spell_save = curwin->w_p_spell;
if (!curwin->w_p_spell)
{
did_set_spelllang(curwin);
curwin->w_p_spell = TRUE;
}
if (*curwin->w_s->b_p_spl == NUL)
{
emsg(_(e_no_spell));
curwin->w_p_spell = wo_spell_save;
return;
}
#endif
if (rettv_list_alloc(rettv) == FAIL)
{
#ifdef FEAT_SPELL
curwin->w_p_spell = wo_spell_save;
#endif
return;
}
#ifdef FEAT_SPELL
if (curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL)
if (*curwin->w_s->b_p_spl != NUL)
{
str = tv_get_string(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN)
@@ -7701,6 +7742,7 @@ f_spellsuggest(typval_T *argvars UNUSED, typval_T *rettv)
}
ga_clear(&ga);
}
curwin->w_p_spell = wo_spell_save;
#endif
}

View File

@@ -4544,7 +4544,7 @@ create_readdirex_item(char_u *path, char_u *name)
int ret, link = FALSE;
varnumber_T size;
char_u permbuf[] = "---------";
char_u *q;
char_u *q = NULL;
struct passwd *pw;
struct group *gr;
@@ -4563,6 +4563,9 @@ create_readdirex_item(char_u *path, char_u *name)
{
link = TRUE;
ret = mch_stat(p, &st);
if (ret < 0)
q = (char_u*)"link";
}
vim_free(p);
@@ -4617,7 +4620,7 @@ create_readdirex_item(char_u *path, char_u *name)
goto theend;
if (dict_add_number(item, "time", -1) == FAIL)
goto theend;
if (dict_add_string(item, "type", (char_u*)"") == FAIL)
if (dict_add_string(item, "type", q == NULL ? (char_u*)"" : q) == FAIL)
goto theend;
if (dict_add_string(item, "perm", (char_u*)"") == FAIL)
goto theend;
@@ -4719,6 +4722,11 @@ readdir_core(
ignore = wp[0] == L'.' &&
(wp[1] == NUL ||
(wp[1] == L'.' && wp[2] == NUL));
if (ignore)
{
ok = FindNextFileW(hFind, &wfd);
continue;
}
# ifdef FEAT_EVAL
if (withattr)
item = (void*)create_readdirex_item(&wfd);
@@ -4787,6 +4795,8 @@ readdir_core(
ignore = p[0] == '.' &&
(p[1] == NUL ||
(p[1] == '.' && p[2] == NUL));
if (ignore)
continue;
# ifdef FEAT_EVAL
if (withattr)
item = (void*)create_readdirex_item(path, p);

View File

@@ -1581,6 +1581,9 @@ EXTERN char e_invcmd[] INIT(= N_("E476: Invalid command"));
#if defined(UNIX) || defined(FEAT_SYN_HL) || defined(FEAT_SPELL)
EXTERN char e_isadir2[] INIT(= N_("E17: \"%s\" is a directory"));
#endif
#ifdef FEAT_SPELL
EXTERN char e_no_spell[] INIT(= N_("E756: Spell checking is not possible"));
#endif
#ifdef FEAT_LIBCALL
EXTERN char e_libcall[] INIT(= N_("E364: Library call failed for \"%s()\""));
#endif

View File

@@ -945,7 +945,7 @@ get_number(
do_redraw = FALSE;
break;
}
else if (c == CAR || c == NL || c == Ctrl_C || c == ESC)
else if (c == CAR || c == NL || c == Ctrl_C || c == ESC || c == 'q')
break;
}
--no_mapping;
@@ -967,9 +967,9 @@ prompt_for_number(int *mouse_used)
// When using ":silent" assume that <CR> was entered.
if (mouse_used != NULL)
msg_puts(_("Type number and <Enter> or click with mouse (empty cancels): "));
msg_puts(_("Type number and <Enter> or click with the mouse (q or empty cancels): "));
else
msg_puts(_("Type number and <Enter> (empty cancels): "));
msg_puts(_("Type number and <Enter> (q or empty cancels): "));
// Set the state such that text can be selected/copied/pasted and we still
// get mouse events. redraw_after_callback() will not redraw if cmdline_row

View File

@@ -1225,7 +1225,7 @@ no_spell_checking(win_T *wp)
if (!wp->w_p_spell || *wp->w_s->b_p_spl == NUL
|| wp->w_s->b_langp.ga_len == 0)
{
emsg(_("E756: Spell checking is not enabled"));
emsg(_(e_no_spell));
return TRUE;
}
return FALSE;

View File

@@ -471,9 +471,19 @@ spell_suggest(int count)
int selected = count;
int badlen = 0;
int msg_scroll_save = msg_scroll;
int wo_spell_save = curwin->w_p_spell;
if (no_spell_checking(curwin))
if (!curwin->w_p_spell)
{
did_set_spelllang(curwin);
curwin->w_p_spell = TRUE;
}
if (*curwin->w_s->b_p_spl == NUL)
{
emsg(_(e_no_spell));
return;
}
if (VIsual_active)
{
@@ -686,6 +696,7 @@ spell_suggest(int count)
spell_find_cleanup(&sug);
skip:
vim_free(line);
curwin->w_p_spell = wo_spell_save;
}
/*

View File

@@ -280,6 +280,10 @@ func Test_strptime()
call assert_equal(1484653763, strptime('%Y-%m-%d %T', '2017-01-17 11:49:23'))
" Force DST and check that it's considered
let $TZ = 'WINTER0SUMMER,J1,J365'
call assert_equal(1484653763 - 3600, strptime('%Y-%m-%d %T', '2017-01-17 11:49:23'))
call assert_fails('call strptime()', 'E119:')
call assert_fails('call strptime("xxx")', 'E119:')
call assert_equal(0, strptime("%Y", ''))
@@ -1371,6 +1375,18 @@ func Test_inputlist()
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>3\<cr>", 'tx')
call assert_equal(3, c)
" CR to cancel
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>\<cr>", 'tx')
call assert_equal(0, c)
" Esc to cancel
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>\<Esc>", 'tx')
call assert_equal(0, c)
" q to cancel
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>q", 'tx')
call assert_equal(0, c)
" Use backspace to delete characters in the prompt
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>1\<BS>3\<BS>2\<cr>", 'tx')
call assert_equal(2, c)
@@ -1900,6 +1916,16 @@ func Test_readdirex()
\ ->map({-> v:val.name})
call sort(files)->assert_equal(['bar.txt', 'dir', 'foo.txt'])
" report brocken link correctly
if has("unix")
call writefile([], 'Xdir/abc.txt')
call system("ln -s Xdir/abc.txt Xdir/link")
call delete('Xdir/abc.txt')
let files = readdirex('Xdir', 'readdirex("Xdir", "1") != []')
\ ->map({-> v:val.name .. '_' .. v:val.type})
call sort(files)->assert_equal(
\ ['bar.txt_file', 'dir_dir', 'foo.txt_file', 'link_link'])
endif
eval 'Xdir'->delete('rf')
endfunc

View File

@@ -99,11 +99,14 @@ foobar/?
set spelllang=Xwords.spl
call assert_equal(['foobar', 'rare'], spellbadword('foo foobar'))
" Typo should not be detected without the 'spell' option.
" Typo should be detected even without the 'spell' option.
set spelllang=en_gb nospell
call assert_equal(['', ''], spellbadword('centre'))
call assert_equal(['', ''], spellbadword('My bycycle.'))
call assert_equal(['', ''], spellbadword('A sentence. another sentence'))
call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.'))
call assert_equal(['another', 'caps'], spellbadword('A sentence. another sentence'))
set spelllang=
call assert_fails("call spellbadword('maxch')", 'E756:')
call delete('Xwords.spl')
call delete('Xwords')
@@ -130,9 +133,9 @@ endfunc
" Test spellsuggest({word} [, {max} [, {capital}]])
func Test_spellsuggest()
" No suggestions when spell checking is not enabled.
" Verify suggestions are given even when spell checking is not enabled.
set nospell
call assert_equal([], spellsuggest('marrch'))
call assert_equal(['march', 'March'], spellsuggest('marrch', 2))
set spell
@@ -163,6 +166,10 @@ func Test_spellsuggest()
call assert_fails("call spellsuggest('maxch', [])", 'E745:')
call assert_fails("call spellsuggest('maxch', 2, [])", 'E745:')
set spelllang=
call assert_fails("call spellsuggest('maxch')", 'E756:')
set spelllang&
set spell&
endfunc
@@ -245,7 +252,7 @@ func Test_spellsuggest_option_number()
\ .. "Change \"baord\" to:\n"
\ .. " 1 \"board\"\n"
\ .. " 2 \"bard\"\n"
\ .. "Type number and <Enter> or click with mouse (empty cancels): ", a)
\ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
set spell spellsuggest=0
call assert_equal("\nSorry, no suggestions", execute('norm $z='))
@@ -283,7 +290,7 @@ func Test_spellsuggest_option_expr()
\ .. " 1 \"BARD\"\n"
\ .. " 2 \"BOARD\"\n"
\ .. " 3 \"BROAD\"\n"
\ .. "Type number and <Enter> or click with mouse (empty cancels): ", a)
\ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
" With verbose, z= should show the score i.e. word length with
" our SpellSuggest() function.
@@ -295,7 +302,7 @@ func Test_spellsuggest_option_expr()
\ .. " 1 \"BARD\" (4 - 0)\n"
\ .. " 2 \"BOARD\" (5 - 0)\n"
\ .. " 3 \"BROAD\" (5 - 0)\n"
\ .. "Type number and <Enter> or click with mouse (empty cancels): ", a)
\ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
set spell& spellsuggest& verbose&
bwipe!
@@ -617,6 +624,34 @@ func Test_zeq_crash()
bwipe!
endfunc
" Check that z= works even when 'nospell' is set. This test uses one of the
" tests in Test_spellsuggest_option_number() just to verify that z= basically
" works and that "E756: Spell checking is not enabled" is not generated.
func Test_zeq_nospell()
new
set nospell spellsuggest=1,best
call setline(1, 'A baord')
try
norm $1z=
call assert_equal('A board', getline(1))
catch
call assert_report("Caught exception: " . v:exception)
endtry
set spell& spellsuggest&
bwipe!
endfunc
" Check that "E756: Spell checking is not possible" is reported when z= is
" executed and 'spelllang' is empty.
func Test_zeq_no_spelllang()
new
set spelllang= spellsuggest=1,best
call setline(1, 'A baord')
call assert_fails('normal $1z=', 'E756:')
set spelllang& spellsuggest&
bwipe!
endfunc
" Check handling a word longer than MAXWLEN.
func Test_spell_long_word()
set enc=utf-8

View File

@@ -1031,7 +1031,7 @@ func Test_tselect_listing()
2 FS v first Xfoo
typeref:typename:char
2
Type number and <Enter> (empty cancels):
Type number and <Enter> (q or empty cancels):
[DATA]
call assert_equal(expected, l)

View File

@@ -314,6 +314,7 @@ f_strptime(typval_T *argvars, typval_T *rettv)
char_u *enc;
CLEAR_FIELD(tmval);
tmval.tm_isdst = -1;
fmt = tv_get_string(&argvars[0]);
str = tv_get_string(&argvars[1]);

View File

@@ -754,6 +754,18 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
950,
/**/
949,
/**/
948,
/**/
947,
/**/
946,
/**/
945,
/**/
944,
/**/