From bc5dfda441dd1b3de56bd64059b0a1df4075f050 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 18 Oct 2023 06:08:14 +0800 Subject: vim-patch:9.0.2041: trim(): hard to use default mask (#25692) 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: vim/vim#13358 https://github.com/vim/vim/commit/8079917447e7436dccc2e4cd4a4a56ae0a4712f2 vim-patch:9.0.2040: trim(): hard to use default mask Problem: trim(): hard to use default mask Solution: Use default 'mask' when it is v:none 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. 'v:none' is already used to mean "use the default argument value" in user defined functions. See |none-function_argument| in help. closes: vim/vim#13363 https://github.com/vim/vim/commit/6e6386716f9494ae86027c6d34f657fd03dfec42 Co-authored-by: Illia Bobyr --- test/old/testdir/test_functions.vim | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test') diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim index 9448ff21aa..eae9c03335 100644 --- a/test/old/testdir/test_functions.vim +++ b/test/old/testdir/test_functions.vim @@ -2099,6 +2099,10 @@ func Test_trim() 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, '', 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 -- cgit