diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/api/buffer.c | 4 | ||||
-rw-r--r-- | src/nvim/buffer.c | 4 | ||||
-rw-r--r-- | src/nvim/buffer_updates.c | 20 | ||||
-rw-r--r-- | src/nvim/buffer_updates.h | 10 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 13 | ||||
-rw-r--r-- | src/nvim/fold.c | 4 | ||||
-rw-r--r-- | src/nvim/misc1.c | 8 | ||||
-rw-r--r-- | src/nvim/undo.c | 35 |
8 files changed, 51 insertions, 47 deletions
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); } /* |