diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/api/vim.c | 24 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 5 | ||||
-rw-r--r-- | src/nvim/message.c | 7 |
3 files changed, 30 insertions, 6 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 9b5e0fc40b..2e8ca384b4 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -27,6 +27,7 @@ #include "nvim/types.h" #include "nvim/ex_docmd.h" #include "nvim/screen.h" +#include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/edit.h" @@ -977,11 +978,20 @@ Buffer nvim_create_buf(Boolean listed, Boolean scratch, Error *err) BLN_NOOPT | BLN_NEW | (listed ? BLN_LISTED : 0)); try_end(err); if (buf == NULL) { - if (!ERROR_SET(err)) { - api_set_error(err, kErrorTypeException, "Failed to create buffer"); - } - return 0; + goto fail; } + + // Open the memline for the buffer. This will avoid spurious autocmds when + // a later nvim_buf_set_lines call would have needed to "open" the buffer. + try_start(); + block_autocmds(); + int status = ml_open(buf); + unblock_autocmds(); + try_end(err); + if (status == FAIL) { + goto fail; + } + if (scratch) { aco_save_T aco; aucmd_prepbuf(&aco, buf); @@ -991,6 +1001,12 @@ Buffer nvim_create_buf(Boolean listed, Boolean scratch, Error *err) aucmd_restbuf(&aco); } return buf->b_fnum; + +fail: + if (!ERROR_SET(err)) { + api_set_error(err, kErrorTypeException, "Failed to create buffer"); + } + return 0; } /// Open a new window. diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index ce46408872..3bfda1f9f0 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -656,10 +656,13 @@ static int command_line_execute(VimState *state, int key) redrawcmd(); save_p_ls = -1; wild_menu_showing = 0; - } else { + // don't redraw statusline if WM_LIST is showing + } else if (wild_menu_showing != WM_LIST) { win_redraw_last_status(topframe); wild_menu_showing = 0; // must be before redraw_statuslines #8385 redraw_statuslines(); + } else { + wild_menu_showing = 0; } KeyTyped = skt; if (ccline.input_fn) { diff --git a/src/nvim/message.c b/src/nvim/message.c index a597fb4866..5188824901 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1806,8 +1806,13 @@ void msg_puts_attr_len(const char *const str, const ptrdiff_t len, int attr) // different, e.g. for Win32 console) or we just don't know where the // cursor is. if (msg_use_printf()) { + int saved_msg_col = msg_col; msg_puts_printf(str, len); - } else { + if (headless_mode) { + msg_col = saved_msg_col; + } + } + if (!msg_use_printf() || (headless_mode && default_grid.chars)) { msg_puts_display((const char_u *)str, len, attr, false); } } |