aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer_updates.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/buffer_updates.c')
-rw-r--r--src/nvim/buffer_updates.c68
1 files changed, 31 insertions, 37 deletions
diff --git a/src/nvim/buffer_updates.c b/src/nvim/buffer_updates.c
index 1d131cc4b1..ee1b7ebc95 100644
--- a/src/nvim/buffer_updates.c
+++ b/src/nvim/buffer_updates.c
@@ -1,14 +1,14 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+#include "nvim/api/private/helpers.h"
+#include "nvim/assert.h"
+#include "nvim/buffer.h"
#include "nvim/buffer_updates.h"
#include "nvim/extmark.h"
+#include "nvim/lua/executor.h"
#include "nvim/memline.h"
-#include "nvim/api/private/helpers.h"
#include "nvim/msgpack_rpc/channel.h"
-#include "nvim/lua/executor.h"
-#include "nvim/assert.h"
-#include "nvim/buffer.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "buffer_updates.c.generated.h"
@@ -17,8 +17,7 @@
// 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
// unloaded.
-bool buf_updates_register(buf_T *buf, uint64_t channel_id,
- BufUpdateCallbacks cb, bool send_buffer)
+bool buf_updates_register(buf_T *buf, uint64_t channel_id, BufUpdateCallbacks cb, bool send_buffer)
{
// must fail if the buffer isn't loaded
if (buf->b_ml.ml_mfp == NULL) {
@@ -86,16 +85,16 @@ bool buf_updates_register(buf_T *buf, uint64_t channel_id,
bool buf_updates_active(buf_T *buf)
{
- return kv_size(buf->update_channels) || kv_size(buf->update_callbacks);
+ return kv_size(buf->update_channels) || kv_size(buf->update_callbacks);
}
void buf_updates_send_end(buf_T *buf, uint64_t channelid)
{
- Array args = ARRAY_DICT_INIT;
- args.size = 1;
- args.items = xcalloc(args.size, sizeof(Object));
- args.items[0] = BUFFER_OBJ(buf->handle);
- rpc_send_event(channelid, "nvim_buf_detach_event", args);
+ Array args = ARRAY_DICT_INIT;
+ args.size = 1;
+ args.items = xcalloc(args.size, sizeof(Object));
+ args.items[0] = BUFFER_OBJ(buf->handle);
+ rpc_send_event(channelid, "nvim_buf_detach_event", args);
}
void buf_updates_unregister(buf_T *buf, uint64_t channelid)
@@ -187,11 +186,8 @@ void buf_updates_unload(buf_T *buf, bool can_reload)
}
-void buf_updates_send_changes(buf_T *buf,
- linenr_T firstline,
- int64_t num_added,
- int64_t num_removed,
- bool send_tick)
+void buf_updates_send_changes(buf_T *buf, linenr_T firstline, int64_t num_added,
+ int64_t num_removed, bool send_tick)
{
size_t deleted_codepoints, deleted_codeunits;
size_t deleted_bytes = ml_flush_deleted_bytes(buf, &deleted_codepoints,
@@ -228,11 +224,11 @@ void buf_updates_send_changes(buf_T *buf,
// linedata of lines being swapped in
Array linedata = ARRAY_DICT_INIT;
if (num_added > 0) {
- STATIC_ASSERT(SIZE_MAX >= MAXLNUM, "size_t smaller than MAXLNUM");
- linedata.size = (size_t)num_added;
- linedata.items = xcalloc((size_t)num_added, sizeof(Object));
- buf_collect_lines(buf, (size_t)num_added, firstline, true, &linedata,
- NULL);
+ STATIC_ASSERT(SIZE_MAX >= MAXLNUM, "size_t smaller than MAXLNUM");
+ linedata.size = (size_t)num_added;
+ linedata.items = xcalloc((size_t)num_added, sizeof(Object));
+ buf_collect_lines(buf, (size_t)num_added, firstline, true, &linedata,
+ NULL);
}
args.items[4] = ARRAY_OBJ(linedata);
args.items[5] = BOOLEAN_OBJ(false);
@@ -248,7 +244,7 @@ void buf_updates_send_changes(buf_T *buf,
// change notifications are so frequent that many dead channels will be
// cleared up quickly.
if (badchannelid != 0) {
- ELOG("Disabling buffer updates for dead channel %"PRIu64, badchannelid);
+ ELOG("Disabling buffer updates for dead channel %" PRIu64, badchannelid);
buf_updates_unregister(buf, badchannelid);
}
@@ -302,11 +298,9 @@ void buf_updates_send_changes(buf_T *buf,
kv_size(buf->update_callbacks) = j;
}
-void buf_updates_send_splice(
- buf_T *buf,
- int start_row, colnr_T start_col, bcount_t start_byte,
- int old_row, colnr_T old_col, bcount_t old_byte,
- int new_row, colnr_T new_col, bcount_t new_byte)
+void buf_updates_send_splice(buf_T *buf, int start_row, colnr_T start_col, bcount_t start_byte,
+ int old_row, colnr_T old_col, bcount_t old_byte, int new_row,
+ colnr_T new_col, bcount_t new_byte)
{
if (!buf_updates_active(buf)
|| (old_byte == 0 && new_byte == 0)) {
@@ -392,18 +386,18 @@ void buf_updates_changedtick(buf_T *buf)
void buf_updates_changedtick_single(buf_T *buf, uint64_t channel_id)
{
- Array args = ARRAY_DICT_INIT;
- args.size = 2;
- args.items = xcalloc(args.size, sizeof(Object));
+ Array args = ARRAY_DICT_INIT;
+ args.size = 2;
+ args.items = xcalloc(args.size, sizeof(Object));
- // the first argument is always the buffer handle
- args.items[0] = BUFFER_OBJ(buf->handle);
+ // the first argument is always the buffer handle
+ args.items[0] = BUFFER_OBJ(buf->handle);
- // next argument is b:changedtick
- args.items[1] = INTEGER_OBJ(buf_get_changedtick(buf));
+ // next argument is b:changedtick
+ args.items[1] = INTEGER_OBJ(buf_get_changedtick(buf));
- // don't try and clean up dead channels here
- rpc_send_event(channel_id, "nvim_buf_changedtick_event", args);
+ // don't try and clean up dead channels here
+ rpc_send_event(channel_id, "nvim_buf_changedtick_event", args);
}
void buffer_update_callbacks_free(BufUpdateCallbacks cb)