mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 20:08:17 +00:00
The grand renaming
This commit is contained in:
@@ -242,44 +242,44 @@ the type codes, because a client may be built against one Nvim version but
|
|||||||
connect to another with different type codes.
|
connect to another with different type codes.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
6. Live Updates *live-updates* *rpc-live-updates*
|
6. Buffer Updates *buffer-updates* *rpc-buffer-updates*
|
||||||
|
|
||||||
A dedicated API has been created to allow co-processes to be notified when a
|
A dedicated API has been created to allow co-processes to be notified when a
|
||||||
buffer is changed in any way. It is difficult and error-prone to try and do
|
buffer is changed in any way. It is difficult and error-prone to try and do
|
||||||
this with autocommands such as |TextChanged|.
|
this with autocommands such as |TextChanged|.
|
||||||
|
|
||||||
*live-updates-api*
|
*buffer-updates-api*
|
||||||
LiveUpdate Functions~
|
BufferUpdates Functions~
|
||||||
|
|
||||||
nvim_buf_live_updates_start({send_buffer}) *nvim_buf_live_updates_start()*
|
nvim_buf_attach({send_buffer}) *nvim_buf_attach()*
|
||||||
Register a plugin to receive notifications on buffer changes. An
|
Register a plugin to receive notifications on buffer changes. An
|
||||||
initial |LiveUpdateStart| notification will be sent as a
|
initial |nvim_buf_updates_start| notification will be sent as a
|
||||||
confirmation. After that, |LiveUpdate| notifications will be
|
confirmation. After that, |nvim_buf_update| notifications will be
|
||||||
sent for buffer updates, and |LiveUpdateTick| notifications for
|
sent for buffer updates, and |nvim_buf_update_tick| notifications
|
||||||
a new changedtick without buffer change.
|
for a new changedtick without buffer change.
|
||||||
|
|
||||||
Parameters:~
|
Parameters:~
|
||||||
{send_buffer} Bool. If `"True"`, the initial
|
{send_buffer} Bool. If `"True"`, the initial
|
||||||
|LiveUpdateStart| notification will also send the full
|
|nvim_buf_updates_start| notification will also send the full
|
||||||
buffer's content. If `"False"`, the notification will
|
buffer's content. If `"False"`, the notification will contain
|
||||||
contain an empty list instead.
|
an empty list instead.
|
||||||
|
|
||||||
nvim_buf_live_updates_stop() *nvim_buf_live_updates_stop()*
|
nvim_buf_detach() *nvim_buf_detach()*
|
||||||
Unregister a plugin from buffer change notifications. A final
|
Unregister a plugin from buffer change notifications. A final
|
||||||
|LiveUpdateEnd| notification will be sent as confirmation.
|
|nvim_buf_updates_end| notification will be sent as confirmation.
|
||||||
|
|
||||||
*live-updates-events*
|
*buffer-updates-events*
|
||||||
LiveUpdate Events~
|
BufferUpdates Events~
|
||||||
|
|
||||||
The co-process will start receiving the following notification events:
|
The co-process will start receiving the following notification events:
|
||||||
|
|
||||||
LiveUpdateStart[{buf}, {changedtick}, {linedata}, {more}] *LiveUpdateStart*
|
nvim_buf_updates_start[{buf}, {changedtick}, {linedata}, {more}] *nvim_buf_updates_start*
|
||||||
|
|
||||||
Neovim will send at least one of these notifications to confirm that
|
Neovim will send at least one of these notifications to confirm that
|
||||||
liveupdates are registered for this plugin, and possibly send the buffer's
|
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
|
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
|
in multiple events to avoid loading the entire buffer's contents into
|
||||||
at once.
|
memory at once.
|
||||||
|
|
||||||
{buf} is an API handle for the buffer.
|
{buf} is an API handle for the buffer.
|
||||||
|
|
||||||
@@ -288,27 +288,27 @@ LiveUpdateStart[{buf}, {changedtick}, {linedata}, {more}] *LiveUpdateStart*
|
|||||||
|b:changedtick| as part of your request to ensure that no other
|
|b:changedtick| as part of your request to ensure that no other
|
||||||
changes have been made.
|
changes have been made.
|
||||||
|
|
||||||
{linedata} is a list of strings containing the buffer's contents. If
|
{linedata} is a list of strings containing the buffer's contents. If this
|
||||||
this list contains 100 strings, then they represent lines 1-100 of the
|
list contains 100 strings, then they represent lines 1-100 of the buffer.
|
||||||
buffer. Newline characters are not included in the strings, so empty
|
Newline characters are not included in the strings, so empty lines will be
|
||||||
lines will be given as empty strings. If you receive another
|
given as empty strings. If you receive another |nvim_buf_updates_start|
|
||||||
|LiveUpdateStart| notification with another {linedata} list, then
|
notification with another {linedata} list, then these lines represent the
|
||||||
these lines represent the next N lines of the buffer. I.e., a second
|
next N lines of the buffer. I.e., a second notification with another list of
|
||||||
notification with another list of 100 strings will represent lines 101-200
|
100 strings will represent lines 101-200 of the buffer. If you send the
|
||||||
of the buffer. If you send the |nvim_buf_live_updates_start| request with
|
|nvim_buf_updates_start| request with its argument set to `"False"`, this
|
||||||
its argument set to `"False"`, this will be empty.
|
will be empty.
|
||||||
|
|
||||||
{linedata} will always have at least 1 item, but the maximum length is
|
{linedata} will always have at least 1 item, but the maximum length is
|
||||||
determined by neovim and not guaranteed to be any particular size.
|
determined by neovim and not guaranteed to be any particular size. Also the
|
||||||
Also the number of {linedata} items may vary between notifications, so
|
number of {linedata} items may vary between notifications, so your plugin
|
||||||
your plugin must be prepared to receive the line data in whatever size
|
must be prepared to receive the line data in whatever size lists neovim
|
||||||
lists neovim decides to split it into.
|
decides to split it into.
|
||||||
|
|
||||||
{more} is a boolean which tells you whether or not to expect more
|
{more} is a boolean which tells you whether or not to expect more
|
||||||
|LiveUpdateStart| notifications. When {more} is false, you can be certain
|
|nvim_buf_updates_start| notifications. When {more} is false, you can be certain
|
||||||
that you now have the entire buffer's contents.
|
that you now have the entire buffer's contents.
|
||||||
|
|
||||||
LiveUpdate[{buf}, {changedtick}, {firstline}, {lastline}, {linedata}] *LiveUpdate*
|
nvim_buf_update[{buf}, {changedtick}, {firstline}, {lastline}, {linedata}] *nvim_buf_update*
|
||||||
|
|
||||||
Indicates that the lines between {firstline} and {lastline} (end-exclusive,
|
Indicates that the lines between {firstline} and {lastline} (end-exclusive,
|
||||||
zero-indexed) have been replaced with the new line data contained in the
|
zero-indexed) have been replaced with the new line data contained in the
|
||||||
@@ -327,24 +327,24 @@ LiveUpdate[{buf}, {changedtick}, {firstline}, {lastline}, {linedata}] *LiveUpdat
|
|||||||
be less than or equal to the number of lines that were in the buffer before
|
be less than or equal to the number of lines that were in the buffer before
|
||||||
the lines were replaced.
|
the lines were replaced.
|
||||||
|
|
||||||
{lastline} is the integer line number of the first line that was not
|
{lastline} is the integer line number of the first line that was not replaced
|
||||||
replaced (i.e. the range {firstline}, {lastline} is end-exclusive). Note
|
(i.e. the range {firstline}, {lastline} is end-exclusive). Note that
|
||||||
that {lastline} is zero-indexed, so if line numbers 2 to 5 were replaced,
|
{lastline} is zero-indexed, so if line numbers 2 to 5 were replaced, this
|
||||||
this will be `5` instead of `6`. {lastline} is guaranteed to always be less
|
will be `5` instead of `6`. {lastline} is guaranteed to always be less than
|
||||||
than or equal to the number of lines that were in the buffer before the
|
or equal to the number of lines that were in the buffer before the lines were
|
||||||
lines were replaced.
|
replaced.
|
||||||
|
|
||||||
{linedata} is a list of strings containing the contents of the new buffer
|
{linedata} is a list of strings containing the contents of the new buffer
|
||||||
lines. Newline characters are not included in the strings, so empty lines
|
lines. Newline characters are not included in the strings, so empty lines
|
||||||
will be given as empty strings.
|
will be given as empty strings.
|
||||||
|
|
||||||
Note: sometimes {changedtick} will be |v:null|, which means that the buffer
|
Note: sometimes {changedtick} will be |v:null|, which means that the buffer
|
||||||
text *looks* like it has changed, but actually hasn't. In this case the
|
text *looks* like it has changed, but actually hasn't. In this case the lines
|
||||||
lines in {linedata} contain the modified text that is shown to the user, but
|
in {linedata} contain the modified text that is shown to the user, but
|
||||||
doesn't reflect the actual buffer contents. Currently this behaviour is only
|
doesn't reflect the actual buffer contents. Currently this behaviour is
|
||||||
used for the 'inccommand' option.
|
only used for the 'inccommand' option.
|
||||||
|
|
||||||
LiveUpdateTick[{buf}, {changedtick}] *LiveUpdateTick*
|
nvim_buf_update_tick[{buf}, {changedtick}] *nvim_buf_update_tick*
|
||||||
|
|
||||||
Indicates that |b:changedtick| was incremented for the buffer {buf}, but no
|
Indicates that |b:changedtick| was incremented for the buffer {buf}, but no
|
||||||
text was changed. This is currently only used by undo/redo.
|
text was changed. This is currently only used by undo/redo.
|
||||||
@@ -353,60 +353,60 @@ LiveUpdateTick[{buf}, {changedtick}] *LiveUpdateTick*
|
|||||||
|
|
||||||
{changedtick} is the new value of |b:changedtick| for that buffer.
|
{changedtick} is the new value of |b:changedtick| for that buffer.
|
||||||
|
|
||||||
LiveUpdateEnd[{buf}] *LiveUpdateEnd*
|
nvim_buf_updates_end[{buf}] *nvim_buf_updates_end*
|
||||||
|
|
||||||
{buf} is an API handle for the buffer.
|
{buf} is an API handle for the buffer.
|
||||||
|
|
||||||
Indicates that live updates for the nominated buffer have been disabled,
|
Indicates that buffer updates for the nominated buffer have been disabled,
|
||||||
either by calling |nvim_buf_live_updates_stop| or because the buffer was
|
either by calling |nvim_buf_detach| or because the buffer was unloaded
|
||||||
unloaded (see |live-updates-limitations| for more information).
|
(see |buffer-updates-limitations| for more information).
|
||||||
|
|
||||||
*live-updates-limitations*
|
*buffer-updates-limitations*
|
||||||
Limitations~
|
Limitations~
|
||||||
|
|
||||||
Note that any of the following actions will also turn off live updates because
|
Note that any of the following actions will also turn off buffer updates because
|
||||||
the buffer contents are unloaded from memory:
|
the buffer contents are unloaded from memory:
|
||||||
|
|
||||||
- Closing all a buffer's windows (unless 'hidden' is enabled).
|
- Closing all a buffer's windows (unless 'hidden' is enabled).
|
||||||
- Using |:edit| to reload the buffer
|
- 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 neovim.
|
||||||
|
|
||||||
*live-updates-examples*
|
*buffer-updates-examples*
|
||||||
Example Events~
|
Example Events~
|
||||||
|
|
||||||
If live updates are activated a new empty buffer, the following
|
If buffer updates are activated a new empty buffer, the following
|
||||||
|LiveUpdateStart| event will be sent: >
|
|nvim_buf_updates_start| event will be sent: >
|
||||||
|
|
||||||
rpcnotify({channel}, "LiveUpdateStart", [{buf}, [""], v:false])
|
rpcnotify({channel}, "nvim_buf_updates_start", [{buf}, [""], v:false])
|
||||||
|
|
||||||
If the user adds 2 new lines to the start of a buffer, the following event
|
If the user adds 2 new lines to the start of a buffer, the following event
|
||||||
would be generated: >
|
would be generated: >
|
||||||
|
|
||||||
rpcnotify({channel}, "LiveUpdate", [{buf}, 0, 0, ["line1", "line2"]])
|
rpcnotify({channel}, "nvim_buf_update", [{buf}, 0, 0, ["line1", "line2"]])
|
||||||
|
|
||||||
If the puts the cursor on a line containing the text `"Hello world"` and adds
|
If the puts the cursor on a line containing the text `"Hello world"` and adds
|
||||||
a `!` character to the end using insert mode, the following event would be
|
a `!` character to the end using insert mode, the following event would be
|
||||||
generated: >
|
generated: >
|
||||||
|
|
||||||
rpcnotify({channel}, "LiveUpdate", [{buf}, {linenr}, {linenr} + 1, ["Hello
|
rpcnotify({channel}, "nvim_buf_update", [{buf}, {linenr}, {linenr} + 1, ["Hello
|
||||||
world!"]])
|
world!"]])
|
||||||
|
|
||||||
If the user moves their cursor to line 3 of a buffer and deletes 20 lines
|
If the user moves their cursor to line 3 of a buffer and deletes 20 lines
|
||||||
using `20dd`, the following event will be generated: >
|
using `20dd`, the following event will be generated: >
|
||||||
|
|
||||||
rpcnotify({channel}, "LiveUpdate", [{buf}, 2, 20, []])
|
rpcnotify({channel}, "nvim_buf_update", [{buf}, 2, 20, []])
|
||||||
|
|
||||||
If the user selects lines 3-5 of a buffer using |linewise-visual| mode and
|
If the user selects lines 3-5 of a buffer using |linewise-visual| mode and
|
||||||
then presses `p` to paste in a new block of 6 lines, then the following event
|
then presses `p` to paste in a new block of 6 lines, then the following event
|
||||||
would be sent to the co-process: >
|
would be sent to the co-process: >
|
||||||
|
|
||||||
rpcnotify({channel}, "LiveUpdate", [{buf}, 2, 5, ['pasted line 1', 'pasted
|
rpcnotify({channel}, "nvim_buf_update", [{buf}, 2, 5, ['pasted line 1', 'pasted
|
||||||
line 2', 'pasted line 3', 'pasted line 4', 'pasted line 5', 'pasted line
|
line 2', 'pasted line 3', 'pasted line 4', 'pasted line 5', 'pasted line
|
||||||
6']])
|
6']])
|
||||||
|
|
||||||
If the user uses :edit to reload a buffer then the following event would be
|
If the user uses :edit to reload a buffer then the following event would be
|
||||||
generated: >
|
generated: >
|
||||||
|
|
||||||
rpcnotify({channel}, "LiveUpdateEnd", [{buf}])
|
rpcnotify({channel}, "nvim_buf_updates_end", [{buf}])
|
||||||
|
|
||||||
vim:tw=78:ts=8:ft=help:norl:
|
vim:tw=78:ts=8:ft=help:norl:
|
||||||
|
@@ -142,7 +142,7 @@ set(CONV_SOURCES
|
|||||||
message.c
|
message.c
|
||||||
regexp.c
|
regexp.c
|
||||||
screen.c
|
screen.c
|
||||||
liveupdate.c
|
buffer_updates.c
|
||||||
search.c
|
search.c
|
||||||
spell.c
|
spell.c
|
||||||
spellfile.c
|
spellfile.c
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
#include "nvim/window.h"
|
#include "nvim/window.h"
|
||||||
#include "nvim/undo.h"
|
#include "nvim/undo.h"
|
||||||
#include "nvim/ex_docmd.h"
|
#include "nvim/ex_docmd.h"
|
||||||
#include "nvim/liveupdate.h"
|
#include "nvim/buffer_updates.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "api/buffer.c.generated.h"
|
# include "api/buffer.c.generated.h"
|
||||||
@@ -76,18 +76,18 @@ String buffer_get_line(Buffer buffer, Integer index, Error *err)
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Activate live updates from this buffer to the current channel.
|
/// Activate updates from this buffer to the current channel.
|
||||||
///
|
///
|
||||||
/// @param buffer The buffer handle
|
/// @param buffer The buffer handle
|
||||||
/// @param send_buffer Set to true if the initial notification should contain
|
/// @param send_buffer Set to true if the initial notification should contain
|
||||||
/// the whole buffer
|
/// the whole buffer
|
||||||
/// @param[out] err Details of an error that may have occurred
|
/// @param[out] err Details of an error that may have occurred
|
||||||
/// @return False when live updates couldn't be enabled because the buffer isn't
|
/// @return False when updates couldn't be enabled because the buffer isn't
|
||||||
/// loaded; otherwise True.
|
/// loaded; otherwise True.
|
||||||
Boolean nvim_buf_live_updates_start(uint64_t channel_id,
|
Boolean nvim_buf_attach(uint64_t channel_id,
|
||||||
Buffer buffer,
|
Buffer buffer,
|
||||||
Boolean send_buffer,
|
Boolean send_buffer,
|
||||||
Error *err)
|
Error *err)
|
||||||
FUNC_API_SINCE(4) FUNC_API_REMOTE_ONLY
|
FUNC_API_SINCE(4) FUNC_API_REMOTE_ONLY
|
||||||
{
|
{
|
||||||
buf_T *buf = find_buffer_by_handle(buffer, err);
|
buf_T *buf = find_buffer_by_handle(buffer, err);
|
||||||
@@ -96,18 +96,18 @@ Boolean nvim_buf_live_updates_start(uint64_t channel_id,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return liveupdate_register(buf, channel_id, send_buffer);
|
return buffer_updates_register(buf, channel_id, send_buffer);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
/// Deactivate live updates from this buffer to the current channel.
|
/// Deactivate updates from this buffer to the current channel.
|
||||||
///
|
///
|
||||||
/// @param buffer The buffer handle
|
/// @param buffer The buffer handle
|
||||||
/// @param[out] err Details of an error that may have occurred
|
/// @param[out] err Details of an error that may have occurred
|
||||||
/// @return False when live updates couldn't be disabled because the buffer
|
/// @return False when updates couldn't be disabled because the buffer
|
||||||
/// isn't loaded; otherwise True.
|
/// isn't loaded; otherwise True.
|
||||||
Boolean nvim_buf_live_updates_stop(uint64_t channel_id,
|
Boolean nvim_buf_detach(uint64_t channel_id,
|
||||||
Buffer buffer,
|
Buffer buffer,
|
||||||
Error *err)
|
Error *err)
|
||||||
FUNC_API_SINCE(4) FUNC_API_REMOTE_ONLY
|
FUNC_API_SINCE(4) FUNC_API_REMOTE_ONLY
|
||||||
{
|
{
|
||||||
buf_T *buf = find_buffer_by_handle(buffer, err);
|
buf_T *buf = find_buffer_by_handle(buffer, err);
|
||||||
@@ -116,7 +116,7 @@ Boolean nvim_buf_live_updates_stop(uint64_t channel_id,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
liveupdate_unregister(buf, channel_id);
|
buffer_updates_unregister(buf, channel_id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -73,7 +73,7 @@
|
|||||||
#include "nvim/os/os.h"
|
#include "nvim/os/os.h"
|
||||||
#include "nvim/os/time.h"
|
#include "nvim/os/time.h"
|
||||||
#include "nvim/os/input.h"
|
#include "nvim/os/input.h"
|
||||||
#include "nvim/liveupdate.h"
|
#include "nvim/buffer_updates.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
kBLSUnchanged = 0,
|
kBLSUnchanged = 0,
|
||||||
@@ -576,7 +576,7 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last)
|
|||||||
do_autochdir();
|
do_autochdir();
|
||||||
|
|
||||||
// disable live updates for the current buffer
|
// disable live updates for the current buffer
|
||||||
liveupdate_unregister_all(buf);
|
buffer_updates_unregister_all(buf);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove the buffer from the list.
|
* Remove the buffer from the list.
|
||||||
@@ -789,7 +789,7 @@ free_buffer_stuff (
|
|||||||
xfree(buf->b_start_fenc);
|
xfree(buf->b_start_fenc);
|
||||||
buf->b_start_fenc = NULL;
|
buf->b_start_fenc = NULL;
|
||||||
|
|
||||||
liveupdate_unregister_all(buf);
|
buffer_updates_unregister_all(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1741,8 +1741,8 @@ buf_T * buflist_new(char_u *ffname, char_u *sfname, linenr_T lnum, int flags)
|
|||||||
clrallmarks(buf); // clear marks
|
clrallmarks(buf); // clear marks
|
||||||
fmarks_check_names(buf); // check file marks for this file
|
fmarks_check_names(buf); // check file marks for this file
|
||||||
buf->b_p_bl = (flags & BLN_LISTED) ? true : false; // init 'buflisted'
|
buf->b_p_bl = (flags & BLN_LISTED) ? true : false; // init 'buflisted'
|
||||||
kv_destroy(buf->liveupdate_channels);
|
kv_destroy(buf->update_channels);
|
||||||
kv_init(buf->liveupdate_channels);
|
kv_init(buf->update_channels);
|
||||||
if (!(flags & BLN_DUMMY)) {
|
if (!(flags & BLN_DUMMY)) {
|
||||||
// Tricky: these autocommands may change the buffer list. They could also
|
// Tricky: these autocommands may change the buffer list. They could also
|
||||||
// split the window with re-using the one empty buffer. This may result in
|
// split the window with re-using the one empty buffer. This may result in
|
||||||
|
@@ -774,9 +774,9 @@ struct file_buffer {
|
|||||||
|
|
||||||
kvec_t(BufhlLine *) b_bufhl_move_space; // temporary space for highlights
|
kvec_t(BufhlLine *) b_bufhl_move_space; // temporary space for highlights
|
||||||
|
|
||||||
// array of channelids which have asked to receive live updates for this
|
// array of channelids which have asked to receive updates for this
|
||||||
// buffer.
|
// buffer.
|
||||||
kvec_t(uint64_t) liveupdate_channels;
|
kvec_t(uint64_t) update_channels;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#include "nvim/liveupdate.h"
|
#include "nvim/buffer_updates.h"
|
||||||
#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"
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
// 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
|
||||||
// unloaded.
|
// unloaded.
|
||||||
bool liveupdate_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)
|
||||||
{
|
{
|
||||||
// must fail if the buffer isn't loaded
|
// must fail if the buffer isn't loaded
|
||||||
if (buf->b_ml.ml_mfp == NULL) {
|
if (buf->b_ml.ml_mfp == NULL) {
|
||||||
@@ -14,10 +14,10 @@ bool liveupdate_register(buf_T *buf, uint64_t channel_id, bool send_buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// count how many channels are currently watching the buffer
|
// count how many channels are currently watching the buffer
|
||||||
size_t size = kv_size(buf->liveupdate_channels);
|
size_t size = kv_size(buf->update_channels);
|
||||||
if (size) {
|
if (size) {
|
||||||
for (size_t i = 0; i < size; i++) {
|
for (size_t i = 0; i < size; i++) {
|
||||||
if (kv_A(buf->liveupdate_channels, i) == channel_id) {
|
if (kv_A(buf->update_channels, i) == channel_id) {
|
||||||
// buffer is already registered ... nothing to do
|
// buffer is already registered ... nothing to do
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ bool liveupdate_register(buf_T *buf, uint64_t channel_id, bool send_buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// append the channelid to the list
|
// append the channelid to the list
|
||||||
kv_push(buf->liveupdate_channels, channel_id);
|
kv_push(buf->update_channels, channel_id);
|
||||||
|
|
||||||
Array linedata = ARRAY_DICT_INIT;
|
Array linedata = ARRAY_DICT_INIT;
|
||||||
if (send_buffer) {
|
if (send_buffer) {
|
||||||
@@ -56,22 +56,22 @@ bool liveupdate_register(buf_T *buf, uint64_t channel_id, bool send_buffer)
|
|||||||
args.items[2] = ARRAY_OBJ(linedata);
|
args.items[2] = ARRAY_OBJ(linedata);
|
||||||
args.items[3] = BOOLEAN_OBJ(false);
|
args.items[3] = BOOLEAN_OBJ(false);
|
||||||
|
|
||||||
rpc_send_event(channel_id, "LiveUpdateStart", args);
|
rpc_send_event(channel_id, "nvim_buf_updates_start", args);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void liveupdate_send_end(buf_T *buf, uint64_t channelid)
|
void buffer_updates_send_end(buf_T *buf, uint64_t channelid)
|
||||||
{
|
{
|
||||||
Array args = ARRAY_DICT_INIT;
|
Array args = ARRAY_DICT_INIT;
|
||||||
args.size = 1;
|
args.size = 1;
|
||||||
args.items = xcalloc(sizeof(Object), args.size);
|
args.items = xcalloc(sizeof(Object), args.size);
|
||||||
args.items[0] = BUFFER_OBJ(buf->handle);
|
args.items[0] = BUFFER_OBJ(buf->handle);
|
||||||
rpc_send_event(channelid, "LiveUpdateEnd", args);
|
rpc_send_event(channelid, "nvim_buf_updates_end", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void liveupdate_unregister(buf_T *buf, uint64_t channelid)
|
void buffer_updates_unregister(buf_T *buf, uint64_t channelid)
|
||||||
{
|
{
|
||||||
size_t size = kv_size(buf->liveupdate_channels);
|
size_t size = kv_size(buf->update_channels);
|
||||||
if (!size) {
|
if (!size) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -81,12 +81,12 @@ void liveupdate_unregister(buf_T *buf, uint64_t channelid)
|
|||||||
size_t j = 0;
|
size_t j = 0;
|
||||||
size_t found = 0;
|
size_t found = 0;
|
||||||
for (size_t i = 0; i < size; i++) {
|
for (size_t i = 0; i < size; i++) {
|
||||||
if (kv_A(buf->liveupdate_channels, i) == channelid) {
|
if (kv_A(buf->update_channels, i) == channelid) {
|
||||||
found++;
|
found++;
|
||||||
} else {
|
} else {
|
||||||
// copy item backwards into prior slot if needed
|
// copy item backwards into prior slot if needed
|
||||||
if (i != j) {
|
if (i != j) {
|
||||||
kv_A(buf->liveupdate_channels, j) = kv_A(buf->liveupdate_channels, i);
|
kv_A(buf->update_channels, j) = kv_A(buf->update_channels, i);
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
@@ -94,39 +94,39 @@ void liveupdate_unregister(buf_T *buf, uint64_t channelid)
|
|||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
// remove X items from the end of the array
|
// remove X items from the end of the array
|
||||||
buf->liveupdate_channels.size -= found;
|
buf->update_channels.size -= found;
|
||||||
|
|
||||||
// make a new copy of the active array without the channelid in it
|
// make a new copy of the active array without the channelid in it
|
||||||
liveupdate_send_end(buf, channelid);
|
buffer_updates_send_end(buf, channelid);
|
||||||
|
|
||||||
if (found == size) {
|
if (found == size) {
|
||||||
kv_destroy(buf->liveupdate_channels);
|
kv_destroy(buf->update_channels);
|
||||||
kv_init(buf->liveupdate_channels);
|
kv_init(buf->update_channels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void liveupdate_unregister_all(buf_T *buf)
|
void buffer_updates_unregister_all(buf_T *buf)
|
||||||
{
|
{
|
||||||
size_t size = kv_size(buf->liveupdate_channels);
|
size_t size = kv_size(buf->update_channels);
|
||||||
if (size) {
|
if (size) {
|
||||||
for (size_t i = 0; i < size; i++) {
|
for (size_t i = 0; i < size; i++) {
|
||||||
liveupdate_send_end(buf, kv_A(buf->liveupdate_channels, i));
|
buffer_updates_send_end(buf, kv_A(buf->update_channels, i));
|
||||||
}
|
}
|
||||||
kv_destroy(buf->liveupdate_channels);
|
kv_destroy(buf->update_channels);
|
||||||
kv_init(buf->liveupdate_channels);
|
kv_init(buf->update_channels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void liveupdate_send_changes(buf_T *buf, linenr_T firstline, int64_t num_added,
|
void buffer_updates_send_changes(buf_T *buf, linenr_T firstline, int64_t num_added,
|
||||||
int64_t num_removed, bool send_tick)
|
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;
|
||||||
|
|
||||||
// notify each of the active channels
|
// notify each of the active channels
|
||||||
for (size_t i = 0; i < kv_size(buf->liveupdate_channels); i++) {
|
for (size_t i = 0; i < kv_size(buf->update_channels); i++) {
|
||||||
uint64_t channelid = kv_A(buf->liveupdate_channels, i);
|
uint64_t channelid = kv_A(buf->update_channels, i);
|
||||||
|
|
||||||
// send through the changes now channel contents now
|
// send through the changes now channel contents now
|
||||||
Array args = ARRAY_DICT_INIT;
|
Array args = ARRAY_DICT_INIT;
|
||||||
@@ -162,9 +162,9 @@ void liveupdate_send_changes(buf_T *buf, linenr_T firstline, int64_t num_added,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
args.items[4] = ARRAY_OBJ(linedata);
|
args.items[4] = ARRAY_OBJ(linedata);
|
||||||
if (!rpc_send_event(channelid, "LiveUpdate", args)) {
|
if (!rpc_send_event(channelid, "nvim_buf_update", args)) {
|
||||||
// We can't unregister the channel while we're iterating over the
|
// We can't unregister the channel while we're iterating over the
|
||||||
// liveupdate_channels array, so we remember its ID to unregister it at
|
// update_channels array, so we remember its ID to unregister it at
|
||||||
// the end.
|
// the end.
|
||||||
badchannelid = channelid;
|
badchannelid = channelid;
|
||||||
}
|
}
|
||||||
@@ -175,15 +175,15 @@ void liveupdate_send_changes(buf_T *buf, linenr_T firstline, int64_t num_added,
|
|||||||
// cleared up quickly.
|
// cleared up quickly.
|
||||||
if (badchannelid != 0) {
|
if (badchannelid != 0) {
|
||||||
ELOG("Disabling live updates for dead channel %llu", badchannelid);
|
ELOG("Disabling live updates for dead channel %llu", badchannelid);
|
||||||
liveupdate_unregister(buf, badchannelid);
|
buffer_updates_unregister(buf, badchannelid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void liveupdate_send_tick(buf_T *buf)
|
void buffer_updates_send_tick(buf_T *buf)
|
||||||
{
|
{
|
||||||
// notify each of the active channels
|
// notify each of the active channels
|
||||||
for (size_t i = 0; i < kv_size(buf->liveupdate_channels); i++) {
|
for (size_t i = 0; i < kv_size(buf->update_channels); i++) {
|
||||||
uint64_t channelid = kv_A(buf->liveupdate_channels, i);
|
uint64_t channelid = kv_A(buf->update_channels, i);
|
||||||
|
|
||||||
// send through the changes now channel contents now
|
// send through the changes now channel contents now
|
||||||
Array args = ARRAY_DICT_INIT;
|
Array args = ARRAY_DICT_INIT;
|
||||||
@@ -197,6 +197,6 @@ void liveupdate_send_tick(buf_T *buf)
|
|||||||
args.items[1] = INTEGER_OBJ(buf->b_changedtick);
|
args.items[1] = INTEGER_OBJ(buf->b_changedtick);
|
||||||
|
|
||||||
// don't try and clean up dead channels here
|
// don't try and clean up dead channels here
|
||||||
rpc_send_event(channelid, "LiveUpdateTick", args);
|
rpc_send_event(channelid, "nvim_buf_update_tick", args);
|
||||||
}
|
}
|
||||||
}
|
}
|
13
src/nvim/buffer_updates.h
Normal file
13
src/nvim/buffer_updates.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#ifndef BUFFER_UPDATES_H
|
||||||
|
#define BUFFER_UPDATES_H
|
||||||
|
|
||||||
|
#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, linenr_T firstline, int64_t num_added,
|
||||||
|
int64_t num_removed, bool send_tick);
|
||||||
|
void buffer_updates_send_tick(buf_T *buf);
|
||||||
|
|
||||||
|
#endif // NVIM_BUFFER_UPDATES_H
|
@@ -35,7 +35,7 @@
|
|||||||
#include "nvim/fold.h"
|
#include "nvim/fold.h"
|
||||||
#include "nvim/getchar.h"
|
#include "nvim/getchar.h"
|
||||||
#include "nvim/indent.h"
|
#include "nvim/indent.h"
|
||||||
#include "nvim/liveupdate.h"
|
#include "nvim/buffer_updates.h"
|
||||||
#include "nvim/main.h"
|
#include "nvim/main.h"
|
||||||
#include "nvim/mark.h"
|
#include "nvim/mark.h"
|
||||||
#include "nvim/mbyte.h"
|
#include "nvim/mbyte.h"
|
||||||
@@ -833,9 +833,9 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
|
|||||||
-(last_line - dest - extra), 0L, true);
|
-(last_line - dest - extra), 0L, true);
|
||||||
changed_lines(last_line - num_lines + 1, 0, last_line + 1, -extra, false);
|
changed_lines(last_line - num_lines + 1, 0, last_line + 1, -extra, false);
|
||||||
|
|
||||||
// send live update regarding the new lines that were added
|
// send update regarding the new lines that were added
|
||||||
if (kv_size(curbuf->liveupdate_channels)) {
|
if (kv_size(curbuf->update_channels)) {
|
||||||
liveupdate_send_changes(curbuf, dest + 1, num_lines, 0, true);
|
buffer_updates_send_changes(curbuf, dest + 1, num_lines, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -872,9 +872,9 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
|
|||||||
changed_lines(dest + 1, 0, line1 + num_lines, 0L, false);
|
changed_lines(dest + 1, 0, line1 + num_lines, 0L, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// send LiveUpdate regarding lines that were deleted
|
// send nvim_buf_update regarding lines that were deleted
|
||||||
if (kv_size(curbuf->liveupdate_channels)) {
|
if (kv_size(curbuf->update_channels)) {
|
||||||
liveupdate_send_changes(curbuf, line1 + extra, 0, num_lines, true);
|
buffer_updates_send_changes(curbuf, line1 + extra, 0, num_lines, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -2442,7 +2442,7 @@ int do_ecmd(
|
|||||||
goto theend;
|
goto theend;
|
||||||
}
|
}
|
||||||
u_unchanged(curbuf);
|
u_unchanged(curbuf);
|
||||||
liveupdate_unregister_all(curbuf);
|
buffer_updates_unregister_all(curbuf);
|
||||||
buf_freeall(curbuf, BFA_KEEP_UNDO);
|
buf_freeall(curbuf, BFA_KEEP_UNDO);
|
||||||
|
|
||||||
// Tell readfile() not to clear or reload undo info.
|
// Tell readfile() not to clear or reload undo info.
|
||||||
@@ -3170,7 +3170,7 @@ static char_u *sub_parse_flags(char_u *cmd, subflags_T *subflags,
|
|||||||
///
|
///
|
||||||
/// @return buffer used for 'inccommand' preview
|
/// @return buffer used for 'inccommand' preview
|
||||||
static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
|
static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
|
||||||
bool send_liveupdate_changedtick)
|
bool send_buffer_update_changedtick)
|
||||||
{
|
{
|
||||||
long i = 0;
|
long i = 0;
|
||||||
regmmatch_T regmatch;
|
regmmatch_T regmatch;
|
||||||
@@ -4018,11 +4018,11 @@ skip:
|
|||||||
i = curbuf->b_ml.ml_line_count - old_line_count;
|
i = curbuf->b_ml.ml_line_count - old_line_count;
|
||||||
changed_lines(first_line, 0, last_line - i, i, false);
|
changed_lines(first_line, 0, last_line - i, i, false);
|
||||||
|
|
||||||
if (kv_size(curbuf->liveupdate_channels)) {
|
if (kv_size(curbuf->update_channels)) {
|
||||||
int64_t num_added = last_line - first_line;
|
int64_t num_added = last_line - first_line;
|
||||||
int64_t num_removed = num_added - i;
|
int64_t num_removed = num_added - i;
|
||||||
liveupdate_send_changes(curbuf, first_line, num_added, num_removed,
|
buffer_updates_send_changes(curbuf, first_line, num_added, num_removed,
|
||||||
send_liveupdate_changedtick);
|
send_buffer_update_changedtick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
#include "nvim/ex_docmd.h"
|
#include "nvim/ex_docmd.h"
|
||||||
#include "nvim/func_attr.h"
|
#include "nvim/func_attr.h"
|
||||||
#include "nvim/indent.h"
|
#include "nvim/indent.h"
|
||||||
#include "nvim/liveupdate.h"
|
#include "nvim/buffer_updates.h"
|
||||||
#include "nvim/mark.h"
|
#include "nvim/mark.h"
|
||||||
#include "nvim/memline.h"
|
#include "nvim/memline.h"
|
||||||
#include "nvim/memory.h"
|
#include "nvim/memory.h"
|
||||||
@@ -746,14 +746,14 @@ deleteFold (
|
|||||||
if (last_lnum > 0) {
|
if (last_lnum > 0) {
|
||||||
changed_lines(first_lnum, (colnr_T)0, last_lnum, 0L, false);
|
changed_lines(first_lnum, (colnr_T)0, last_lnum, 0L, false);
|
||||||
|
|
||||||
// send one LiveUpdate at the end
|
// send one nvim_buf_update at the end
|
||||||
if (kv_size(curbuf->liveupdate_channels)) {
|
if (kv_size(curbuf->update_channels)) {
|
||||||
// last_lnum is the line *after* the last line of the outermost fold
|
// last_lnum is the line *after* the last line of the outermost fold
|
||||||
// that was modified. Note also that deleting a fold might only require
|
// that was modified. Note also that deleting a fold might only require
|
||||||
// the modification of the *first* line of the fold, but we send through a
|
// 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
|
// notification that includes every line that was part of the fold
|
||||||
int64_t num_changed = last_lnum - first_lnum;
|
int64_t num_changed = last_lnum - first_lnum;
|
||||||
liveupdate_send_changes(curbuf, first_lnum, num_changed,
|
buffer_updates_send_changes(curbuf, first_lnum, num_changed,
|
||||||
num_changed, true);
|
num_changed, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1605,12 +1605,12 @@ static void foldCreateMarkers(linenr_T start, linenr_T end)
|
|||||||
* changed when the start marker is inserted and the end isn't. */
|
* changed when the start marker is inserted and the end isn't. */
|
||||||
changed_lines(start, (colnr_T)0, end, 0L, false);
|
changed_lines(start, (colnr_T)0, end, 0L, false);
|
||||||
|
|
||||||
if (kv_size(curbuf->liveupdate_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 LiveUpdate
|
// u_save() is unable to save the buffer line, but we send the nvim_buf_update
|
||||||
// anyway since it won't do any harm.
|
// anyway since it won't do any harm.
|
||||||
int64_t num_changed = 1 + end - start;
|
int64_t num_changed = 1 + end - start;
|
||||||
liveupdate_send_changes(curbuf, start, num_changed, num_changed, true);
|
buffer_updates_send_changes(curbuf, start, num_changed, num_changed, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,13 +0,0 @@
|
|||||||
#ifndef NVIM_LIVEUPDATE_H
|
|
||||||
#define NVIM_LIVEUPDATE_H
|
|
||||||
|
|
||||||
#include "nvim/buffer_defs.h"
|
|
||||||
|
|
||||||
bool liveupdate_register(buf_T *buf, uint64_t channel_id, bool send_buffer);
|
|
||||||
void liveupdate_unregister(buf_T *buf, uint64_t channel_id);
|
|
||||||
void liveupdate_unregister_all(buf_T *buf);
|
|
||||||
void liveupdate_send_changes(buf_T *buf, linenr_T firstline, int64_t num_added,
|
|
||||||
int64_t num_removed, bool send_tick);
|
|
||||||
void liveupdate_send_tick(buf_T *buf);
|
|
||||||
|
|
||||||
#endif // NVIM_LIVEUPDATE_H
|
|
@@ -28,7 +28,7 @@
|
|||||||
#include "nvim/getchar.h"
|
#include "nvim/getchar.h"
|
||||||
#include "nvim/indent.h"
|
#include "nvim/indent.h"
|
||||||
#include "nvim/indent_c.h"
|
#include "nvim/indent_c.h"
|
||||||
#include "nvim/liveupdate.h"
|
#include "nvim/buffer_updates.h"
|
||||||
#include "nvim/main.h"
|
#include "nvim/main.h"
|
||||||
#include "nvim/mark.h"
|
#include "nvim/mark.h"
|
||||||
#include "nvim/mbyte.h"
|
#include "nvim/mbyte.h"
|
||||||
@@ -1822,8 +1822,8 @@ void changed_bytes(linenr_T lnum, colnr_T col)
|
|||||||
changedOneline(curbuf, lnum);
|
changedOneline(curbuf, lnum);
|
||||||
changed_common(lnum, col, lnum + 1, 0L);
|
changed_common(lnum, col, lnum + 1, 0L);
|
||||||
// notify any channels that are watching
|
// notify any channels that are watching
|
||||||
if (kv_size(curbuf->liveupdate_channels)) {
|
if (kv_size(curbuf->update_channels)) {
|
||||||
liveupdate_send_changes(curbuf, lnum, 1, 1, true);
|
buffer_updates_send_changes(curbuf, lnum, 1, 1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Diff highlighting in other diff windows may need to be updated too. */
|
/* Diff highlighting in other diff windows may need to be updated too. */
|
||||||
@@ -1920,9 +1920,9 @@ changed_lines(
|
|||||||
colnr_T col, // column in first line with change
|
colnr_T col, // column in first line with change
|
||||||
linenr_T lnume, // line below last changed line
|
linenr_T lnume, // line below last changed line
|
||||||
long xtra, // number of extra lines (negative when deleting)
|
long xtra, // number of extra lines (negative when deleting)
|
||||||
bool send_liveupdate // some callers like undo/redo call changed_lines()
|
bool send_update // some callers like undo/redo call changed_lines()
|
||||||
// and then increment b_changedtick *again*. This flag
|
// and then increment b_changedtick *again*. This flag
|
||||||
// allows these callers to send the LiveUpdate events
|
// allows these callers to send the nvim_buf_update events
|
||||||
// after they're done modifying b_changedtick.
|
// after they're done modifying b_changedtick.
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -1948,10 +1948,10 @@ changed_lines(
|
|||||||
|
|
||||||
changed_common(lnum, col, lnume, xtra);
|
changed_common(lnum, col, lnume, xtra);
|
||||||
|
|
||||||
if (send_liveupdate && kv_size(curbuf->liveupdate_channels)) {
|
if (send_update && kv_size(curbuf->update_channels)) {
|
||||||
int64_t num_added = (int64_t)(lnume + xtra - lnum);
|
int64_t num_added = (int64_t)(lnume + xtra - lnum);
|
||||||
int64_t num_removed = lnume - lnum;
|
int64_t num_removed = lnume - lnum;
|
||||||
liveupdate_send_changes(curbuf, lnum, num_added, num_removed, true);
|
buffer_updates_send_changes(curbuf, lnum, num_added, num_removed, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1234,7 +1234,7 @@ static void refresh_screen(Terminal *term, buf_T *buf)
|
|||||||
|
|
||||||
int change_start = row_to_linenr(term, term->invalid_start);
|
int change_start = row_to_linenr(term, term->invalid_start);
|
||||||
int change_end = change_start + changed;
|
int change_end = change_start + changed;
|
||||||
// Note: don't send LiveUpdate event for a :terminal buffer
|
// Note: don't send nvim_buf_update event for a :terminal buffer
|
||||||
changed_lines(change_start, 0, change_end, added, false);
|
changed_lines(change_start, 0, change_end, added, false);
|
||||||
term->invalid_start = INT_MAX;
|
term->invalid_start = INT_MAX;
|
||||||
term->invalid_end = -1;
|
term->invalid_end = -1;
|
||||||
|
@@ -92,7 +92,7 @@
|
|||||||
#include "nvim/eval.h"
|
#include "nvim/eval.h"
|
||||||
#include "nvim/fileio.h"
|
#include "nvim/fileio.h"
|
||||||
#include "nvim/fold.h"
|
#include "nvim/fold.h"
|
||||||
#include "nvim/liveupdate.h"
|
#include "nvim/buffer_updates.h"
|
||||||
#include "nvim/mark.h"
|
#include "nvim/mark.h"
|
||||||
#include "nvim/memline.h"
|
#include "nvim/memline.h"
|
||||||
#include "nvim/message.h"
|
#include "nvim/message.h"
|
||||||
@@ -1698,7 +1698,7 @@ bool u_undo_and_forget(int count)
|
|||||||
count = 1;
|
count = 1;
|
||||||
}
|
}
|
||||||
undo_undoes = true;
|
undo_undoes = true;
|
||||||
// don't send a LiveUpdate for this undo is part of 'inccommand' playing with
|
// don't send a nvim_buf_update for this undo is part of 'inccommand' playing with
|
||||||
// buffer contents
|
// buffer contents
|
||||||
u_doit(count, true, false);
|
u_doit(count, true, false);
|
||||||
|
|
||||||
@@ -1735,7 +1735,7 @@ bool u_undo_and_forget(int count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Undo or redo, depending on `undo_undoes`, `count` times.
|
/// Undo or redo, depending on `undo_undoes`, `count` times.
|
||||||
static void u_doit(int startcount, bool quiet, bool send_liveupdate)
|
static void u_doit(int startcount, bool quiet, bool send_update)
|
||||||
{
|
{
|
||||||
int count = startcount;
|
int count = startcount;
|
||||||
|
|
||||||
@@ -1771,7 +1771,7 @@ static void u_doit(int startcount, bool quiet, bool send_liveupdate)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
u_undoredo(true, send_liveupdate);
|
u_undoredo(true, send_update);
|
||||||
} else {
|
} else {
|
||||||
if (curbuf->b_u_curhead == NULL || get_undolevel() <= 0) {
|
if (curbuf->b_u_curhead == NULL || get_undolevel() <= 0) {
|
||||||
beep_flush(); /* nothing to redo */
|
beep_flush(); /* nothing to redo */
|
||||||
@@ -1782,7 +1782,7 @@ static void u_doit(int startcount, bool quiet, bool send_liveupdate)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
u_undoredo(false, send_liveupdate);
|
u_undoredo(false, send_update);
|
||||||
|
|
||||||
/* Advance for next redo. Set "newhead" when at the end of the
|
/* Advance for next redo. Set "newhead" when at the end of the
|
||||||
* redoable changes. */
|
* redoable changes. */
|
||||||
@@ -2117,7 +2117,7 @@ void undo_time(long step, int sec, int file, int absolute)
|
|||||||
*
|
*
|
||||||
* When "undo" is TRUE we go up in the tree, when FALSE we go down.
|
* When "undo" is TRUE we go up in the tree, when FALSE we go down.
|
||||||
*/
|
*/
|
||||||
static void u_undoredo(int undo, bool send_liveupdate)
|
static void u_undoredo(int undo, bool send_update)
|
||||||
{
|
{
|
||||||
char_u **newarray = NULL;
|
char_u **newarray = NULL;
|
||||||
linenr_T oldsize;
|
linenr_T oldsize;
|
||||||
@@ -2245,7 +2245,7 @@ static void u_undoredo(int undo, bool send_liveupdate)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
changed_lines(top + 1, 0, bot, newsize - oldsize, send_liveupdate);
|
changed_lines(top + 1, 0, bot, newsize - oldsize, send_update);
|
||||||
|
|
||||||
/* set '[ and '] mark */
|
/* set '[ and '] mark */
|
||||||
if (top + 1 < curbuf->b_op_start.lnum)
|
if (top + 1 < curbuf->b_op_start.lnum)
|
||||||
@@ -2281,10 +2281,10 @@ static void u_undoredo(int undo, bool send_liveupdate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// because the calls to changed()/unchanged() above will bump b_changedtick
|
// because the calls to changed()/unchanged() above will bump b_changedtick
|
||||||
// again, we need to send a LiveUpdate with just the new value of
|
// again, we need to send a nvim_buf_update with just the new value of
|
||||||
// b:changedtick
|
// b:changedtick
|
||||||
if (send_liveupdate && kv_size(curbuf->liveupdate_channels)) {
|
if (send_update && kv_size(curbuf->update_channels)) {
|
||||||
liveupdate_send_tick(curbuf);
|
buffer_updates_send_tick(curbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local eq, ok = helpers.eq, helpers.ok
|
local eq, ok = helpers.eq, helpers.ok
|
||||||
local buffer, command, eval, nvim, next_message = helpers.buffer,
|
local buffer, command, eval, nvim, next_message = helpers.buffer,
|
||||||
helpers.command, helpers.eval, helpers.nvim, helpers.next_message
|
helpers.command, helpers.eval, helpers.nvim, helpers.next_msg
|
||||||
|
|
||||||
local origlines = {"original line 1",
|
local origlines = {"original line 1",
|
||||||
"original line 2",
|
"original line 2",
|
||||||
@@ -32,11 +32,11 @@ local function open(activate, lines)
|
|||||||
-- what is the value of b:changedtick?
|
-- what is the value of b:changedtick?
|
||||||
local tick = eval('b:changedtick')
|
local tick = eval('b:changedtick')
|
||||||
|
|
||||||
-- turn on live updates, ensure that the LiveUpdateStart messages
|
-- turn on live updates, ensure that the nvim_buf_updates_start messages
|
||||||
-- arrive as expectected
|
-- arrive as expectected
|
||||||
if activate then
|
if activate then
|
||||||
ok(buffer('live_updates_start', b, true))
|
ok(buffer('attach', b, true))
|
||||||
expectn('LiveUpdateStart', {b, tick, lines, false})
|
expectn('nvim_buf_updates_start', {b, tick, lines, false})
|
||||||
end
|
end
|
||||||
|
|
||||||
return b, tick, filename
|
return b, tick, filename
|
||||||
@@ -52,13 +52,13 @@ local function editoriginal(activate, lines)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function reopen(buf, expectedlines)
|
local function reopen(buf, expectedlines)
|
||||||
ok(buffer('live_updates_stop', buf))
|
ok(buffer('detach', buf))
|
||||||
expectn('LiveUpdateEnd', {buf})
|
expectn('nvim_buf_updates_end', {buf})
|
||||||
-- for some reason the :edit! increments tick by 2
|
-- for some reason the :edit! increments tick by 2
|
||||||
command('edit!')
|
command('edit!')
|
||||||
local tick = eval('b:changedtick')
|
local tick = eval('b:changedtick')
|
||||||
ok(buffer('live_updates_start', buf, true))
|
ok(buffer('attach', buf, true))
|
||||||
expectn('LiveUpdateStart', {buf, tick, expectedlines, false})
|
expectn('nvim_buf_updates_start', {buf, tick, expectedlines, false})
|
||||||
command('normal! gg')
|
command('normal! gg')
|
||||||
return tick
|
return tick
|
||||||
end
|
end
|
||||||
@@ -73,13 +73,13 @@ local function reopenwithfolds(b)
|
|||||||
-- add a fold
|
-- add a fold
|
||||||
command('2,4fold')
|
command('2,4fold')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 1, 4, {'original line 2/*{{{*/',
|
expectn('nvim_buf_update', {b, tick, 1, 4, {'original line 2/*{{{*/',
|
||||||
'original line 3',
|
'original line 3',
|
||||||
'original line 4/*}}}*/'}})
|
'original line 4/*}}}*/'}})
|
||||||
-- make a new fold that wraps lines 1-6
|
-- make a new fold that wraps lines 1-6
|
||||||
command('1,6fold')
|
command('1,6fold')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 6, {'original line 1/*{{{*/',
|
expectn('nvim_buf_update', {b, tick, 0, 6, {'original line 1/*{{{*/',
|
||||||
'original line 2/*{{{*/',
|
'original line 2/*{{{*/',
|
||||||
'original line 3',
|
'original line 3',
|
||||||
'original line 4/*}}}*/',
|
'original line 4/*}}}*/',
|
||||||
@@ -95,30 +95,30 @@ describe('liveupdate', function()
|
|||||||
-- add a new line at the start of the buffer
|
-- add a new line at the start of the buffer
|
||||||
command('normal! GyyggP')
|
command('normal! GyyggP')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 0, {'original line 6'}})
|
expectn('nvim_buf_update', {b, tick, 0, 0, {'original line 6'}})
|
||||||
|
|
||||||
-- add multiple lines at the start of the file
|
-- add multiple lines at the start of the file
|
||||||
command('normal! GkkyGggP')
|
command('normal! GkkyGggP')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 0, {'original line 4',
|
expectn('nvim_buf_update', {b, tick, 0, 0, {'original line 4',
|
||||||
'original line 5',
|
'original line 5',
|
||||||
'original line 6'}})
|
'original line 6'}})
|
||||||
|
|
||||||
-- add one line to the middle of the file, several times
|
-- add one line to the middle of the file, several times
|
||||||
command('normal! ggYjjp')
|
command('normal! ggYjjp')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 3, 3, {'original line 4'}})
|
expectn('nvim_buf_update', {b, tick, 3, 3, {'original line 4'}})
|
||||||
command('normal! p')
|
command('normal! p')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 4, 4, {'original line 4'}})
|
expectn('nvim_buf_update', {b, tick, 4, 4, {'original line 4'}})
|
||||||
command('normal! p')
|
command('normal! p')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 5, 5, {'original line 4'}})
|
expectn('nvim_buf_update', {b, tick, 5, 5, {'original line 4'}})
|
||||||
|
|
||||||
-- add multiple lines to the middle of the file
|
-- add multiple lines to the middle of the file
|
||||||
command('normal! gg4Yjjp')
|
command('normal! gg4Yjjp')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 3, 3, {'original line 4',
|
expectn('nvim_buf_update', {b, tick, 3, 3, {'original line 4',
|
||||||
'original line 5',
|
'original line 5',
|
||||||
'original line 6',
|
'original line 6',
|
||||||
'original line 4'}})
|
'original line 4'}})
|
||||||
@@ -126,16 +126,16 @@ describe('liveupdate', function()
|
|||||||
-- add one line to the end of the file
|
-- add one line to the end of the file
|
||||||
command('normal! ggYGp')
|
command('normal! ggYGp')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 17, 17, {'original line 4'}})
|
expectn('nvim_buf_update', {b, tick, 17, 17, {'original line 4'}})
|
||||||
|
|
||||||
-- add one line to the end of the file, several times
|
-- add one line to the end of the file, several times
|
||||||
command('normal! ggYGppp')
|
command('normal! ggYGppp')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 18, 18, {'original line 4'}})
|
expectn('nvim_buf_update', {b, tick, 18, 18, {'original line 4'}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 19, 19, {'original line 4'}})
|
expectn('nvim_buf_update', {b, tick, 19, 19, {'original line 4'}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 20, 20, {'original line 4'}})
|
expectn('nvim_buf_update', {b, tick, 20, 20, {'original line 4'}})
|
||||||
|
|
||||||
-- add several lines to the end of the file, several times
|
-- add several lines to the end of the file, several times
|
||||||
command('normal! gg4YGp')
|
command('normal! gg4YGp')
|
||||||
@@ -146,47 +146,47 @@ describe('liveupdate', function()
|
|||||||
'original line 6',
|
'original line 6',
|
||||||
'original line 4'}
|
'original line 4'}
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 21, 21, firstfour})
|
expectn('nvim_buf_update', {b, tick, 21, 21, firstfour})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 25, 25, firstfour})
|
expectn('nvim_buf_update', {b, tick, 25, 25, firstfour})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 29, 29, firstfour})
|
expectn('nvim_buf_update', {b, tick, 29, 29, firstfour})
|
||||||
|
|
||||||
-- create a new empty buffer and wipe out the old one ... this will
|
-- create a new empty buffer and wipe out the old one ... this will
|
||||||
-- turn off live updates
|
-- turn off live updates
|
||||||
command('enew!')
|
command('enew!')
|
||||||
expectn('LiveUpdateEnd', {b})
|
expectn('nvim_buf_updates_end', {b})
|
||||||
|
|
||||||
-- add a line at the start of an empty file
|
-- add a line at the start of an empty file
|
||||||
command('enew')
|
command('enew')
|
||||||
tick = eval('b:changedtick')
|
tick = eval('b:changedtick')
|
||||||
local b2 = nvim('get_current_buf')
|
local b2 = nvim('get_current_buf')
|
||||||
ok(buffer('live_updates_start', b2, true))
|
ok(buffer('attach', b2, true))
|
||||||
expectn('LiveUpdateStart', {b2, tick, {""}, false})
|
expectn('nvim_buf_updates_start', {b2, tick, {""}, false})
|
||||||
eval('append(0, ["new line 1"])')
|
eval('append(0, ["new line 1"])')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b2, tick, 0, 0, {'new line 1'}})
|
expectn('nvim_buf_update', {b2, tick, 0, 0, {'new line 1'}})
|
||||||
|
|
||||||
-- turn off live updates manually
|
-- turn off live updates manually
|
||||||
buffer('live_updates_stop', b2)
|
buffer('detach', b2)
|
||||||
expectn('LiveUpdateEnd', {b2})
|
expectn('nvim_buf_updates_end', {b2})
|
||||||
|
|
||||||
-- add multiple lines to a blank file
|
-- add multiple lines to a blank file
|
||||||
command('enew!')
|
command('enew!')
|
||||||
local b3 = nvim('get_current_buf')
|
local b3 = nvim('get_current_buf')
|
||||||
ok(buffer('live_updates_start', b3, true))
|
ok(buffer('attach', b3, true))
|
||||||
tick = eval('b:changedtick')
|
tick = eval('b:changedtick')
|
||||||
expectn('LiveUpdateStart', {b3, tick, {""}, false})
|
expectn('nvim_buf_updates_start', {b3, tick, {""}, false})
|
||||||
eval('append(0, ["new line 1", "new line 2", "new line 3"])')
|
eval('append(0, ["new line 1", "new line 2", "new line 3"])')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b3, tick, 0, 0, {'new line 1',
|
expectn('nvim_buf_update', {b3, tick, 0, 0, {'new line 1',
|
||||||
'new line 2',
|
'new line 2',
|
||||||
'new line 3'}})
|
'new line 3'}})
|
||||||
|
|
||||||
-- use the API itself to add a line to the start of the buffer
|
-- use the API itself to add a line to the start of the buffer
|
||||||
buffer('set_lines', b3, 0, 0, true, {'New First Line'})
|
buffer('set_lines', b3, 0, 0, true, {'New First Line'})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b3, tick, 0, 0, {"New First Line"}})
|
expectn('nvim_buf_update', {b3, tick, 0, 0, {"New First Line"}})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('knows when you remove lines from a buffer', function()
|
it('knows when you remove lines from a buffer', function()
|
||||||
@@ -195,37 +195,37 @@ describe('liveupdate', function()
|
|||||||
-- remove one line from start of file
|
-- remove one line from start of file
|
||||||
command('normal! dd')
|
command('normal! dd')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 1, {}})
|
expectn('nvim_buf_update', {b, tick, 0, 1, {}})
|
||||||
|
|
||||||
-- remove multiple lines from the start of the file
|
-- remove multiple lines from the start of the file
|
||||||
command('normal! 4dd')
|
command('normal! 4dd')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 4, {}})
|
expectn('nvim_buf_update', {b, tick, 0, 4, {}})
|
||||||
|
|
||||||
-- remove multiple lines from middle of file
|
-- remove multiple lines from middle of file
|
||||||
tick = reopen(b, origlines)
|
tick = reopen(b, origlines)
|
||||||
command('normal! jj3dd')
|
command('normal! jj3dd')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 2, 5, {}})
|
expectn('nvim_buf_update', {b, tick, 2, 5, {}})
|
||||||
|
|
||||||
-- remove one line from the end of the file
|
-- remove one line from the end of the file
|
||||||
tick = reopen(b, origlines)
|
tick = reopen(b, origlines)
|
||||||
command('normal! Gdd')
|
command('normal! Gdd')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 5, 6, {}})
|
expectn('nvim_buf_update', {b, tick, 5, 6, {}})
|
||||||
|
|
||||||
-- remove multiple lines from the end of the file
|
-- remove multiple lines from the end of the file
|
||||||
tick = reopen(b, origlines)
|
tick = reopen(b, origlines)
|
||||||
command('normal! 4G3dd')
|
command('normal! 4G3dd')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 3, 6, {}})
|
expectn('nvim_buf_update', {b, tick, 3, 6, {}})
|
||||||
|
|
||||||
-- pretend to remove heaps lines from the end of the file but really
|
-- pretend to remove heaps lines from the end of the file but really
|
||||||
-- just remove two
|
-- just remove two
|
||||||
tick = reopen(b, origlines)
|
tick = reopen(b, origlines)
|
||||||
command('normal! Gk5dd')
|
command('normal! Gk5dd')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 4, 6, {}})
|
expectn('nvim_buf_update', {b, tick, 4, 6, {}})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('knows when you modify lines of text', function()
|
it('knows when you modify lines of text', function()
|
||||||
@@ -234,53 +234,53 @@ describe('liveupdate', function()
|
|||||||
-- some normal text editing
|
-- some normal text editing
|
||||||
command('normal! A555')
|
command('normal! A555')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 1, {'original line 1555'}})
|
expectn('nvim_buf_update', {b, tick, 0, 1, {'original line 1555'}})
|
||||||
command('normal! jj8X')
|
command('normal! jj8X')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 2, 3, {'origin3'}})
|
expectn('nvim_buf_update', {b, tick, 2, 3, {'origin3'}})
|
||||||
|
|
||||||
-- modify multiple lines at once using visual block mode
|
-- modify multiple lines at once using visual block mode
|
||||||
tick = reopen(b, origlines)
|
tick = reopen(b, origlines)
|
||||||
command('normal! jjw')
|
command('normal! jjw')
|
||||||
sendkeys('\x16jjllx')
|
sendkeys('\x16jjllx')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate',
|
expectn('nvim_buf_update',
|
||||||
{b, tick, 2, 5, {'original e 3', 'original e 4', 'original e 5'}})
|
{b, tick, 2, 5, {'original e 3', 'original e 4', 'original e 5'}})
|
||||||
|
|
||||||
-- replace part of a line line using :s
|
-- replace part of a line line using :s
|
||||||
tick = reopen(b, origlines)
|
tick = reopen(b, origlines)
|
||||||
command('3s/line 3/foo/')
|
command('3s/line 3/foo/')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 2, 3, {'original foo'}})
|
expectn('nvim_buf_update', {b, tick, 2, 3, {'original foo'}})
|
||||||
|
|
||||||
-- replace parts of several lines line using :s
|
-- replace parts of several lines line using :s
|
||||||
tick = reopen(b, origlines)
|
tick = reopen(b, origlines)
|
||||||
command('%s/line [35]/foo/')
|
command('%s/line [35]/foo/')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 2, 5, {'original foo',
|
expectn('nvim_buf_update', {b, tick, 2, 5, {'original foo',
|
||||||
'original line 4',
|
'original line 4',
|
||||||
'original foo'}})
|
'original foo'}})
|
||||||
|
|
||||||
-- type text into the first line of a blank file, one character at a time
|
-- type text into the first line of a blank file, one character at a time
|
||||||
command('enew!')
|
command('enew!')
|
||||||
tick = 2
|
tick = 2
|
||||||
expectn('LiveUpdateEnd', {b})
|
expectn('nvim_buf_updates_end', {b})
|
||||||
local bnew = nvim('get_current_buf')
|
local bnew = nvim('get_current_buf')
|
||||||
ok(buffer('live_updates_start', bnew, true))
|
ok(buffer('attach', bnew, true))
|
||||||
expectn('LiveUpdateStart', {bnew, tick, {''}, false})
|
expectn('nvim_buf_updates_start', {bnew, tick, {''}, false})
|
||||||
sendkeys('i')
|
sendkeys('i')
|
||||||
sendkeys('h')
|
sendkeys('h')
|
||||||
sendkeys('e')
|
sendkeys('e')
|
||||||
sendkeys('l')
|
sendkeys('l')
|
||||||
sendkeys('l')
|
sendkeys('l')
|
||||||
sendkeys('o\nworld')
|
sendkeys('o\nworld')
|
||||||
expectn('LiveUpdate', {bnew, tick + 1, 0, 1, {'h'}})
|
expectn('nvim_buf_update', {bnew, tick + 1, 0, 1, {'h'}})
|
||||||
expectn('LiveUpdate', {bnew, tick + 2, 0, 1, {'he'}})
|
expectn('nvim_buf_update', {bnew, tick + 2, 0, 1, {'he'}})
|
||||||
expectn('LiveUpdate', {bnew, tick + 3, 0, 1, {'hel'}})
|
expectn('nvim_buf_update', {bnew, tick + 3, 0, 1, {'hel'}})
|
||||||
expectn('LiveUpdate', {bnew, tick + 4, 0, 1, {'hell'}})
|
expectn('nvim_buf_update', {bnew, tick + 4, 0, 1, {'hell'}})
|
||||||
expectn('LiveUpdate', {bnew, tick + 5, 0, 1, {'hello'}})
|
expectn('nvim_buf_update', {bnew, tick + 5, 0, 1, {'hello'}})
|
||||||
expectn('LiveUpdate', {bnew, tick + 6, 0, 1, {'hello', ''}})
|
expectn('nvim_buf_update', {bnew, tick + 6, 0, 1, {'hello', ''}})
|
||||||
expectn('LiveUpdate', {bnew, tick + 7, 1, 2, {'world'}})
|
expectn('nvim_buf_update', {bnew, tick + 7, 1, 2, {'world'}})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('knows when you replace lines', function()
|
it('knows when you replace lines', function()
|
||||||
@@ -289,23 +289,23 @@ describe('liveupdate', function()
|
|||||||
-- blast away parts of some lines with visual mode
|
-- blast away parts of some lines with visual mode
|
||||||
command('normal! jjwvjjllx')
|
command('normal! jjwvjjllx')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 2, 3, {'original '}})
|
expectn('nvim_buf_update', {b, tick, 2, 3, {'original '}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 3, 4, {}})
|
expectn('nvim_buf_update', {b, tick, 3, 4, {}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 3, 4, {'e 5'}})
|
expectn('nvim_buf_update', {b, tick, 3, 4, {'e 5'}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 2, 3, {'original e 5'}})
|
expectn('nvim_buf_update', {b, tick, 2, 3, {'original e 5'}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 3, 4, {}})
|
expectn('nvim_buf_update', {b, tick, 3, 4, {}})
|
||||||
|
|
||||||
-- blast away a few lines using :g
|
-- blast away a few lines using :g
|
||||||
tick = reopen(b, origlines)
|
tick = reopen(b, origlines)
|
||||||
command('global/line [35]/delete')
|
command('global/line [35]/delete')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 2, 3, {}})
|
expectn('nvim_buf_update', {b, tick, 2, 3, {}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 3, 4, {}})
|
expectn('nvim_buf_update', {b, tick, 3, 4, {}})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('knows when you filter lines', function()
|
it('knows when you filter lines', function()
|
||||||
@@ -317,9 +317,9 @@ describe('liveupdate', function()
|
|||||||
-- 1) addition of the new lines after the filtered lines
|
-- 1) addition of the new lines after the filtered lines
|
||||||
-- 2) removal of the original lines
|
-- 2) removal of the original lines
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 5, 5, {"C", "E", "B", "D"}})
|
expectn('nvim_buf_update', {b, tick, 5, 5, {"C", "E", "B", "D"}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 1, 5, {}})
|
expectn('nvim_buf_update', {b, tick, 1, 5, {}})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('sends a sensible event when you use "o"', function()
|
it('sends a sensible event when you use "o"', function()
|
||||||
@@ -329,37 +329,37 @@ describe('liveupdate', function()
|
|||||||
-- use 'o' to start a new line from a line with no indent
|
-- use 'o' to start a new line from a line with no indent
|
||||||
command('normal! o')
|
command('normal! o')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 1, 1, {""}})
|
expectn('nvim_buf_update', {b, tick, 1, 1, {""}})
|
||||||
|
|
||||||
-- undo the change, indent line 1 a bit, and try again
|
-- undo the change, indent line 1 a bit, and try again
|
||||||
command('undo')
|
command('undo')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 1, 2, {}})
|
expectn('nvim_buf_update', {b, tick, 1, 2, {}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdateTick', {b, tick})
|
expectn('nvim_buf_update_tick', {b, tick})
|
||||||
command('set autoindent')
|
command('set autoindent')
|
||||||
command('normal! >>')
|
command('normal! >>')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 1, {"\tAAA"}})
|
expectn('nvim_buf_update', {b, tick, 0, 1, {"\tAAA"}})
|
||||||
command('normal! ommm')
|
command('normal! ommm')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 1, 1, {"\t"}})
|
expectn('nvim_buf_update', {b, tick, 1, 1, {"\t"}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 1, 2, {"\tmmm"}})
|
expectn('nvim_buf_update', {b, tick, 1, 2, {"\tmmm"}})
|
||||||
|
|
||||||
-- undo the change, and try again with 'O'
|
-- undo the change, and try again with 'O'
|
||||||
command('undo')
|
command('undo')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 1, 2, {'\t'}})
|
expectn('nvim_buf_update', {b, tick, 1, 2, {'\t'}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 1, 2, {}})
|
expectn('nvim_buf_update', {b, tick, 1, 2, {}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdateTick', {b, tick})
|
expectn('nvim_buf_update_tick', {b, tick})
|
||||||
command('normal! ggOmmm')
|
command('normal! ggOmmm')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 0, {"\t"}})
|
expectn('nvim_buf_update', {b, tick, 0, 0, {"\t"}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 1, {"\tmmm"}})
|
expectn('nvim_buf_update', {b, tick, 0, 1, {"\tmmm"}})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('deactivates when your buffer changes outside vim', function()
|
it('deactivates when your buffer changes outside vim', function()
|
||||||
@@ -369,12 +369,12 @@ describe('liveupdate', function()
|
|||||||
|
|
||||||
command('normal! x')
|
command('normal! x')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 1, {'ine 1'}})
|
expectn('nvim_buf_update', {b, tick, 0, 1, {'ine 1'}})
|
||||||
command('undo')
|
command('undo')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 1, {'Line 1'}})
|
expectn('nvim_buf_update', {b, tick, 0, 1, {'Line 1'}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdateTick', {b, tick})
|
expectn('nvim_buf_update_tick', {b, tick})
|
||||||
|
|
||||||
-- change the file directly
|
-- change the file directly
|
||||||
local f = io.open(filename, 'a')
|
local f = io.open(filename, 'a')
|
||||||
@@ -384,7 +384,7 @@ describe('liveupdate', function()
|
|||||||
|
|
||||||
-- reopen the file and watch live updates shut down
|
-- reopen the file and watch live updates shut down
|
||||||
command('edit')
|
command('edit')
|
||||||
expectn('LiveUpdateEnd', {b})
|
expectn('nvim_buf_updates_end', {b})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('allows a channel to watch multiple buffers at once', function()
|
it('allows a channel to watch multiple buffers at once', function()
|
||||||
@@ -405,32 +405,32 @@ describe('liveupdate', function()
|
|||||||
command('b'..b1nr)
|
command('b'..b1nr)
|
||||||
command('normal! x')
|
command('normal! x')
|
||||||
tick1 = tick1 + 1
|
tick1 = tick1 + 1
|
||||||
expectn('LiveUpdate', {b1, tick1, 0, 1, {'1'}})
|
expectn('nvim_buf_update', {b1, tick1, 0, 1, {'1'}})
|
||||||
command('undo')
|
command('undo')
|
||||||
tick1 = tick1 + 1
|
tick1 = tick1 + 1
|
||||||
expectn('LiveUpdate', {b1, tick1, 0, 1, {'A1'}})
|
expectn('nvim_buf_update', {b1, tick1, 0, 1, {'A1'}})
|
||||||
tick1 = tick1 + 1
|
tick1 = tick1 + 1
|
||||||
expectn('LiveUpdateTick', {b1, tick1})
|
expectn('nvim_buf_update_tick', {b1, tick1})
|
||||||
|
|
||||||
command('b'..b2nr)
|
command('b'..b2nr)
|
||||||
command('normal! x')
|
command('normal! x')
|
||||||
tick2 = tick2 + 1
|
tick2 = tick2 + 1
|
||||||
expectn('LiveUpdate', {b2, tick2, 0, 1, {'1'}})
|
expectn('nvim_buf_update', {b2, tick2, 0, 1, {'1'}})
|
||||||
command('undo')
|
command('undo')
|
||||||
tick2 = tick2 + 1
|
tick2 = tick2 + 1
|
||||||
expectn('LiveUpdate', {b2, tick2, 0, 1, {'B1'}})
|
expectn('nvim_buf_update', {b2, tick2, 0, 1, {'B1'}})
|
||||||
tick2 = tick2 + 1
|
tick2 = tick2 + 1
|
||||||
expectn('LiveUpdateTick', {b2, tick2})
|
expectn('nvim_buf_update_tick', {b2, tick2})
|
||||||
|
|
||||||
command('b'..b3nr)
|
command('b'..b3nr)
|
||||||
command('normal! x')
|
command('normal! x')
|
||||||
tick3 = tick3 + 1
|
tick3 = tick3 + 1
|
||||||
expectn('LiveUpdate', {b3, tick3, 0, 1, {'1'}})
|
expectn('nvim_buf_update', {b3, tick3, 0, 1, {'1'}})
|
||||||
command('undo')
|
command('undo')
|
||||||
tick3 = tick3 + 1
|
tick3 = tick3 + 1
|
||||||
expectn('LiveUpdate', {b3, tick3, 0, 1, {'C1'}})
|
expectn('nvim_buf_update', {b3, tick3, 0, 1, {'C1'}})
|
||||||
tick3 = tick3 + 1
|
tick3 = tick3 + 1
|
||||||
expectn('LiveUpdateTick', {b3, tick3})
|
expectn('nvim_buf_update_tick', {b3, tick3})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('doesn\'t get confused when you turn watching on/off many times',
|
it('doesn\'t get confused when you turn watching on/off many times',
|
||||||
@@ -439,22 +439,22 @@ describe('liveupdate', function()
|
|||||||
local b, tick = editoriginal(false)
|
local b, tick = editoriginal(false)
|
||||||
|
|
||||||
-- turn on live updates many times
|
-- turn on live updates many times
|
||||||
ok(buffer('live_updates_start', b, true))
|
ok(buffer('attach', b, true))
|
||||||
ok(buffer('live_updates_start', b, true))
|
ok(buffer('attach', b, true))
|
||||||
ok(buffer('live_updates_start', b, true))
|
ok(buffer('attach', b, true))
|
||||||
ok(buffer('live_updates_start', b, true))
|
ok(buffer('attach', b, true))
|
||||||
ok(buffer('live_updates_start', b, true))
|
ok(buffer('attach', b, true))
|
||||||
expectn('LiveUpdateStart', {b, tick, origlines, false})
|
expectn('nvim_buf_updates_start', {b, tick, origlines, false})
|
||||||
eval('rpcnotify('..channel..', "Hello There")')
|
eval('rpcnotify('..channel..', "Hello There")')
|
||||||
expectn('Hello There', {})
|
expectn('Hello There', {})
|
||||||
|
|
||||||
-- turn live updates off many times
|
-- turn live updates off many times
|
||||||
ok(buffer('live_updates_stop', b))
|
ok(buffer('detach', b))
|
||||||
ok(buffer('live_updates_stop', b))
|
ok(buffer('detach', b))
|
||||||
ok(buffer('live_updates_stop', b))
|
ok(buffer('detach', b))
|
||||||
ok(buffer('live_updates_stop', b))
|
ok(buffer('detach', b))
|
||||||
ok(buffer('live_updates_stop', b))
|
ok(buffer('detach', b))
|
||||||
expectn('LiveUpdateEnd', {b})
|
expectn('nvim_buf_updates_end', {b})
|
||||||
eval('rpcnotify('..channel..', "Hello Again")')
|
eval('rpcnotify('..channel..', "Hello Again")')
|
||||||
expectn('Hello Again', {})
|
expectn('Hello Again', {})
|
||||||
end)
|
end)
|
||||||
@@ -488,46 +488,46 @@ describe('liveupdate', function()
|
|||||||
local b, tick = open(false, lines)
|
local b, tick = open(false, lines)
|
||||||
|
|
||||||
-- turn on live updates for sessions 1, 2 and 3
|
-- turn on live updates for sessions 1, 2 and 3
|
||||||
ok(request(1, 'nvim_buf_live_updates_start', b, true))
|
ok(request(1, 'nvim_buf_attach', b, true))
|
||||||
ok(request(2, 'nvim_buf_live_updates_start', b, true))
|
ok(request(2, 'nvim_buf_attach', b, true))
|
||||||
ok(request(3, 'nvim_buf_live_updates_start', b, true))
|
ok(request(3, 'nvim_buf_attach', b, true))
|
||||||
wantn(1, 'LiveUpdateStart', {b, tick, lines, false})
|
wantn(1, 'nvim_buf_updates_start', {b, tick, lines, false})
|
||||||
wantn(2, 'LiveUpdateStart', {b, tick, lines, false})
|
wantn(2, 'nvim_buf_updates_start', {b, tick, lines, false})
|
||||||
wantn(3, 'LiveUpdateStart', {b, tick, lines, false})
|
wantn(3, 'nvim_buf_updates_start', {b, tick, lines, false})
|
||||||
|
|
||||||
-- make a change to the buffer
|
-- make a change to the buffer
|
||||||
command('normal! x')
|
command('normal! x')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
wantn(1, 'LiveUpdate', {b, tick, 0, 1, {'AA'}})
|
wantn(1, 'nvim_buf_update', {b, tick, 0, 1, {'AA'}})
|
||||||
wantn(2, 'LiveUpdate', {b, tick, 0, 1, {'AA'}})
|
wantn(2, 'nvim_buf_update', {b, tick, 0, 1, {'AA'}})
|
||||||
wantn(3, 'LiveUpdate', {b, tick, 0, 1, {'AA'}})
|
wantn(3, 'nvim_buf_update', {b, tick, 0, 1, {'AA'}})
|
||||||
|
|
||||||
-- stop watching on channel 1
|
-- stop watching on channel 1
|
||||||
ok(request(1, 'nvim_buf_live_updates_stop', b))
|
ok(request(1, 'nvim_buf_detach', b))
|
||||||
wantn(1, 'LiveUpdateEnd', {b})
|
wantn(1, 'nvim_buf_updates_end', {b})
|
||||||
|
|
||||||
-- undo the change to buffer 1
|
-- undo the change to buffer 1
|
||||||
command('undo')
|
command('undo')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
wantn(2, 'LiveUpdate', {b, tick, 0, 1, {'AAA'}})
|
wantn(2, 'nvim_buf_update', {b, tick, 0, 1, {'AAA'}})
|
||||||
wantn(3, 'LiveUpdate', {b, tick, 0, 1, {'AAA'}})
|
wantn(3, 'nvim_buf_update', {b, tick, 0, 1, {'AAA'}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
wantn(2, 'LiveUpdateTick', {b, tick})
|
wantn(2, 'nvim_buf_update_tick', {b, tick})
|
||||||
wantn(3, 'LiveUpdateTick', {b, tick})
|
wantn(3, 'nvim_buf_update_tick', {b, tick})
|
||||||
|
|
||||||
-- make sure there are no other pending LiveUpdate messages going to
|
-- make sure there are no other pending nvim_buf_update messages going to
|
||||||
-- channel 1
|
-- channel 1
|
||||||
local channel1 = request(1, 'nvim_get_api_info')[1]
|
local channel1 = request(1, 'nvim_get_api_info')[1]
|
||||||
eval('rpcnotify('..channel1..', "Hello")')
|
eval('rpcnotify('..channel1..', "Hello")')
|
||||||
wantn(1, 'Hello', {})
|
wantn(1, 'Hello', {})
|
||||||
|
|
||||||
-- close the buffer and channels 2 and 3 should get a LiveUpdateEnd
|
-- close the buffer and channels 2 and 3 should get a nvim_buf_updates_end
|
||||||
-- notification
|
-- notification
|
||||||
command('edit')
|
command('edit')
|
||||||
wantn(2, 'LiveUpdateEnd', {b})
|
wantn(2, 'nvim_buf_updates_end', {b})
|
||||||
wantn(3, 'LiveUpdateEnd', {b})
|
wantn(3, 'nvim_buf_updates_end', {b})
|
||||||
|
|
||||||
-- make sure there are no other pending LiveUpdate messages going to
|
-- make sure there are no other pending nvim_buf_update messages going to
|
||||||
-- channel 1
|
-- channel 1
|
||||||
channel1 = request(1, 'nvim_get_api_info')[1]
|
channel1 = request(1, 'nvim_get_api_info')[1]
|
||||||
eval('rpcnotify('..channel1..', "Hello Again")')
|
eval('rpcnotify('..channel1..', "Hello Again")')
|
||||||
@@ -550,13 +550,13 @@ describe('liveupdate', function()
|
|||||||
command('normal! gg')
|
command('normal! gg')
|
||||||
command('diffput')
|
command('diffput')
|
||||||
tick2 = tick2 + 1
|
tick2 = tick2 + 1
|
||||||
expectn('LiveUpdate', {b2, tick2, 0, 0, {"AAA"}})
|
expectn('nvim_buf_update', {b2, tick2, 0, 0, {"AAA"}})
|
||||||
|
|
||||||
-- use :diffget to grab the other change from buffer 2
|
-- use :diffget to grab the other change from buffer 2
|
||||||
command('normal! G')
|
command('normal! G')
|
||||||
command('diffget')
|
command('diffget')
|
||||||
tick1 = tick1 + 1
|
tick1 = tick1 + 1
|
||||||
expectn('LiveUpdate', {b1, tick1, 2, 2, {"CCC"}})
|
expectn('nvim_buf_update', {b1, tick1, 2, 2, {"CCC"}})
|
||||||
|
|
||||||
eval('rpcnotify('..channel..', "Goodbye")')
|
eval('rpcnotify('..channel..', "Goodbye")')
|
||||||
expectn('Goodbye', {})
|
expectn('Goodbye', {})
|
||||||
@@ -567,14 +567,14 @@ describe('liveupdate', function()
|
|||||||
local b, tick = editoriginal(true, {"B", "D", "C", "A", "E"})
|
local b, tick = editoriginal(true, {"B", "D", "C", "A", "E"})
|
||||||
command('%sort')
|
command('%sort')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 5, {"A", "B", "C", "D", "E"}})
|
expectn('nvim_buf_update', {b, tick, 0, 5, {"A", "B", "C", "D", "E"}})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works with :left', function()
|
it('works with :left', function()
|
||||||
local b, tick = editoriginal(true, {" A", " B", "B", "\tB", "\t\tC"})
|
local b, tick = editoriginal(true, {" A", " B", "B", "\tB", "\t\tC"})
|
||||||
command('2,4left')
|
command('2,4left')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 1, 4, {"B", "B", "B"}})
|
expectn('nvim_buf_update', {b, tick, 1, 4, {"B", "B", "B"}})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works with :right', function()
|
it('works with :right', function()
|
||||||
@@ -586,7 +586,7 @@ describe('liveupdate', function()
|
|||||||
command('set ts=2 et')
|
command('set ts=2 et')
|
||||||
command('2,4retab')
|
command('2,4retab')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 1, 4, {" B", " BB", " B"}})
|
expectn('nvim_buf_update', {b, tick, 1, 4, {" B", " BB", " B"}})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works with :move', function()
|
it('works with :move', function()
|
||||||
@@ -594,19 +594,19 @@ describe('liveupdate', function()
|
|||||||
-- move text down towards the end of the file
|
-- move text down towards the end of the file
|
||||||
command('2,3move 4')
|
command('2,3move 4')
|
||||||
tick = tick + 2
|
tick = tick + 2
|
||||||
expectn('LiveUpdate', {b, tick, 4, 4, {"original line 2",
|
expectn('nvim_buf_update', {b, tick, 4, 4, {"original line 2",
|
||||||
"original line 3"}})
|
"original line 3"}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 1, 3, {}})
|
expectn('nvim_buf_update', {b, tick, 1, 3, {}})
|
||||||
|
|
||||||
-- move text up towards the start of the file
|
-- move text up towards the start of the file
|
||||||
tick = reopen(b, origlines)
|
tick = reopen(b, origlines)
|
||||||
command('4,5move 2')
|
command('4,5move 2')
|
||||||
tick = tick + 2
|
tick = tick + 2
|
||||||
expectn('LiveUpdate', {b, tick, 2, 2, {"original line 4",
|
expectn('nvim_buf_update', {b, tick, 2, 2, {"original line 4",
|
||||||
"original line 5"}})
|
"original line 5"}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 5, 7, {}})
|
expectn('nvim_buf_update', {b, tick, 5, 7, {}})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('sends sensible events when you manually add/remove folds', function()
|
it('sends sensible events when you manually add/remove folds', function()
|
||||||
@@ -616,13 +616,13 @@ describe('liveupdate', function()
|
|||||||
-- delete the inner fold
|
-- delete the inner fold
|
||||||
command('normal! zR3Gzd')
|
command('normal! zR3Gzd')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 1, 4, {'original line 2',
|
expectn('nvim_buf_update', {b, tick, 1, 4, {'original line 2',
|
||||||
'original line 3',
|
'original line 3',
|
||||||
'original line 4'}})
|
'original line 4'}})
|
||||||
-- delete the outer fold
|
-- delete the outer fold
|
||||||
command('normal! zd')
|
command('normal! zd')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 6, origlines})
|
expectn('nvim_buf_update', {b, tick, 0, 6, origlines})
|
||||||
|
|
||||||
-- discard changes and put the folds back
|
-- discard changes and put the folds back
|
||||||
tick = reopenwithfolds(b)
|
tick = reopenwithfolds(b)
|
||||||
@@ -630,7 +630,7 @@ describe('liveupdate', function()
|
|||||||
-- remove both folds at once
|
-- remove both folds at once
|
||||||
command('normal! ggzczD')
|
command('normal! ggzczD')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 6, origlines})
|
expectn('nvim_buf_update', {b, tick, 0, 6, origlines})
|
||||||
|
|
||||||
-- discard changes and put the folds back
|
-- discard changes and put the folds back
|
||||||
tick = reopenwithfolds(b)
|
tick = reopenwithfolds(b)
|
||||||
@@ -638,17 +638,17 @@ describe('liveupdate', function()
|
|||||||
-- now delete all folds at once
|
-- now delete all folds at once
|
||||||
command('normal! zE')
|
command('normal! zE')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 6, origlines})
|
expectn('nvim_buf_update', {b, tick, 0, 6, origlines})
|
||||||
|
|
||||||
-- create a fold from line 4 to the end of the file
|
-- create a fold from line 4 to the end of the file
|
||||||
command('normal! 4GA/*{{{*/')
|
command('normal! 4GA/*{{{*/')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 3, 4, {'original line 4/*{{{*/'}})
|
expectn('nvim_buf_update', {b, tick, 3, 4, {'original line 4/*{{{*/'}})
|
||||||
|
|
||||||
-- delete the fold which only has one marker
|
-- delete the fold which only has one marker
|
||||||
command('normal! Gzd')
|
command('normal! Gzd')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 3, 6, {'original line 4',
|
expectn('nvim_buf_update', {b, tick, 3, 6, {'original line 4',
|
||||||
'original line 5',
|
'original line 5',
|
||||||
'original line 6'}})
|
'original line 6'}})
|
||||||
end)
|
end)
|
||||||
@@ -660,16 +660,16 @@ describe('liveupdate', function()
|
|||||||
-- test live updates are working
|
-- test live updates are working
|
||||||
command('normal! x')
|
command('normal! x')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 1, {'AA'}})
|
expectn('nvim_buf_update', {b, tick, 0, 1, {'AA'}})
|
||||||
command('undo')
|
command('undo')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 1, {'AAA'}})
|
expectn('nvim_buf_update', {b, tick, 0, 1, {'AAA'}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdateTick', {b, tick})
|
expectn('nvim_buf_update_tick', {b, tick})
|
||||||
|
|
||||||
-- close our buffer by creating a new one
|
-- close our buffer by creating a new one
|
||||||
command('enew')
|
command('enew')
|
||||||
expectn('LiveUpdateEnd', {b})
|
expectn('nvim_buf_updates_end', {b})
|
||||||
|
|
||||||
-- reopen the original buffer, make sure there are no Live Updates sent
|
-- reopen the original buffer, make sure there are no Live Updates sent
|
||||||
command('b1')
|
command('b1')
|
||||||
@@ -687,18 +687,18 @@ describe('liveupdate', function()
|
|||||||
-- test live updates are working
|
-- test live updates are working
|
||||||
command('normal! x')
|
command('normal! x')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 1, {'AA'}})
|
expectn('nvim_buf_update', {b, tick, 0, 1, {'AA'}})
|
||||||
command('undo')
|
command('undo')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 1, {'AAA'}})
|
expectn('nvim_buf_update', {b, tick, 0, 1, {'AAA'}})
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdateTick', {b, tick})
|
expectn('nvim_buf_update_tick', {b, tick})
|
||||||
|
|
||||||
-- close our buffer by creating a new one
|
-- close our buffer by creating a new one
|
||||||
command('set hidden')
|
command('set hidden')
|
||||||
command('enew')
|
command('enew')
|
||||||
|
|
||||||
-- note that no LiveUpdateEnd is sent
|
-- note that no nvim_buf_updates_end is sent
|
||||||
eval('rpcnotify('..channel..', "Hello There")')
|
eval('rpcnotify('..channel..', "Hello There")')
|
||||||
expectn('Hello There', {})
|
expectn('Hello There', {})
|
||||||
|
|
||||||
@@ -706,7 +706,7 @@ describe('liveupdate', function()
|
|||||||
command('b1')
|
command('b1')
|
||||||
command('normal! x')
|
command('normal! x')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
expectn('LiveUpdate', {b, tick, 0, 1, {'AA'}})
|
expectn('nvim_buf_update', {b, tick, 0, 1, {'AA'}})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('turns off live updates when a buffer is unloaded, deleted, or wiped',
|
it('turns off live updates when a buffer is unloaded, deleted, or wiped',
|
||||||
@@ -721,17 +721,17 @@ describe('liveupdate', function()
|
|||||||
local b = open(true, {'AAA'})
|
local b = open(true, {'AAA'})
|
||||||
|
|
||||||
-- call :bunload or whatever the command is, and then check that we
|
-- call :bunload or whatever the command is, and then check that we
|
||||||
-- receive a LiveUpdateEnd
|
-- receive a nvim_buf_updates_end
|
||||||
command(cmd)
|
command(cmd)
|
||||||
expectn('LiveUpdateEnd', {b})
|
expectn('nvim_buf_updates_end', {b})
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('doesn\'t send the buffer\'s content when not requested', function()
|
it('doesn\'t send the buffer\'s content when not requested', function()
|
||||||
helpers.clear()
|
helpers.clear()
|
||||||
local b, tick = editoriginal(false)
|
local b, tick = editoriginal(false)
|
||||||
ok(buffer('live_updates_start', b, false))
|
ok(buffer('attach', b, false))
|
||||||
expectn('LiveUpdateStart', {b, tick, {}, false})
|
expectn('nvim_buf_updates_start', {b, tick, {}, false})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
end)
|
end)
|
Reference in New Issue
Block a user