Merge remote-tracking branch 'vim/master'

This commit is contained in:
ichizok
2022-05-16 11:34:09 +09:00
8 changed files with 161 additions and 50 deletions
+22 -13
View File
@@ -2646,13 +2646,15 @@ buflist_findpat(
if (*p == '^' && !(attempt & 1)) // add/remove '^'
++p;
regmatch.regprog = vim_regcomp(p, magic_isset() ? RE_MAGIC : 0);
if (regmatch.regprog == NULL)
{
vim_free(pat);
return -1;
}
FOR_ALL_BUFS_FROM_LAST(buf)
{
if (regmatch.regprog == NULL)
{
// invalid pattern, possibly after switching engine
vim_free(pat);
return -1;
}
if (buf->b_p_bl == find_listed
#ifdef FEAT_DIFF
&& (!diffmode || diff_mode_buf(buf))
@@ -2678,6 +2680,7 @@ buflist_findpat(
}
match = buf->b_fnum; // remember first match
}
}
vim_regfree(regmatch.regprog);
if (match >= 0) // found one match
@@ -2770,12 +2773,6 @@ ExpandBufnames(
if (attempt > 0 && patc == pat)
break; // there was no anchor, no need to try again
regmatch.regprog = vim_regcomp(patc + attempt * 11, RE_MAGIC);
if (regmatch.regprog == NULL)
{
if (patc != pat)
vim_free(patc);
return FAIL;
}
}
// round == 1: Count the matches.
@@ -2796,7 +2793,16 @@ ExpandBufnames(
#endif
if (!fuzzy)
{
if (regmatch.regprog == NULL)
{
// invalid pattern, possibly after recompiling
if (patc != pat)
vim_free(patc);
return FAIL;
}
p = buflist_match(&regmatch, buf, p_wic);
}
else
{
p = NULL;
@@ -2925,6 +2931,7 @@ ExpandBufnames(
/*
* Check for a match on the file name for buffer "buf" with regprog "prog".
* Note that rmp->regprog may become NULL when switching regexp engine.
*/
static char_u *
buflist_match(
@@ -2943,7 +2950,8 @@ buflist_match(
}
/*
* Try matching the regexp in "prog" with file name "name".
* Try matching the regexp in "rmp->regprog" with file name "name".
* Note that rmp->regprog may become NULL when switching regexp engine.
* Return "name" when there is a match, NULL when not.
*/
static char_u *
@@ -2955,7 +2963,8 @@ fname_match(
char_u *match = NULL;
char_u *p;
if (name != NULL)
// extra check for valid arguments
if (name != NULL && rmp->regprog != NULL)
{
// Ignore case when 'fileignorecase' or the argument is set.
rmp->rm_ic = p_fic || ignore_case;
+29 -32
View File
@@ -9823,43 +9823,40 @@ f_spellsuggest(typval_T *argvars UNUSED, typval_T *rettv)
}
#ifdef FEAT_SPELL
if (*curwin->w_s->b_p_spl != NUL)
str = tv_get_string(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN)
{
str = tv_get_string(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN)
maxcount = (int)tv_get_number_chk(&argvars[1], &typeerr);
if (maxcount <= 0)
return;
if (argvars[2].v_type != VAR_UNKNOWN)
{
maxcount = (int)tv_get_number_chk(&argvars[1], &typeerr);
if (maxcount <= 0)
need_capital = (int)tv_get_bool_chk(&argvars[2], &typeerr);
if (typeerr)
return;
if (argvars[2].v_type != VAR_UNKNOWN)
{
need_capital = (int)tv_get_bool_chk(&argvars[2], &typeerr);
if (typeerr)
return;
}
}
else
maxcount = 25;
spell_suggest_list(&ga, str, maxcount, need_capital, FALSE);
for (i = 0; i < ga.ga_len; ++i)
{
str = ((char_u **)ga.ga_data)[i];
li = listitem_alloc();
if (li == NULL)
vim_free(str);
else
{
li->li_tv.v_type = VAR_STRING;
li->li_tv.v_lock = 0;
li->li_tv.vval.v_string = str;
list_append(rettv->vval.v_list, li);
}
}
ga_clear(&ga);
}
else
maxcount = 25;
spell_suggest_list(&ga, str, maxcount, need_capital, FALSE);
for (i = 0; i < ga.ga_len; ++i)
{
str = ((char_u **)ga.ga_data)[i];
li = listitem_alloc();
if (li == NULL)
vim_free(str);
else
{
li->li_tv.v_type = VAR_STRING;
li->li_tv.v_lock = 0;
li->li_tv.vval.v_string = str;
list_append(rettv->vval.v_list, li);
}
}
ga_clear(&ga);
curwin->w_p_spell = wo_spell_save;
#endif
}
+5 -4
View File
@@ -3501,8 +3501,9 @@ ml_replace_len(
#ifdef FEAT_PROP_POPUP
/*
* Adjust text properties in line "lnum" for a deleted line.
* When "above" is true this is the line above the deleted line.
* "del_props" are the properties of the deleted line.
* When "above" is true this is the line above the deleted line, otherwise this
* is the line below the deleted line.
* "del_props[del_props_len]" are the properties of the deleted line.
*/
static void
adjust_text_props_for_delete(
@@ -3569,7 +3570,7 @@ adjust_text_props_for_delete(
: TP_FLAG_CONT_PREV;
textprop_T prop_this;
mch_memmove(&prop_this, text + textlen + done_del,
mch_memmove(&prop_this, text + textlen + done_this,
sizeof(textprop_T));
if ((prop_this.tp_flags & flag)
&& prop_del.tp_id == prop_this.tp_id
@@ -3577,7 +3578,7 @@ adjust_text_props_for_delete(
{
found = TRUE;
prop_this.tp_flags &= ~flag;
mch_memmove(text + textlen + done_del, &prop_this,
mch_memmove(text + textlen + done_this, &prop_this,
sizeof(textprop_T));
break;
}
+6
View File
@@ -1814,6 +1814,12 @@ op_change(oparg_T *oap)
oldp += bd.textcol;
STRMOVE(newp + offset, oldp);
ml_replace(linenr, newp, FALSE);
#ifdef FEAT_PROP_POPUP
// Shift the properties for linenr as edit() would do.
if (curbuf->b_has_textprop)
adjust_prop_columns(linenr, bd.textcol,
vpos.coladd + ins_len, 0);
#endif
}
}
check_cursor();
+1 -1
View File
@@ -2494,7 +2494,7 @@ qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, int is_file_stack)
// store directory on the stack
if (vim_isAbsName(dirbuf)
|| (*stackptr)->next == NULL
|| (*stackptr && is_file_stack))
|| is_file_stack)
(*stackptr)->dirname = vim_strsave(dirbuf);
else
{
+6
View File
@@ -419,6 +419,12 @@ func Test_buf_pattern_invalid()
vsplit 00000000000000000000000000
silent! buf [0--]\&\zs*\zs*e
bwipe!
" similar case with different code path
split 0
edit ÿ
silent! buf [0--]\&\zs*\zs*0
bwipe!
endfunc
" Test for the 'maxmem' and 'maxmemtot' options
+84
View File
@@ -1645,6 +1645,57 @@ def Test_prop_add_delete_line()
bwipe!
enddef
" This test is to detect a regression related to #10430. It is not an attempt
" fully cover deleting lines in the presence of multi-line properties.
def Test_delete_line_within_multiline_prop()
new
setline(1, '# Top.')
append(1, ['some_text = """', 'A string.', '"""', '# Bottom.'])
prop_type_add('Identifier', {'highlight': 'ModeMsg', 'priority': 0, 'combine': 0, 'start_incl': 0, 'end_incl': 0})
prop_type_add('String', {'highlight': 'MoreMsg', 'priority': 0, 'combine': 0, 'start_incl': 0, 'end_incl': 0})
prop_add(2, 1, {'type': 'Identifier', 'end_lnum': 2, 'end_col': 9})
prop_add(2, 13, {'type': 'String', 'end_lnum': 4, 'end_col': 4})
# The property for line 3 should extend into the previous and next lines.
var props = prop_list(3)
var prop = props[0]
assert_equal(1, len(props))
assert_equal(0, prop['start'])
assert_equal(0, prop['end'])
# This deletion should run without raising an exception.
try
:2 del
catch
assert_report('Line delete should have workd, but it raised an error.')
endtry
# The property for line 2 (was 3) should no longer extend into the previous
# line.
props = prop_list(2)
prop = props[0]
assert_equal(1, len(props))
assert_equal(1, prop['start'], 'Property was not changed to start within the line.')
# This deletion should run without raising an exception.
try
:3 del
catch
assert_report('Line delete should have workd, but it raised an error.')
endtry
# The property for line 2 (originally 3) should no longer extend into the next
# line.
props = prop_list(2)
prop = props[0]
assert_equal(1, len(props))
assert_equal(1, prop['end'], 'Property was not changed to end within the line.')
prop_type_delete('Identifier')
prop_type_delete('String')
bwip!
enddef
func Test_prop_in_linebreak()
CheckRunVimInTerminal
@@ -2003,4 +2054,37 @@ func Test_prop_insert_multiline()
bwipe!
endfunc
func Test_prop_blockwise_change()
new
call AddPropTypes()
call setline(1, ['foooooo', 'bar', 'baaaaz'])
call prop_add(1, 1, #{end_col: 3, type: 'one'})
call prop_add(2, 1, #{end_col: 3, type: 'two'})
call prop_add(3, 1, #{end_col: 3, type: 'three'})
" Replace the first two columns with '123', since 'start_incl' is false the
" prop is not extended.
call feedkeys("gg\<c-v>2jc123\<Esc>", 'nxt')
let lines =<< trim END
123oooooo
123ar
123aaaaz
END
call assert_equal(lines, getline(1, '$'))
let expected = [
\ {'lnum': 1, 'id': 0, 'col': 4, 'type_bufnr': 0, 'end': 1, 'type': 'one',
\ 'length': 1, 'start': 1},
\ {'lnum': 2, 'id': 0, 'col': 4, 'type_bufnr': 0, 'end': 1, 'type': 'two',
\ 'length': 1, 'start': 1},
\ {'lnum': 3, 'id': 0, 'col': 4, 'type_bufnr': 0, 'end': 1 ,
\ 'type': 'three', 'length': 1, 'start': 1}
\ ]
call assert_equal(expected, prop_list(1, #{end_lnum: 10}))
call DeletePropTypes()
bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab
+8
View File
@@ -761,6 +761,14 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4960,
/**/
4959,
/**/
4958,
/**/
4957,
/**/
4956,
/**/