diff options
author | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2024-02-28 22:48:12 +0100 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-02-28 22:49:03 +0100 |
commit | 19b718828d8d5fab52d94c6cdba694641879ab38 (patch) | |
tree | 4683fa9c3cc05d02bc5e70ea5c58b2204b0de6ff /src/testdir/test_vim9_builtin.vim | |
parent | d0d4adb609064d6ca4fce111a09c2cbbcdef1cf1 (diff) |
patch 9.1.0142: getregion() can be improvedv9.1.0142
Problem: getregion() can be improved (after v9.1.120)
Solution: change getregion() implementation to use pos as lists and
one optional {opt} dictionary (Shougo Matsushita)
Note: The following is a breaking change!
Currently, the getregion() function (included as of patch v9.1.120) takes
3 arguments: the first 2 arguments are strings, describing a position,
arg3 is the type string.
However, that is slightly inflexible, there is no way to specify
additional arguments. So let's instead change the function signature to:
getregion(pos1, pos2 [, {Dict}]) where both pos1 and pos2 are lists.
This is slightly cleaner, and gives us the flexibility to specify
additional arguments as key/value pairs to the optional Dict arg.
Now it supports the "type" key to specify the selection type
(characterwise, blockwise or linewise) and now in addition one can also
define the selection type, independently of what the 'selection' option
actually is.
Technically, this is a breaking change, but since the getregion()
Vimscript function is still quite new, this should be fine.
closes: #14090
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/testdir/test_vim9_builtin.vim')
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index e2585d4f69..afb8cb9100 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -5198,12 +5198,11 @@ def Test_passing_type_to_builtin() enddef def Test_getregion() - assert_equal(['x'], getregion('.', '.', 'v')->map((_, _) => 'x')) + assert_equal(['x'], getregion(getpos('.'), getpos('.'))->map((_, _) => 'x')) - v9.CheckDefAndScriptFailure(['getregion(10, ".", "v")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - assert_equal([''], getregion('.', '.', 'v')) - v9.CheckDefExecFailure(['getregion("a", ".", "v")'], 'E1209:') - v9.CheckDefExecAndScriptFailure(['getregion("", ".", "v")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['getregion(10, getpos("."))'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1211: List required for argument 1']) + assert_equal([''], getregion(getpos('.'), getpos('.'))) + v9.CheckDefExecFailure(['getregion(getpos("a"), getpos("."))'], 'E1209:') enddef " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |