mirror of
https://github.com/neovim/neovim.git
synced 2025-09-11 13:58:18 +00:00
Enable -Wconversion
This commit is contained in:
@@ -142,7 +142,6 @@ set(CONV_SOURCES
|
|||||||
message.c
|
message.c
|
||||||
regexp.c
|
regexp.c
|
||||||
screen.c
|
screen.c
|
||||||
buffer_updates.c
|
|
||||||
search.c
|
search.c
|
||||||
spell.c
|
spell.c
|
||||||
spellfile.c
|
spellfile.c
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#include "nvim/memline.h"
|
#include "nvim/memline.h"
|
||||||
#include "nvim/api/private/helpers.h"
|
#include "nvim/api/private/helpers.h"
|
||||||
#include "nvim/msgpack_rpc/channel.h"
|
#include "nvim/msgpack_rpc/channel.h"
|
||||||
|
#include "nvim/assert.h"
|
||||||
|
|
||||||
// Register a channel. Return True if the channel was added, or already added.
|
// Register a channel. Return True if the channel was added, or already added.
|
||||||
// Return False if the channel couldn't be added because the buffer is
|
// Return False if the channel couldn't be added because the buffer is
|
||||||
@@ -30,7 +31,10 @@ bool buffer_updates_register(buf_T *buf, uint64_t channel_id, bool send_buffer)
|
|||||||
Array linedata = ARRAY_DICT_INIT;
|
Array linedata = ARRAY_DICT_INIT;
|
||||||
if (send_buffer) {
|
if (send_buffer) {
|
||||||
// collect buffer contents
|
// collect buffer contents
|
||||||
size_t line_count = buf->b_ml.ml_line_count;
|
// True now, but a compile time reminder for future systems we support
|
||||||
|
STATIC_ASSERT(SIZE_MAX >= MAXLNUM, "size_t to small to hold the number of"
|
||||||
|
" lines in a buffer");
|
||||||
|
size_t line_count = (size_t)buf->b_ml.ml_line_count;
|
||||||
linedata.size = line_count;
|
linedata.size = line_count;
|
||||||
linedata.items = xcalloc(sizeof(Object), line_count);
|
linedata.items = xcalloc(sizeof(Object), line_count);
|
||||||
for (size_t i = 0; i < line_count; i++) {
|
for (size_t i = 0; i < line_count; i++) {
|
||||||
@@ -118,8 +122,11 @@ void buffer_updates_unregister_all(buf_T *buf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void buffer_updates_send_changes(buf_T *buf, linenr_T firstline, int64_t num_added,
|
void buffer_updates_send_changes(buf_T *buf,
|
||||||
int64_t num_removed, bool send_tick)
|
linenr_T firstline,
|
||||||
|
int64_t num_added,
|
||||||
|
int64_t num_removed,
|
||||||
|
bool send_tick)
|
||||||
{
|
{
|
||||||
// if one the channels doesn't work, put its ID here so we can remove it later
|
// if one the channels doesn't work, put its ID here so we can remove it later
|
||||||
uint64_t badchannelid = 0;
|
uint64_t badchannelid = 0;
|
||||||
@@ -148,8 +155,13 @@ void buffer_updates_send_changes(buf_T *buf, linenr_T firstline, int64_t num_add
|
|||||||
// linedata of lines being swapped in
|
// linedata of lines being swapped in
|
||||||
Array linedata = ARRAY_DICT_INIT;
|
Array linedata = ARRAY_DICT_INIT;
|
||||||
if (num_added > 0) {
|
if (num_added > 0) {
|
||||||
linedata.size = num_added;
|
// True now, but a compile time reminder for future systems we support
|
||||||
linedata.items = xcalloc(sizeof(Object), num_added);
|
// Note that `num_added` is a `int64_t`, but still must be lower than
|
||||||
|
// `MAX_LNUM`
|
||||||
|
STATIC_ASSERT(SIZE_MAX >= MAXLNUM, "size_t to small to hold the number "
|
||||||
|
"of lines in a buffer");
|
||||||
|
linedata.size = (size_t)num_added;
|
||||||
|
linedata.items = xcalloc(sizeof(Object), (size_t)num_added);
|
||||||
for (int64_t i = 0; i < num_added; i++) {
|
for (int64_t i = 0; i < num_added; i++) {
|
||||||
int64_t lnum = firstline + i;
|
int64_t lnum = firstline + i;
|
||||||
const char *bufstr = (char *)ml_get_buf(buf, (linenr_T)lnum, false);
|
const char *bufstr = (char *)ml_get_buf(buf, (linenr_T)lnum, false);
|
||||||
|
@@ -1,13 +1,16 @@
|
|||||||
#ifndef BUFFER_UPDATES_H
|
#ifndef NVIM_BUFFER_UPDATES_H
|
||||||
#define BUFFER_UPDATES_H
|
#define NVIM_BUFFER_UPDATES_H
|
||||||
|
|
||||||
#include "nvim/buffer_defs.h"
|
#include "nvim/buffer_defs.h"
|
||||||
|
|
||||||
bool buffer_updates_register(buf_T *buf, uint64_t channel_id, bool send_buffer);
|
bool buffer_updates_register(buf_T *buf, uint64_t channel_id, bool send_buffer);
|
||||||
void buffer_updates_unregister(buf_T *buf, uint64_t channel_id);
|
void buffer_updates_unregister(buf_T *buf, uint64_t channel_id);
|
||||||
void buffer_updates_unregister_all(buf_T *buf);
|
void buffer_updates_unregister_all(buf_T *buf);
|
||||||
void buffer_updates_send_changes(buf_T *buf, linenr_T firstline, int64_t num_added,
|
void buffer_updates_send_changes(buf_T *buf,
|
||||||
int64_t num_removed, bool send_tick);
|
linenr_T firstline,
|
||||||
|
int64_t num_added,
|
||||||
|
int64_t num_removed,
|
||||||
|
bool send_tick);
|
||||||
void buffer_updates_send_tick(buf_T *buf);
|
void buffer_updates_send_tick(buf_T *buf);
|
||||||
|
|
||||||
#endif // NVIM_BUFFER_UPDATES_H
|
#endif // NVIM_BUFFER_UPDATES_H
|
||||||
|
@@ -1607,8 +1607,8 @@ static void foldCreateMarkers(linenr_T start, linenr_T end)
|
|||||||
|
|
||||||
if (kv_size(curbuf->update_channels)) {
|
if (kv_size(curbuf->update_channels)) {
|
||||||
// Note: foldAddMarker() may not actually change start and/or end if
|
// Note: foldAddMarker() may not actually change start and/or end if
|
||||||
// u_save() is unable to save the buffer line, but we send the nvim_buf_update
|
// u_save() is unable to save the buffer line, but we send the
|
||||||
// anyway since it won't do any harm.
|
// nvim_buf_update anyway since it won't do any harm.
|
||||||
int64_t num_changed = 1 + end - start;
|
int64_t num_changed = 1 + end - start;
|
||||||
buffer_updates_send_changes(curbuf, start, num_changed, num_changed, true);
|
buffer_updates_send_changes(curbuf, start, num_changed, num_changed, true);
|
||||||
}
|
}
|
||||||
|
@@ -1698,8 +1698,8 @@ bool u_undo_and_forget(int count)
|
|||||||
count = 1;
|
count = 1;
|
||||||
}
|
}
|
||||||
undo_undoes = true;
|
undo_undoes = true;
|
||||||
// don't send a nvim_buf_update for this undo is part of 'inccommand' playing with
|
// don't send a nvim_buf_update for this undo is part of 'inccommand' playing
|
||||||
// buffer contents
|
// with buffer contents
|
||||||
u_doit(count, true, false);
|
u_doit(count, true, false);
|
||||||
|
|
||||||
if (curbuf->b_u_curhead == NULL) {
|
if (curbuf->b_u_curhead == NULL) {
|
||||||
|
Reference in New Issue
Block a user