diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-02-23 13:17:47 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-02-23 13:17:47 +0000 |
commit | 2007dd49f5cb36f944cab1cfbceb0f864e625f74 (patch) | |
tree | 3269837fb87102d6de40418d1b4ecf7345a43c93 /runtime | |
parent | 6a8b13614e5bcb233d20403ae9f008ccba152be3 (diff) |
patch 8.2.4455: accepting one and zero for second sort() argument is strangev8.2.4455
Problem: Accepting one and zero for the second sort() argument is strange.
Solution: Disallow using one and zero in Vim9 script.
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/builtin.txt | 23 | ||||
-rw-r--r-- | runtime/menu.vim | 4 |
2 files changed, 14 insertions, 13 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index e7707ca0d5..c3bacf940b 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -539,8 +539,8 @@ sin({expr}) Float sine of {expr} sinh({expr}) Float hyperbolic sine of {expr} slice({expr}, {start} [, {end}]) String, List or Blob slice of a String, List or Blob -sort({list} [, {func} [, {dict}]]) - List sort {list}, using {func} to compare +sort({list} [, {how} [, {dict}]]) + List sort {list}, compare with {how} sound_clear() none stop playing all sounds sound_playevent({name} [, {callback}]) Number play an event sound @@ -8033,21 +8033,22 @@ slice({expr}, {start} [, {end}]) *slice()* GetList()->slice(offset) -sort({list} [, {func} [, {dict}]]) *sort()* *E702* +sort({list} [, {how} [, {dict}]]) *sort()* *E702* Sort the items in {list} in-place. Returns {list}. If you want a list to remain unmodified make a copy first: > :let sortedlist = sort(copy(mylist)) -< When {func} is omitted, is empty or zero, then sort() uses the +< When {how} is omitted or is an string, then sort() uses the string representation of each item to sort on. Numbers sort after Strings, |Lists| after Numbers. For sorting text in the current buffer use |:sort|. - When {func} is given and it is '1' or 'i' then case is - ignored. + When {how} is given and it is 'i' then case is ignored. + In legacy script, for backwards compatibility, the value one + can be used to ignore case. Zero means to not ignore case. - When {func} is given and it is 'l' then the current collation + When {how} is given and it is 'l' then the current collation locale is used for ordering. Implementation details: strcoll() is used to compare strings. See |:language| check or set the collation locale. |v:collate| can also be used to check the @@ -8064,19 +8065,19 @@ sort({list} [, {func} [, {dict}]]) *sort()* *E702* < ['n', 'o', 'O', 'p', 'z', 'รถ'] ~ This does not work properly on Mac. - When {func} is given and it is 'n' then all items will be + When {how} is given and it is 'n' then all items will be sorted numerical (Implementation detail: this uses the strtod() function to parse numbers, Strings, Lists, Dicts and Funcrefs will be considered as being 0). - When {func} is given and it is 'N' then all items will be + When {how} is given and it is 'N' then all items will be sorted numerical. This is like 'n' but a string containing digits will be used as the number they represent. - When {func} is given and it is 'f' then all items will be + When {how} is given and it is 'f' then all items will be sorted numerical. All values must be a Number or a Float. - When {func} is a |Funcref| or a function name, this function + When {how} is a |Funcref| or a function name, this function is called to compare items. The function is invoked with two items as argument and must return zero if they are equal, 1 or bigger if the first one sorts after the second one, -1 or diff --git a/runtime/menu.vim b/runtime/menu.vim index 12924af6fb..602c4d5455 100644 --- a/runtime/menu.vim +++ b/runtime/menu.vim @@ -2,7 +2,7 @@ " You can also use this as a start for your own set of menus. " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2022 Feb 04 +" Last Change: 2022 Feb 23 " Note that ":an" (short for ":anoremenu") is often used to make a menu work " in all modes and avoid side effects from mappings defined by the user. @@ -378,7 +378,7 @@ def s:SetupColorSchemes() n += globpath(&packpath, "pack/*/opt/*/colors/*.vim", 1, 1) # Ignore case for VMS and windows, sort on name - var names = sort(map(n, 'substitute(v:val, "\\c.*[/\\\\:\\]]\\([^/\\\\:]*\\)\\.vim", "\\1", "")'), 1) + var names = sort(map(n, 'substitute(v:val, "\\c.*[/\\\\:\\]]\\([^/\\\\:]*\\)\\.vim", "\\1", "")'), 'i') # define all the submenu entries var idx = 100 |