mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
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 #11498)
This commit is contained in:
@@ -175,9 +175,7 @@ set_buffer_lines(
|
||||
l = lines->vval.v_list;
|
||||
if (l == NULL || 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 done;
|
||||
}
|
||||
CHECK_LIST_MATERIALIZE(l);
|
||||
|
@@ -23,8 +23,8 @@ func Test_setbufline_getbufline()
|
||||
|
||||
call assert_equal(1, setbufline(b, 5, 'x'))
|
||||
call assert_equal(1, setbufline(b, 5, ['x']))
|
||||
call assert_equal(1, setbufline(b, 5, []))
|
||||
call assert_equal(1, setbufline(b, 5, test_null_list()))
|
||||
call assert_equal(0, setbufline(b, 5, []))
|
||||
call assert_equal(0, setbufline(b, 5, test_null_list()))
|
||||
|
||||
call assert_equal(1, 'x'->setbufline(bufnr('$') + 1, 1))
|
||||
call assert_equal(1, ['x']->setbufline(bufnr('$') + 1, 1))
|
||||
@@ -86,6 +86,11 @@ func Test_setline_startup()
|
||||
sleep 50m
|
||||
call assert_equal(['Hello'], readfile('Xtest'))
|
||||
|
||||
call assert_equal(0, setline(1, []))
|
||||
call assert_equal(0, setline(1, test_null_list()))
|
||||
call assert_equal(0, setline(5, []))
|
||||
call assert_equal(0, setline(6, test_null_list()))
|
||||
|
||||
call delete('Xtest')
|
||||
endfunc
|
||||
|
||||
@@ -112,8 +117,8 @@ func Test_appendbufline()
|
||||
|
||||
call assert_equal(1, appendbufline(b, 4, 'x'))
|
||||
call assert_equal(1, appendbufline(b, 4, ['x']))
|
||||
call assert_equal(1, appendbufline(b, 4, []))
|
||||
call assert_equal(1, appendbufline(b, 4, test_null_list()))
|
||||
call assert_equal(0, appendbufline(b, 4, []))
|
||||
call assert_equal(0, appendbufline(b, 4, test_null_list()))
|
||||
|
||||
call assert_equal(1, appendbufline(1234, 1, 'x'))
|
||||
call assert_equal(1, appendbufline(1234, 1, ['x']))
|
||||
@@ -122,8 +127,8 @@ func Test_appendbufline()
|
||||
|
||||
call assert_equal(0, appendbufline(b, 1, []))
|
||||
call assert_equal(0, appendbufline(b, 1, test_null_list()))
|
||||
call assert_equal(1, appendbufline(b, 3, []))
|
||||
call assert_equal(1, appendbufline(b, 3, test_null_list()))
|
||||
call assert_equal(0, appendbufline(b, 3, []))
|
||||
call assert_equal(0, appendbufline(b, 3, test_null_list()))
|
||||
|
||||
call assert_equal(['a', 'b', 'c'], getbufline(b, 1, '$'))
|
||||
|
||||
|
@@ -939,9 +939,13 @@ endfunc
|
||||
func Test_append()
|
||||
enew!
|
||||
split
|
||||
call append(0, ["foo"])
|
||||
call append(1, [])
|
||||
call append(1, test_null_list())
|
||||
call assert_equal(0, append(1, []))
|
||||
call assert_equal(0, append(1, test_null_list()))
|
||||
call assert_equal(0, append(0, ["foo"]))
|
||||
call assert_equal(0, append(1, []))
|
||||
call assert_equal(0, append(1, test_null_list()))
|
||||
call assert_equal(0, append(8, []))
|
||||
call assert_equal(0, append(9, test_null_list()))
|
||||
call assert_equal(['foo', ''], getline(1, '$'))
|
||||
split
|
||||
only
|
||||
|
@@ -3721,8 +3721,8 @@ def Test_set_get_bufline()
|
||||
|
||||
assert_equal(1, setbufline(b, 5, 'x'))
|
||||
assert_equal(1, setbufline(b, 5, ['x']))
|
||||
assert_equal(1, setbufline(b, 5, []))
|
||||
assert_equal(1, setbufline(b, 5, test_null_list()))
|
||||
assert_equal(0, setbufline(b, 5, []))
|
||||
assert_equal(0, setbufline(b, 5, test_null_list()))
|
||||
|
||||
assert_equal(1, 'x'->setbufline(bufnr('$') + 1, 1))
|
||||
assert_equal(1, ['x']->setbufline(bufnr('$') + 1, 1))
|
||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
837,
|
||||
/**/
|
||||
836,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user