mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.1701: Vim9: sort("i") does not work
Problem: Vim9: sort("i") does not work. Solution: Don't try getting a number for a string argument. (closes #6958)
This commit is contained in:
parent
9939f57b7f
commit
08e51f446b
27
src/list.c
27
src/list.c
@ -1717,18 +1717,25 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
int error = FALSE;
|
int error = FALSE;
|
||||||
|
int nr = 0;
|
||||||
|
|
||||||
i = (long)tv_get_number_chk(&argvars[1], &error);
|
if (argvars[1].v_type == VAR_NUMBER)
|
||||||
if (error)
|
|
||||||
goto theend; // type error; errmsg already given
|
|
||||||
if (i == 1)
|
|
||||||
info.item_compare_ic = TRUE;
|
|
||||||
else if (argvars[1].v_type != VAR_NUMBER)
|
|
||||||
info.item_compare_func = tv_get_string(&argvars[1]);
|
|
||||||
else if (i != 0)
|
|
||||||
{
|
{
|
||||||
emsg(_(e_invarg));
|
nr = tv_get_number_chk(&argvars[1], &error);
|
||||||
goto theend;
|
if (error)
|
||||||
|
goto theend; // type error; errmsg already given
|
||||||
|
if (nr == 1)
|
||||||
|
info.item_compare_ic = TRUE;
|
||||||
|
}
|
||||||
|
if (nr != 1)
|
||||||
|
{
|
||||||
|
if (argvars[1].v_type != VAR_NUMBER)
|
||||||
|
info.item_compare_func = tv_get_string(&argvars[1]);
|
||||||
|
else if (nr != 0)
|
||||||
|
{
|
||||||
|
emsg(_(e_invarg));
|
||||||
|
goto theend;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (info.item_compare_func != NULL)
|
if (info.item_compare_func != NULL)
|
||||||
{
|
{
|
||||||
|
@ -1299,6 +1299,11 @@ def Test_sort_return_type()
|
|||||||
res = [1, 2, 3]->sort()
|
res = [1, 2, 3]->sort()
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_sort_argument()
|
||||||
|
let res = ['b', 'a', 'c']->sort('i')
|
||||||
|
res->assert_equal(['a', 'b', 'c'])
|
||||||
|
enddef
|
||||||
|
|
||||||
def Test_getqflist_return_type()
|
def Test_getqflist_return_type()
|
||||||
let l = getqflist()
|
let l = getqflist()
|
||||||
l->assert_equal([])
|
l->assert_equal([])
|
||||||
|
@ -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 */
|
||||||
|
/**/
|
||||||
|
1701,
|
||||||
/**/
|
/**/
|
||||||
1700,
|
1700,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user