mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:7.4.2160 (#5952)
Problem: setmatches() mixes up values. (Nikolai Pavlov)
Solution: Save the string instead of reusing a shared buffer.
7dc5e2e486
This commit is contained in:
parent
c88e4a270d
commit
a6be6df5d6
@ -6726,6 +6726,7 @@ static bool get_dict_callback(dict_T *d, char *key, Callback *result)
|
|||||||
/// Get a string item from a dictionary.
|
/// Get a string item from a dictionary.
|
||||||
///
|
///
|
||||||
/// @param save whether memory should be allocated for the return value
|
/// @param save whether memory should be allocated for the return value
|
||||||
|
/// when false a shared buffer is used, can only be used once!
|
||||||
///
|
///
|
||||||
/// @return the entry or NULL if the entry doesn't exist.
|
/// @return the entry or NULL if the entry doesn't exist.
|
||||||
char_u *get_dict_string(dict_T *d, char *key, bool save)
|
char_u *get_dict_string(dict_T *d, char *key, bool save)
|
||||||
@ -15445,12 +15446,11 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char_u *group = get_dict_string(d, "group", false);
|
char_u *group = get_dict_string(d, "group", true);
|
||||||
int priority = get_dict_number(d, "priority");
|
int priority = get_dict_number(d, "priority");
|
||||||
int id = get_dict_number(d, "id");
|
int id = get_dict_number(d, "id");
|
||||||
char_u *conceal = dict_find(d, (char_u *)"conceal", -1) != NULL
|
char_u *conceal = dict_find(d, (char_u *)"conceal", -1) != NULL
|
||||||
? get_dict_string(d, "conceal",
|
? get_dict_string(d, "conceal", true)
|
||||||
false)
|
|
||||||
: NULL;
|
: NULL;
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
match_add(curwin, group,
|
match_add(curwin, group,
|
||||||
@ -15461,6 +15461,8 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
list_unref(s);
|
list_unref(s);
|
||||||
s = NULL;
|
s = NULL;
|
||||||
}
|
}
|
||||||
|
xfree(group);
|
||||||
|
xfree(conceal);
|
||||||
li = li->li_next;
|
li = li->li_next;
|
||||||
}
|
}
|
||||||
rettv->vval.v_number = 0;
|
rettv->vval.v_number = 0;
|
||||||
|
@ -96,4 +96,12 @@ endfunc
|
|||||||
func Test_special_char()
|
func Test_special_char()
|
||||||
" The failure is only visible using valgrind.
|
" The failure is only visible using valgrind.
|
||||||
call assert_fails('echo "\<C-">')
|
call assert_fails('echo "\<C-">')
|
||||||
|
|
||||||
|
func Test_setmatches()
|
||||||
|
hi def link 1 Comment
|
||||||
|
hi def link 2 PreProc
|
||||||
|
let set = [{"group": 1, "pattern": 2, "id": 3, "priority": 4, "conceal": 5}]
|
||||||
|
let exp = [{"group": '1', "pattern": '2', "id": 3, "priority": 4, "conceal": '5'}]
|
||||||
|
call setmatches(set)
|
||||||
|
call assert_equal(exp, getmatches())
|
||||||
endfunc
|
endfunc
|
||||||
|
@ -280,7 +280,7 @@ static int included_patches[] = {
|
|||||||
2163,
|
2163,
|
||||||
2162,
|
2162,
|
||||||
// 2161,
|
// 2161,
|
||||||
// 2160,
|
2160,
|
||||||
// 2159,
|
// 2159,
|
||||||
2158,
|
2158,
|
||||||
// 2157 NA
|
// 2157 NA
|
||||||
|
Loading…
Reference in New Issue
Block a user