• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Révision4ce3906e5997cbce9294dcce09f9e3827682ec59 (tree)
l'heure2020-09-17 06:30:04
AuteurBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Message de Log

patch 8.2.1701: Vim9: sort("i") does not work

Commit: https://github.com/vim/vim/commit/08e51f446bd4bf1a0342c471163b1ed083e9eedb
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Sep 16 23:23:36 2020 +0200

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 https://github.com/vim/vim/issues/6958)

Change Summary

Modification

diff -r 36e8e046c335 -r 4ce3906e5997 src/list.c
--- a/src/list.c Wed Sep 16 22:30:03 2020 +0200
+++ b/src/list.c Wed Sep 16 23:30:04 2020 +0200
@@ -1717,18 +1717,25 @@
17171717 else
17181718 {
17191719 int error = FALSE;
1720+ int nr = 0;
17201721
1721- i = (long)tv_get_number_chk(&argvars[1], &error);
1722- if (error)
1723- goto theend; // type error; errmsg already given
1724- if (i == 1)
1725- info.item_compare_ic = TRUE;
1726- else if (argvars[1].v_type != VAR_NUMBER)
1727- info.item_compare_func = tv_get_string(&argvars[1]);
1728- else if (i != 0)
1722+ if (argvars[1].v_type == VAR_NUMBER)
17291723 {
1730- emsg(_(e_invarg));
1731- goto theend;
1724+ nr = tv_get_number_chk(&argvars[1], &error);
1725+ if (error)
1726+ goto theend; // type error; errmsg already given
1727+ if (nr == 1)
1728+ info.item_compare_ic = TRUE;
1729+ }
1730+ if (nr != 1)
1731+ {
1732+ if (argvars[1].v_type != VAR_NUMBER)
1733+ info.item_compare_func = tv_get_string(&argvars[1]);
1734+ else if (nr != 0)
1735+ {
1736+ emsg(_(e_invarg));
1737+ goto theend;
1738+ }
17321739 }
17331740 if (info.item_compare_func != NULL)
17341741 {
diff -r 36e8e046c335 -r 4ce3906e5997 src/testdir/test_vim9_func.vim
--- a/src/testdir/test_vim9_func.vim Wed Sep 16 22:30:03 2020 +0200
+++ b/src/testdir/test_vim9_func.vim Wed Sep 16 23:30:04 2020 +0200
@@ -1299,6 +1299,11 @@
12991299 res = [1, 2, 3]->sort()
13001300 enddef
13011301
1302+def Test_sort_argument()
1303+ let res = ['b', 'a', 'c']->sort('i')
1304+ res->assert_equal(['a', 'b', 'c'])
1305+enddef
1306+
13021307 def Test_getqflist_return_type()
13031308 let l = getqflist()
13041309 l->assert_equal([])
diff -r 36e8e046c335 -r 4ce3906e5997 src/version.c
--- a/src/version.c Wed Sep 16 22:30:03 2020 +0200
+++ b/src/version.c Wed Sep 16 23:30:04 2020 +0200
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 1701,
755+/**/
754756 1700,
755757 /**/
756758 1699,
Afficher sur ancien navigateur de dépôt.