aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-22 18:21:15 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-08-22 18:56:43 +0800
commit09910d5b35f2432a22374e59560a1bbd08907d57 (patch)
tree8e87414d2294f68ecb7f9865213f2096633702a7 /src/nvim/eval.lua
parent48722ec400eff53baa5f7bdf0aa5e933e20fb0f4 (diff)
downloadrneovim-09910d5b35f2432a22374e59560a1bbd08907d57.tar.gz
rneovim-09910d5b35f2432a22374e59560a1bbd08907d57.tar.bz2
rneovim-09910d5b35f2432a22374e59560a1bbd08907d57.zip
vim-patch:9.0.0837: append() reports failure when not appending anything
Problem: append() reports failure when not appending anything. Solution: Only report failure when appending something. (closes vim/vim#11498) https://github.com/vim/vim/commit/cd9c8d400c1eb9cbb4ff6a33be02f91a30ab13b2 Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/eval.lua')
-rw-r--r--src/nvim/eval.lua16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index f6ccc803c0..886887dedb 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -141,7 +141,8 @@ M.funcs = {
{lnum} can be zero to insert a line before the first one.
{lnum} is used like with |getline()|.
Returns 1 for failure ({lnum} out of range or out of memory),
- 0 for success. Example: >vim
+ 0 for success. When {text} is an empty list zero is returned,
+ no matter the value of {lnum}. Example: >vim
let failed = append(line('$'), "# THE END")
let failed = append(0, ["Chapter 1", "the beginning"])
<
@@ -173,7 +174,8 @@ M.funcs = {
If {buf} is not a valid buffer or {lnum} is not valid, an
error message is given. Example: >vim
let failed = appendbufline(13, 0, "# THE START")
- <
+ <However, when {text} is an empty list then no error is given
+ for an invalid {lnum}, since {lnum} isn't actually used.
]=],
name = 'appendbufline',
@@ -8871,9 +8873,10 @@ M.funcs = {
To insert lines use |appendbufline()|.
- {text} can be a string to set one line, or a list of strings
- to set multiple lines. If the list extends below the last
- line then those lines are added.
+ {text} can be a string to set one line, or a List of strings
+ to set multiple lines. If the List extends below the last
+ line then those lines are added. If the List is empty then
+ nothing is changed and zero is returned.
For the use of {buf}, see |bufname()| above.
@@ -9117,7 +9120,8 @@ M.funcs = {
When {lnum} is just below the last line the {text} will be
added below the last line.
{text} can be any type or a List of any type, each item is
- converted to a String.
+ converted to a String. When {text} is an empty List then
+ nothing is changed and FALSE is returned.
If this succeeds, FALSE is returned. If this fails (most likely
because {lnum} is invalid) TRUE is returned.