From 802f8429d5d908457658e4b9859d8ed110bc0247 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Thu, 27 May 2021 22:10:42 +0100 Subject: api(nvim_open_win): add "noautocmd" option This option, when set, stops nvim_open_win() from potentially firing buffer-related autocmd events (BufEnter, BufLeave and BufWinEnter in the case of nvim_open_win()). --- src/nvim/api/vim.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/nvim/api/vim.c') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index a76cefe294..99a41f4f6f 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1459,6 +1459,9 @@ void nvim_chan_send(Integer chan, String data, Error *err) /// By default `FloatBorder` highlight is used which links to `VertSplit` /// when not defined. It could also be specified by character: /// [ {"+", "MyCorner"}, {"x", "MyBorder"} ] +/// - `noautocmd`: If true then no buffer-related autocommand events such as +/// |BufEnter|, |BufLeave| or |BufWinEnter| may fire from +/// calling this function. /// /// @param[out] err Error details, if any /// @@ -1469,7 +1472,7 @@ Window nvim_open_win(Buffer buffer, Boolean enter, Dictionary config, FUNC_API_CHECK_TEXTLOCK { FloatConfig fconfig = FLOAT_CONFIG_INIT; - if (!parse_float_config(config, &fconfig, false, err)) { + if (!parse_float_config(config, &fconfig, false, true, err)) { return 0; } win_T *wp = win_new_float(NULL, fconfig, err); @@ -1484,7 +1487,7 @@ Window nvim_open_win(Buffer buffer, Boolean enter, Dictionary config, return 0; } if (buffer > 0) { - nvim_win_set_buf(wp->handle, buffer, err); + win_set_buf(wp->handle, buffer, fconfig.noautocmd, err); } if (fconfig.style == kWinStyleMinimal) { -- cgit