patch 9.0.2041: trim(): hard to use default mask
Problem: trim(): hard to use default mask (partly revert v9.0.2040)
Solution: use default mask when it is empty
The default 'mask' value is pretty complex, as it includes many
characters. Yet, if one needs to specify the trimming direction, the
third argument, 'trim()' currently requires the 'mask' value to be
provided explicitly.
Currently, an empty 'mask' will make 'trim()' call return 'text' value
that is passed in unmodified. It is unlikely that someone is using it,
so the chances of scripts being broken by this change are low.
Also, this reverts commit 9.0.2040 (which uses v:none for the default
and requires to use an empty string instead).
closes: #13358
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Illia Bobyr <illia.bobyr@gmail.com>
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index 85d1d22..49b688c 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -2231,14 +2231,14 @@
call assert_fails('eval trim(" vim ", " ", [])', 'E745:')
call assert_fails('eval trim(" vim ", " ", -1)', 'E475:')
call assert_fails('eval trim(" vim ", " ", 3)', 'E475:')
- call assert_fails('eval trim(" vim ", 0)', 'E1393:')
+ call assert_fails('eval trim(" vim ", 0)', 'E1174:')
let chars = join(map(range(1, 0x20) + [0xa0], {n -> n->nr2char()}), '')
call assert_equal("x", trim(chars . "x" . chars))
- call assert_equal("x", trim(chars . "x" . chars, v:none, 0))
- call assert_equal("x" . chars, trim(chars . "x" . chars, v:none, 1))
- call assert_equal(chars . "x", trim(chars . "x" . chars, v:none, 2))
+ call assert_equal("x", trim(chars . "x" . chars, '', 0))
+ call assert_equal("x" . chars, trim(chars . "x" . chars, '', 1))
+ call assert_equal(chars . "x", trim(chars . "x" . chars, '', 2))
call assert_fails('let c=trim([])', 'E730:')
endfunc