diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 7c346d46e5..83452e3bf1 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -332,7 +332,7 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_ks) if (!dangerous) { ex_normal_busy++; } - exec_normal(true); + exec_normal(true, lowlevel); if (!dangerous) { ex_normal_busy--; } diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index e5612ad6be..e39f17618e 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -7072,21 +7072,26 @@ void exec_normal_cmd(char *cmd, int remap, bool silent) { // Stuff the argument into the typeahead buffer. ins_typebuf(cmd, remap, 0, true, silent); - exec_normal(false); + exec_normal(false, false); } /// Execute normal_cmd() until there is no typeahead left. /// /// @param was_typed whether or not something was typed -void exec_normal(bool was_typed) +/// @param use_vpeekc true to use vpeekc() to check for available chars +void exec_normal(bool was_typed, bool use_vpeekc) { oparg_T oa; + int c; + // When calling vpeekc() from feedkeys() it will return Ctrl_C when there + // is nothing to get, so also check for Ctrl_C. clear_oparg(&oa); finish_op = false; while ((!stuff_empty() || ((was_typed || !typebuf_typed()) - && typebuf.tb_len > 0)) + && typebuf.tb_len > 0) + || (use_vpeekc && (c = vpeekc()) != NUL && c != Ctrl_C)) && !got_int) { update_topline_cursor(); normal_cmd(&oa, true); // execute a Normal mode cmd