aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKillTheMule <KillTheMule@users.noreply.github.com>2018-04-24 20:38:00 +0200
committerKillTheMule <KillTheMule@users.noreply.github.com>2018-05-23 22:07:27 +0200
commite7451f8a91e0a9452fc3c3627ac60dc80288252c (patch)
treedf606b41f1cf56b8eeb05671ae8e9eb3f136601c
parentde5d1e863c71c8da87422bdb94dc91749d4a8b61 (diff)
downloadrneovim-e7451f8a91e0a9452fc3c3627ac60dc80288252c.tar.gz
rneovim-e7451f8a91e0a9452fc3c3627ac60dc80288252c.tar.bz2
rneovim-e7451f8a91e0a9452fc3c3627ac60dc80288252c.zip
Some renamings and doc changes
-rw-r--r--runtime/doc/msgpack_rpc.txt22
-rw-r--r--src/nvim/api/buffer.c4
-rw-r--r--src/nvim/buffer.c4
-rw-r--r--src/nvim/buffer_updates.c20
-rw-r--r--src/nvim/buffer_updates.h10
-rw-r--r--src/nvim/ex_cmds.c13
-rw-r--r--src/nvim/fold.c4
-rw-r--r--src/nvim/misc1.c8
-rw-r--r--src/nvim/undo.c35
-rw-r--r--test/functional/api/buffer_updates_spec.lua20
10 files changed, 72 insertions, 68 deletions
diff --git a/runtime/doc/msgpack_rpc.txt b/runtime/doc/msgpack_rpc.txt
index 0b0e774d33..9ebebb8d61 100644
--- a/runtime/doc/msgpack_rpc.txt
+++ b/runtime/doc/msgpack_rpc.txt
@@ -255,16 +255,16 @@ The co-process will start receiving the following notification events:
nvim_buf_updates_start[{buf}, {changedtick}, {linedata}, {more}] *nvim_buf_updates_start*
- Neovim will send at least one of these notifications to confirm that
- buffer updates are registered for this plugin, and possibly send the buffer's
- contents. If the buffer is very large, neovim might send the contents through
- in multiple events to avoid loading the entire buffer's contents into
- memory at once.
+ Nvim will send at least one of these notifications to confirm that buffer
+ updates are registered for this plugin, and possibly send the buffer's
+ contents. If the buffer is very large, nvim might send the contents
+ through in multiple events to avoid loading the entire buffer's contents
+ into memory at once.
{buf} is an API handle for the buffer.
{changedtick} is the value of |b:changedtick| for the buffer. If you
- send an API command back to neovim you can check the value of
+ send an API command back to nvim you can check the value of
|b:changedtick| as part of your request to ensure that no other
changes have been made.
@@ -279,9 +279,9 @@ nvim_buf_updates_start[{buf}, {changedtick}, {linedata}, {more}] *nvim_buf_upda
will be empty.
{linedata} will always have at least 1 item, but the maximum length is
- determined by neovim and not guaranteed to be any particular size. Also the
+ determined by nvim and not guaranteed to be any particular size. Also the
number of {linedata} items may vary between notifications, so your plugin
- must be prepared to receive the line data in whatever size lists neovim
+ must be prepared to receive the line data in whatever size lists nvim
decides to split it into.
{more} is a boolean which tells you whether or not to expect more
@@ -298,7 +298,7 @@ nvim_buf_update[{buf}, {changedtick}, {firstline}, {lastline}, {linedata}] *nvim
{buf} is an API handle for the buffer.
{changedtick} is the value of |b:changedtick| for the buffer. If you send an
- API command back to neovim you can check the value of |b:changedtick| as
+ API command back to nvim you can check the value of |b:changedtick| as
part of your request to ensure that no other changes have been made.
{firstline} is the integer line number of the first line that was replaced.
@@ -324,7 +324,7 @@ nvim_buf_update[{buf}, {changedtick}, {firstline}, {lastline}, {linedata}] *nvim
doesn't reflect the actual buffer contents. Currently this behaviour is
only used for the 'inccommand' option.
-nvim_buf_update_tick[{buf}, {changedtick}] *nvim_buf_update_tick*
+nvim_buf_changedtick[{buf}, {changedtick}] *nvim_buf_changedtick*
Indicates that |b:changedtick| was incremented for the buffer {buf}, but no
text was changed. This is currently only used by undo/redo.
@@ -349,7 +349,7 @@ the buffer contents are unloaded from memory:
- Closing all a buffer's windows (unless 'hidden' is enabled).
- Using |:edit| to reload the buffer
- - reloading the buffer after it is changed from outside neovim.
+ - reloading the buffer after it is changed from outside nvim.
*buffer-updates-examples*
Examples~
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index f6a6534560..756367f801 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -96,7 +96,7 @@ Boolean nvim_buf_attach(uint64_t channel_id,
return false;
}
- return buffer_updates_register(buf, channel_id, send_buffer);
+ return buf_updates_register(buf, channel_id, send_buffer);
}
//
/// Deactivate updates from this buffer to the current channel.
@@ -116,7 +116,7 @@ Boolean nvim_buf_detach(uint64_t channel_id,
return false;
}
- buffer_updates_unregister(buf, channel_id);
+ buf_updates_unregister(buf, channel_id);
return true;
}
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index e5b7128248..af77a9891b 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -576,7 +576,7 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last)
do_autochdir();
// disable live updates for the current buffer
- buffer_updates_unregister_all(buf);
+ buf_updates_unregister_all(buf);
/*
* Remove the buffer from the list.
@@ -789,7 +789,7 @@ free_buffer_stuff (
xfree(buf->b_start_fenc);
buf->b_start_fenc = NULL;
- buffer_updates_unregister_all(buf);
+ buf_updates_unregister_all(buf);
}
/*
diff --git a/src/nvim/buffer_updates.c b/src/nvim/buffer_updates.c
index 3d0c969491..830c1bfe7b 100644
--- a/src/nvim/buffer_updates.c
+++ b/src/nvim/buffer_updates.c
@@ -7,7 +7,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 buffer_updates_register(buf_T *buf, uint64_t channel_id, bool send_buffer)
+bool buf_updates_register(buf_T *buf, uint64_t channel_id, bool send_buffer)
{
// must fail if the buffer isn't loaded
if (buf->b_ml.ml_mfp == NULL) {
@@ -64,7 +64,7 @@ bool buffer_updates_register(buf_T *buf, uint64_t channel_id, bool send_buffer)
return true;
}
-void buffer_updates_send_end(buf_T *buf, uint64_t channelid)
+void buf_updates_send_end(buf_T *buf, uint64_t channelid)
{
Array args = ARRAY_DICT_INIT;
args.size = 1;
@@ -73,7 +73,7 @@ void buffer_updates_send_end(buf_T *buf, uint64_t channelid)
rpc_send_event(channelid, "nvim_buf_updates_end", args);
}
-void buffer_updates_unregister(buf_T *buf, uint64_t channelid)
+void buf_updates_unregister(buf_T *buf, uint64_t channelid)
{
size_t size = kv_size(buf->update_channels);
if (!size) {
@@ -101,7 +101,7 @@ void buffer_updates_unregister(buf_T *buf, uint64_t channelid)
buf->update_channels.size -= found;
// make a new copy of the active array without the channelid in it
- buffer_updates_send_end(buf, channelid);
+ buf_updates_send_end(buf, channelid);
if (found == size) {
kv_destroy(buf->update_channels);
@@ -110,19 +110,19 @@ void buffer_updates_unregister(buf_T *buf, uint64_t channelid)
}
}
-void buffer_updates_unregister_all(buf_T *buf)
+void buf_updates_unregister_all(buf_T *buf)
{
size_t size = kv_size(buf->update_channels);
if (size) {
for (size_t i = 0; i < size; i++) {
- buffer_updates_send_end(buf, kv_A(buf->update_channels, i));
+ buf_updates_send_end(buf, kv_A(buf->update_channels, i));
}
kv_destroy(buf->update_channels);
kv_init(buf->update_channels);
}
}
-void buffer_updates_send_changes(buf_T *buf,
+void buf_updates_send_changes(buf_T *buf,
linenr_T firstline,
int64_t num_added,
int64_t num_removed,
@@ -187,11 +187,11 @@ void buffer_updates_send_changes(buf_T *buf,
// cleared up quickly.
if (badchannelid != 0) {
ELOG("Disabling live updates for dead channel %llu", badchannelid);
- buffer_updates_unregister(buf, badchannelid);
+ buf_updates_unregister(buf, badchannelid);
}
}
-void buffer_updates_send_tick(buf_T *buf)
+void buf_updates_changedtick(buf_T *buf)
{
// notify each of the active channels
for (size_t i = 0; i < kv_size(buf->update_channels); i++) {
@@ -209,6 +209,6 @@ void buffer_updates_send_tick(buf_T *buf)
args.items[1] = INTEGER_OBJ(buf->b_changedtick);
// don't try and clean up dead channels here
- rpc_send_event(channelid, "nvim_buf_update_tick", args);
+ rpc_send_event(channelid, "nvim_buf_changedtick", args);
}
}
diff --git a/src/nvim/buffer_updates.h b/src/nvim/buffer_updates.h
index 63ae2d3984..23804809f1 100644
--- a/src/nvim/buffer_updates.h
+++ b/src/nvim/buffer_updates.h
@@ -3,14 +3,14 @@
#include "nvim/buffer_defs.h"
-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_all(buf_T *buf);
-void buffer_updates_send_changes(buf_T *buf,
+bool buf_updates_register(buf_T *buf, uint64_t channel_id, bool send_buffer);
+void buf_updates_unregister(buf_T *buf, uint64_t channel_id);
+void buf_updates_unregister_all(buf_T *buf);
+void buf_updates_send_changes(buf_T *buf,
linenr_T firstline,
int64_t num_added,
int64_t num_removed,
bool send_tick);
-void buffer_updates_send_tick(buf_T *buf);
+void buf_updates_changedtick(buf_T *buf);
#endif // NVIM_BUFFER_UPDATES_H
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 3960412782..e342ae44aa 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -835,7 +835,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
// send update regarding the new lines that were added
if (kv_size(curbuf->update_channels)) {
- buffer_updates_send_changes(curbuf, dest + 1, num_lines, 0, true);
+ buf_updates_send_changes(curbuf, dest + 1, num_lines, 0, true);
}
/*
@@ -874,7 +874,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
// send nvim_buf_update regarding lines that were deleted
if (kv_size(curbuf->update_channels)) {
- buffer_updates_send_changes(curbuf, line1 + extra, 0, num_lines, true);
+ buf_updates_send_changes(curbuf, line1 + extra, 0, num_lines, true);
}
return OK;
@@ -2442,7 +2442,7 @@ int do_ecmd(
goto theend;
}
u_unchanged(curbuf);
- buffer_updates_unregister_all(curbuf);
+ buf_updates_unregister_all(curbuf);
buf_freeall(curbuf, BFA_KEEP_UNDO);
// Tell readfile() not to clear or reload undo info.
@@ -3168,9 +3168,10 @@ static char_u *sub_parse_flags(char_u *cmd, subflags_T *subflags,
///
/// The usual escapes are supported as described in the regexp docs.
///
+/// @param do_buf_event If `true`, send buffer updates.
/// @return buffer used for 'inccommand' preview
static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
- bool send_buffer_update_changedtick)
+ bool do_buf_event)
{
long i = 0;
regmmatch_T regmatch;
@@ -4021,8 +4022,8 @@ skip:
if (kv_size(curbuf->update_channels)) {
int64_t num_added = last_line - first_line;
int64_t num_removed = num_added - i;
- buffer_updates_send_changes(curbuf, first_line, num_added, num_removed,
- send_buffer_update_changedtick);
+ buf_updates_send_changes(curbuf, first_line, num_added, num_removed,
+ do_buf_event);
}
}
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index 9869e0fd30..4d947d9b07 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -753,7 +753,7 @@ deleteFold (
// the modification of the *first* line of the fold, but we send through a
// notification that includes every line that was part of the fold
int64_t num_changed = last_lnum - first_lnum;
- buffer_updates_send_changes(curbuf, first_lnum, num_changed,
+ buf_updates_send_changes(curbuf, first_lnum, num_changed,
num_changed, true);
}
}
@@ -1610,7 +1610,7 @@ static void foldCreateMarkers(linenr_T start, linenr_T end)
// u_save() is unable to save the buffer line, but we send the
// nvim_buf_update anyway since it won't do any harm.
int64_t num_changed = 1 + end - start;
- buffer_updates_send_changes(curbuf, start, num_changed, num_changed, true);
+ buf_updates_send_changes(curbuf, start, num_changed, num_changed, true);
}
}
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index 47ec3eff32..de68031135 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -1823,7 +1823,7 @@ void changed_bytes(linenr_T lnum, colnr_T col)
changed_common(lnum, col, lnum + 1, 0L);
// notify any channels that are watching
if (kv_size(curbuf->update_channels)) {
- buffer_updates_send_changes(curbuf, lnum, 1, 1, true);
+ buf_updates_send_changes(curbuf, lnum, 1, 1, true);
}
/* Diff highlighting in other diff windows may need to be updated too. */
@@ -1920,7 +1920,7 @@ changed_lines(
colnr_T col, // column in first line with change
linenr_T lnume, // line below last changed line
long xtra, // number of extra lines (negative when deleting)
- bool send_update // some callers like undo/redo call changed_lines()
+ bool do_buf_event // some callers like undo/redo call changed_lines()
// and then increment b_changedtick *again*. This flag
// allows these callers to send the nvim_buf_update events
// after they're done modifying b_changedtick.
@@ -1948,10 +1948,10 @@ changed_lines(
changed_common(lnum, col, lnume, xtra);
- if (send_update && kv_size(curbuf->update_channels)) {
+ if (do_buf_event && kv_size(curbuf->update_channels)) {
int64_t num_added = (int64_t)(lnume + xtra - lnum);
int64_t num_removed = lnume - lnum;
- buffer_updates_send_changes(curbuf, lnum, num_added, num_removed, true);
+ buf_updates_send_changes(curbuf, lnum, num_added, num_removed, true);
}
}
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index ed4515398d..985c6873a4 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -1735,7 +1735,11 @@ bool u_undo_and_forget(int count)
}
/// Undo or redo, depending on `undo_undoes`, `count` times.
-static void u_doit(int startcount, bool quiet, bool send_update)
+///
+/// @param startcount How often to undo or redo
+/// @param quiet If `true`, don't show messages
+/// @param do_buf_event If `true`, send the changedtick with the buffer updates
+static void u_doit(int startcount, bool quiet, bool do_buf_event)
{
int count = startcount;
@@ -1771,7 +1775,7 @@ static void u_doit(int startcount, bool quiet, bool send_update)
break;
}
- u_undoredo(true, send_update);
+ u_undoredo(true, do_buf_event);
} else {
if (curbuf->b_u_curhead == NULL || get_undolevel() <= 0) {
beep_flush(); /* nothing to redo */
@@ -1782,7 +1786,7 @@ static void u_doit(int startcount, bool quiet, bool send_update)
break;
}
- u_undoredo(false, send_update);
+ u_undoredo(false, do_buf_event);
/* Advance for next redo. Set "newhead" when at the end of the
* redoable changes. */
@@ -2108,16 +2112,15 @@ void undo_time(long step, int sec, int file, int absolute)
u_undo_end(did_undo, absolute, false);
}
-/*
- * u_undoredo: common code for undo and redo
- *
- * The lines in the file are replaced by the lines in the entry list at
- * curbuf->b_u_curhead. The replaced lines in the file are saved in the entry
- * list for the next undo/redo.
- *
- * When "undo" is TRUE we go up in the tree, when FALSE we go down.
- */
-static void u_undoredo(int undo, bool send_update)
+/// u_undoredo: common code for undo and redo
+///
+/// The lines in the file are replaced by the lines in the entry list at
+/// curbuf->b_u_curhead. The replaced lines in the file are saved in the entry
+/// list for the next undo/redo.
+///
+/// @param undo If `true`, go up the tree. Down if `false`.
+/// @param do_buf_event If `true`, send buffer updates.
+static void u_undoredo(int undo, bool do_buf_event)
{
char_u **newarray = NULL;
linenr_T oldsize;
@@ -2245,7 +2248,7 @@ static void u_undoredo(int undo, bool send_update)
}
}
- changed_lines(top + 1, 0, bot, newsize - oldsize, send_update);
+ changed_lines(top + 1, 0, bot, newsize - oldsize, do_buf_event);
/* set '[ and '] mark */
if (top + 1 < curbuf->b_op_start.lnum)
@@ -2283,8 +2286,8 @@ static void u_undoredo(int undo, bool send_update)
// because the calls to changed()/unchanged() above will bump b_changedtick
// again, we need to send a nvim_buf_update with just the new value of
// b:changedtick
- if (send_update && kv_size(curbuf->update_channels)) {
- buffer_updates_send_tick(curbuf);
+ if (do_buf_event && kv_size(curbuf->update_channels)) {
+ buf_updates_changedtick(curbuf);
}
/*
diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua
index b30d0805bd..7659961e90 100644
--- a/test/functional/api/buffer_updates_spec.lua
+++ b/test/functional/api/buffer_updates_spec.lua
@@ -336,7 +336,7 @@ describe('liveupdate', function()
tick = tick + 1
expectn('nvim_buf_update', {b, tick, 1, 2, {}})
tick = tick + 1
- expectn('nvim_buf_update_tick', {b, tick})
+ expectn('nvim_buf_changedtick', {b, tick})
command('set autoindent')
command('normal! >>')
tick = tick + 1
@@ -354,7 +354,7 @@ describe('liveupdate', function()
tick = tick + 1
expectn('nvim_buf_update', {b, tick, 1, 2, {}})
tick = tick + 1
- expectn('nvim_buf_update_tick', {b, tick})
+ expectn('nvim_buf_changedtick', {b, tick})
command('normal! ggOmmm')
tick = tick + 1
expectn('nvim_buf_update', {b, tick, 0, 0, {"\t"}})
@@ -374,7 +374,7 @@ describe('liveupdate', function()
tick = tick + 1
expectn('nvim_buf_update', {b, tick, 0, 1, {'Line 1'}})
tick = tick + 1
- expectn('nvim_buf_update_tick', {b, tick})
+ expectn('nvim_buf_changedtick', {b, tick})
-- change the file directly
local f = io.open(filename, 'a')
@@ -410,7 +410,7 @@ describe('liveupdate', function()
tick1 = tick1 + 1
expectn('nvim_buf_update', {b1, tick1, 0, 1, {'A1'}})
tick1 = tick1 + 1
- expectn('nvim_buf_update_tick', {b1, tick1})
+ expectn('nvim_buf_changedtick', {b1, tick1})
command('b'..b2nr)
command('normal! x')
@@ -420,7 +420,7 @@ describe('liveupdate', function()
tick2 = tick2 + 1
expectn('nvim_buf_update', {b2, tick2, 0, 1, {'B1'}})
tick2 = tick2 + 1
- expectn('nvim_buf_update_tick', {b2, tick2})
+ expectn('nvim_buf_changedtick', {b2, tick2})
command('b'..b3nr)
command('normal! x')
@@ -430,7 +430,7 @@ describe('liveupdate', function()
tick3 = tick3 + 1
expectn('nvim_buf_update', {b3, tick3, 0, 1, {'C1'}})
tick3 = tick3 + 1
- expectn('nvim_buf_update_tick', {b3, tick3})
+ expectn('nvim_buf_changedtick', {b3, tick3})
end)
it('doesn\'t get confused when you turn watching on/off many times',
@@ -512,8 +512,8 @@ describe('liveupdate', function()
wantn(2, 'nvim_buf_update', {b, tick, 0, 1, {'AAA'}})
wantn(3, 'nvim_buf_update', {b, tick, 0, 1, {'AAA'}})
tick = tick + 1
- wantn(2, 'nvim_buf_update_tick', {b, tick})
- wantn(3, 'nvim_buf_update_tick', {b, tick})
+ wantn(2, 'nvim_buf_changedtick', {b, tick})
+ wantn(3, 'nvim_buf_changedtick', {b, tick})
-- make sure there are no other pending nvim_buf_update messages going to
-- channel 1
@@ -665,7 +665,7 @@ describe('liveupdate', function()
tick = tick + 1
expectn('nvim_buf_update', {b, tick, 0, 1, {'AAA'}})
tick = tick + 1
- expectn('nvim_buf_update_tick', {b, tick})
+ expectn('nvim_buf_changedtick', {b, tick})
-- close our buffer by creating a new one
command('enew')
@@ -692,7 +692,7 @@ describe('liveupdate', function()
tick = tick + 1
expectn('nvim_buf_update', {b, tick, 0, 1, {'AAA'}})
tick = tick + 1
- expectn('nvim_buf_update_tick', {b, tick})
+ expectn('nvim_buf_changedtick', {b, tick})
-- close our buffer by creating a new one
command('set hidden')