From 09910d5b35f2432a22374e59560a1bbd08907d57 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 22 Aug 2023 18:21:15 +0800 Subject: 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 --- src/nvim/eval.lua | 16 ++++++++++------ src/nvim/eval/buffer.c | 5 +---- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'src') 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") - < + v_type == VAR_LIST) { l = lines->vval.v_list; if (l == NULL || tv_list_len(l) == 0) { - // set proper return code - if (lnum > curbuf->b_ml.ml_line_count) { - rettv->vval.v_number = 1; // FAIL - } + // not appending anything always succeeds goto cleanup; } li = tv_list_first(l); -- cgit