feat(buffer_updates): allow ignoring when previewing

Also adds a test that we actually subscribe to buffer events when in
CMDPREVIEW.
This commit is contained in:
Thomas Vigouroux
2020-12-15 22:18:35 +01:00
parent d0112693a3
commit 25e20da550
5 changed files with 33 additions and 7 deletions

View File

@@ -237,7 +237,7 @@ void buf_updates_send_changes(buf_T *buf,
for (size_t i = 0; i < kv_size(buf->update_callbacks); i++) {
BufUpdateCallbacks cb = kv_A(buf->update_callbacks, i);
bool keep = true;
if (cb.on_lines != LUA_NOREF) {
if (cb.on_lines != LUA_NOREF && (cb.preview || !(State & CMDPREVIEW))) {
Array args = ARRAY_DICT_INIT;
Object items[8];
args.size = 6; // may be increased to 8 below
@@ -298,7 +298,7 @@ void buf_updates_send_splice(
for (size_t i = 0; i < kv_size(buf->update_callbacks); i++) {
BufUpdateCallbacks cb = kv_A(buf->update_callbacks, i);
bool keep = true;
if (cb.on_bytes != LUA_NOREF) {
if (cb.on_bytes != LUA_NOREF && (cb.preview || !(State & CMDPREVIEW))) {
FIXED_TEMP_ARRAY(args, 11);
// the first argument is always the buffer handle