diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-10-18 06:08:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-18 06:08:14 +0800 |
commit | bc5dfda441dd1b3de56bd64059b0a1df4075f050 (patch) | |
tree | a6df1b29b2ae8ee8d5e43b2154f61d5d6aa7ab7f /runtime/lua/vim/_meta/vimfn.lua | |
parent | 3fd7449d5abe9a75fed8fb6b68c5958bd1a9ee12 (diff) | |
download | rneovim-bc5dfda441dd1b3de56bd64059b0a1df4075f050.tar.gz rneovim-bc5dfda441dd1b3de56bd64059b0a1df4075f050.tar.bz2 rneovim-bc5dfda441dd1b3de56bd64059b0a1df4075f050.zip |
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 <illia.bobyr@gmail.com>
Diffstat (limited to 'runtime/lua/vim/_meta/vimfn.lua')
-rw-r--r-- | runtime/lua/vim/_meta/vimfn.lua | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index 2b79feec8e..2c594e049f 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -9845,15 +9845,18 @@ function vim.fn.tr(src, fromstr, tostr) end --- Return {text} as a String where any character in {mask} is --- removed from the beginning and/or end of {text}. ---- If {mask} is not given, {mask} is all characters up to 0x20, ---- which includes Tab, space, NL and CR, plus the non-breaking ---- space character 0xa0. +--- +--- If {mask} is not given, or is an empty string, {mask} is all +--- characters up to 0x20, which includes Tab, space, NL and CR, +--- plus the non-breaking space character 0xa0. +--- --- The optional {dir} argument specifies where to remove the --- characters: --- 0 remove from the beginning and end of {text} --- 1 remove only at the beginning of {text} --- 2 remove only at the end of {text} --- When omitted both ends are trimmed. +--- --- This function deals with multibyte characters properly. --- Returns an empty string on error. --- |