aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/private/converter.c3
-rw-r--r--src/nvim/autocmd.c11
-rw-r--r--src/nvim/eval.c12
-rw-r--r--src/nvim/lua/converter.c3
-rw-r--r--src/nvim/ops.c4
-rw-r--r--src/nvim/tui/input.c48
6 files changed, 41 insertions, 40 deletions
diff --git a/src/nvim/api/private/converter.c b/src/nvim/api/private/converter.c
index 82ec1ad0d8..a26383ec7d 100644
--- a/src/nvim/api/private/converter.c
+++ b/src/nvim/api/private/converter.c
@@ -65,8 +65,7 @@ typedef struct {
#define TYPVAL_ENCODE_CONV_FUNC_START(tv, fun) \
do { \
ufunc_T *fp = find_func(fun); \
- assert(fp != NULL); \
- if (fp->uf_cb == nlua_CFunction_func_call) { \
+ if (fp != NULL && fp->uf_cb == nlua_CFunction_func_call) { \
LuaRef ref = api_new_luaref(((LuaCFunctionState *)fp->uf_cb_state)->lua_callable.func_ref); \
kvi_push(edata->stack, LUAREF_OBJ(ref)); \
} else { \
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index df336d8703..a36f2c97b5 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -2013,6 +2013,7 @@ char_u *getnextac(int c, void *cookie, int indent, bool do_concat)
}
AutoCmd *ac = acp->nextcmd;
+ bool oneshot = ac->once;
if (p_verbose >= 9) {
verbose_enter_scroll();
@@ -2024,7 +2025,13 @@ char_u *getnextac(int c, void *cookie, int indent, bool do_concat)
if (ac->exec.type == CALLABLE_CB) {
typval_T argsin = TV_INITIAL_VALUE;
typval_T rettv = TV_INITIAL_VALUE;
- callback_call(&ac->exec.callable.cb, 0, &argsin, &rettv);
+ if (callback_call(&ac->exec.callable.cb, 0, &argsin, &rettv)) {
+ if (ac->exec.callable.cb.type == kCallbackLua) {
+ // If a Lua callback returns 'true' then the autocommand is removed
+ oneshot = true;
+ }
+ }
+
// TODO(tjdevries):
//
@@ -2042,7 +2049,7 @@ char_u *getnextac(int c, void *cookie, int indent, bool do_concat)
}
// Remove one-shot ("once") autocmd in anticipation of its execution.
- if (ac->once) {
+ if (oneshot) {
aucmd_del(ac);
}
autocmd_nested = ac->nested;
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index af7c3d4985..33e8469768 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -7730,6 +7730,7 @@ bool callback_call(Callback *const callback, const int argcount_in, typval_T *co
partial_T *partial;
char_u *name;
Array args = ARRAY_DICT_INIT;
+ Object rv;
switch (callback->type) {
case kCallbackFuncref:
name = callback->data.funcref;
@@ -7742,10 +7743,13 @@ bool callback_call(Callback *const callback, const int argcount_in, typval_T *co
break;
case kCallbackLua:
- nlua_call_ref(callback->data.luaref, NULL, args, false, NULL);
-
- return false;
- break;
+ rv = nlua_call_ref(callback->data.luaref, NULL, args, true, NULL);
+ switch (rv.type) {
+ case kObjectTypeBoolean:
+ return rv.data.boolean;
+ default:
+ return false;
+ }
case kCallbackNone:
return false;
diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c
index 0bb224c729..ef49a03660 100644
--- a/src/nvim/lua/converter.c
+++ b/src/nvim/lua/converter.c
@@ -477,8 +477,7 @@ static bool typval_conv_special = false;
#define TYPVAL_ENCODE_CONV_FUNC_START(tv, fun) \
do { \
ufunc_T *fp = find_func(fun); \
- assert(fp != NULL); \
- if (fp->uf_cb == nlua_CFunction_func_call) { \
+ if (fp != NULL && fp->uf_cb == nlua_CFunction_func_call) { \
nlua_pushref(lstate, ((LuaCFunctionState *)fp->uf_cb_state)->lua_callable.func_ref); \
} else { \
TYPVAL_ENCODE_CONV_NIL(tv); \
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 244a1881aa..fc66fb5f06 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -2835,9 +2835,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
curr->y_size = j;
xfree(reg->y_array);
}
- if (curwin->w_p_rnu) {
- redraw_later(curwin, SOME_VALID); // cursor moved to start
- }
+
if (message) { // Display message about yank?
if (yank_type == kMTCharWise && yanklines == 1) {
yanklines = 0;
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c
index 917847608a..24958ce041 100644
--- a/src/nvim/tui/input.c
+++ b/src/nvim/tui/input.c
@@ -115,34 +115,28 @@ static void tinput_done_event(void **argv)
static void tinput_wait_enqueue(void **argv)
{
TermInput *input = argv[0];
- if (rbuffer_size(input->key_buffer) == 0 && input->paste == 3) {
- // End streamed paste with an empty string.
- const String keys = { .data = "", .size = 0 };
- String copy = copy_string(keys);
- multiqueue_put(main_loop.events, tinput_paste_event, 3,
- copy.data, copy.size, (intptr_t)input->paste);
- }
- RBUFFER_UNTIL_EMPTY(input->key_buffer, buf, len) {
- const String keys = { .data = buf, .size = len };
- if (input->paste) {
- String copy = copy_string(keys);
- if (ui_client_channel_id) {
- Array args = ARRAY_DICT_INIT;
- ADD(args, STRING_OBJ(copy_string(keys))); // 'data'
- ADD(args, BOOLEAN_OBJ(true)); // 'crlf'
- ADD(args, INTEGER_OBJ(input->paste)); // 'phase'
- rpc_send_event(ui_client_channel_id, "nvim_paste", args);
- } else {
- multiqueue_put(main_loop.events, tinput_paste_event, 3,
- copy.data, copy.size, (intptr_t)input->paste);
- }
- if (input->paste == 1) {
- // Paste phase: "continue"
- input->paste = 2;
- }
- rbuffer_consumed(input->key_buffer, len);
- rbuffer_reset(input->key_buffer);
+ if (input->paste) { // produce exactly one paste event
+ const size_t len = rbuffer_size(input->key_buffer);
+ String keys = { .data = xmallocz(len), .size = len };
+ rbuffer_read(input->key_buffer, keys.data, len);
+ if (ui_client_channel_id) {
+ Array args = ARRAY_DICT_INIT;
+ ADD(args, STRING_OBJ(keys)); // 'data'
+ ADD(args, BOOLEAN_OBJ(true)); // 'crlf'
+ ADD(args, INTEGER_OBJ(input->paste)); // 'phase'
+ rpc_send_event(ui_client_channel_id, "nvim_paste", args);
} else {
+ multiqueue_put(main_loop.events, tinput_paste_event, 3,
+ keys.data, keys.size, (intptr_t)input->paste);
+ }
+ if (input->paste == 1) {
+ // Paste phase: "continue"
+ input->paste = 2;
+ }
+ rbuffer_reset(input->key_buffer);
+ } else { // enqueue input for the main thread or Nvim server
+ RBUFFER_UNTIL_EMPTY(input->key_buffer, buf, len) {
+ const String keys = { .data = buf, .size = len };
size_t consumed;
if (ui_client_channel_id) {
Array args = ARRAY_DICT_INIT;