mirror of
https://github.com/neovim/neovim.git
synced 2024-12-31 17:13:26 -07:00
eval/typval,api/buffer: Fix review comments
This commit is contained in:
parent
58e34e8d99
commit
114eaa15f0
@ -296,7 +296,7 @@ void nvim_buf_set_lines(uint64_t channel_id,
|
|||||||
tabpage_T *save_curtab = NULL;
|
tabpage_T *save_curtab = NULL;
|
||||||
size_t new_len = replacement.size;
|
size_t new_len = replacement.size;
|
||||||
size_t old_len = (size_t)(end - start);
|
size_t old_len = (size_t)(end - start);
|
||||||
ssize_t extra = 0; // lines added to text, can be negative
|
ptrdiff_t extra = 0; // lines added to text, can be negative
|
||||||
char **lines = (new_len != 0) ? xcalloc(new_len, sizeof(char *)) : NULL;
|
char **lines = (new_len != 0) ? xcalloc(new_len, sizeof(char *)) : NULL;
|
||||||
|
|
||||||
for (size_t i = 0; i < new_len; i++) {
|
for (size_t i = 0; i < new_len; i++) {
|
||||||
@ -342,8 +342,8 @@ void nvim_buf_set_lines(uint64_t channel_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ssize_t)to_delete > 0) {
|
if (to_delete > 0) {
|
||||||
extra -= (ssize_t)to_delete;
|
extra -= (ptrdiff_t)to_delete;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For as long as possible, replace the existing old_len with the
|
// For as long as possible, replace the existing old_len with the
|
||||||
|
@ -164,9 +164,8 @@ void tv_list_free_contents(list_T *const l)
|
|||||||
}
|
}
|
||||||
l->lv_len = 0;
|
l->lv_len = 0;
|
||||||
l->lv_idx_item = NULL;
|
l->lv_idx_item = NULL;
|
||||||
for (listwatch_T *lw = l->lv_watch; lw != NULL; lw = lw->lw_next) {
|
l->lv_last = NULL;
|
||||||
lw->lw_item = NULL;
|
assert(l->lv_watch == NULL);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Free a list itself, ignoring items it contains
|
/// Free a list itself, ignoring items it contains
|
||||||
@ -230,13 +229,10 @@ void tv_list_remove_items(list_T *const l, listitem_T *const item,
|
|||||||
listitem_T *const item2)
|
listitem_T *const item2)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
// notify watchers
|
// Notify watchers.
|
||||||
for (listitem_T *ip = item; ip != NULL; ip = ip->li_next) {
|
for (listitem_T *ip = item; ip != item2->li_next; ip = ip->li_next) {
|
||||||
l->lv_len--;
|
l->lv_len--;
|
||||||
tv_list_watch_fix(l, ip);
|
tv_list_watch_fix(l, ip);
|
||||||
if (ip == item2) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item2->li_next == NULL) {
|
if (item2->li_next == NULL) {
|
||||||
|
@ -255,6 +255,9 @@ describe('typval.c', function()
|
|||||||
eq({lis[3], lis[5], nil}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil})
|
eq({lis[3], lis[5], nil}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil})
|
||||||
|
|
||||||
alloc_log:clear()
|
alloc_log:clear()
|
||||||
|
lib.tv_list_watch_remove(l, lws[2])
|
||||||
|
lib.tv_list_watch_remove(l, lws[3])
|
||||||
|
lib.tv_list_watch_remove(l, lws[1])
|
||||||
lib.tv_list_free(l)
|
lib.tv_list_free(l)
|
||||||
alloc_log:check({
|
alloc_log:check({
|
||||||
a.freed(lis[3]),
|
a.freed(lis[3]),
|
||||||
|
Loading…
Reference in New Issue
Block a user