0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.2435: setline() gives an error for some types

Problem:    setline() gives an error for some types.
Solution:   Allow any type, convert each item to a string.
This commit is contained in:
Bram Moolenaar
2021-01-31 13:08:38 +01:00
parent f2b26bcf8f
commit 3445320839
9 changed files with 96 additions and 20 deletions

View File

@@ -128,7 +128,8 @@ find_win_for_curbuf(void)
}
/*
* Set line or list of lines in buffer "buf".
* Set line or list of lines in buffer "buf" to "lines".
* Any type is allowed and converted to a string.
*/
static void
set_buffer_lines(
@@ -187,7 +188,7 @@ set_buffer_lines(
li = l->lv_first;
}
else
line = tv_get_string_chk(lines);
line = typval_tostring(lines, FALSE);
// default result is zero == OK
for (;;)
@@ -197,7 +198,8 @@ set_buffer_lines(
// list argument, get next string
if (li == NULL)
break;
line = tv_get_string_chk(&li->li_tv);
vim_free(line);
line = typval_tostring(&li->li_tv, FALSE);
li = li->li_next;
}
@@ -238,6 +240,7 @@ set_buffer_lines(
break;
++lnum;
}
vim_free(line);
if (added > 0)
{