diff options
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r-- | src/nvim/api/vim.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index e6ec88c5e8..83f9aa573d 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -779,8 +779,8 @@ void nvim_set_vvar(String name, Object value, Error *err) /// Echo a message. /// /// @param chunks A list of `[text, hl_group]` arrays, each representing a -/// text chunk with specified highlight. `hl_group` element -/// can be omitted for no highlight. +/// text chunk with specified highlight group name or ID. +/// `hl_group` element can be omitted for no highlight. /// @param history if true, add to |message-history|. /// @param opts Optional parameters. /// - verbose: Message is printed as a result of 'verbose' option. @@ -1004,10 +1004,10 @@ Buffer nvim_create_buf(Boolean listed, Boolean scratch, Error *err) buf_copy_options(buf, BCO_ENTER | BCO_NOHELP); if (scratch) { - set_option_direct_for(kOptBufhidden, STATIC_CSTR_AS_OPTVAL("hide"), OPT_LOCAL, 0, kOptReqBuf, - buf); - set_option_direct_for(kOptBuftype, STATIC_CSTR_AS_OPTVAL("nofile"), OPT_LOCAL, 0, kOptReqBuf, - buf); + set_option_direct_for(kOptBufhidden, STATIC_CSTR_AS_OPTVAL("hide"), OPT_LOCAL, 0, + kOptScopeBuf, buf); + set_option_direct_for(kOptBuftype, STATIC_CSTR_AS_OPTVAL("nofile"), OPT_LOCAL, 0, + kOptScopeBuf, buf); assert(buf->b_ml.ml_mfp->mf_fd < 0); // ml_open() should not have opened swapfile already buf->b_p_swf = false; buf->b_p_ml = false; @@ -2398,14 +2398,22 @@ void nvim__redraw(Dict(redraw) *opts, Error *err) redraw_buf_range_later(rbuf, first, last); } - bool flush = opts->flush; + // Redraw later types require update_screen() so call implicitly unless set to false. + if (HAS_KEY(opts, redraw, valid) || HAS_KEY(opts, redraw, range)) { + opts->flush = HAS_KEY(opts, redraw, flush) ? opts->flush : true; + } + + // When explicitly set to false and only "redraw later" types are present, + // don't call ui_flush() either. + bool flush_ui = opts->flush; if (opts->tabline) { // Flush later in case tabline was just hidden or shown for the first time. if (redraw_tabline && firstwin->w_lines_valid == 0) { - flush = true; + opts->flush = true; } else { draw_tabline(); } + flush_ui = true; } bool save_lz = p_lz; @@ -2416,31 +2424,35 @@ void nvim__redraw(Dict(redraw) *opts, Error *err) if (win == NULL) { FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { if (buf == NULL || wp->w_buffer == buf) { - redraw_status(wp, opts, &flush); + redraw_status(wp, opts, &opts->flush); } } } else { - redraw_status(win, opts, &flush); + redraw_status(win, opts, &opts->flush); } + flush_ui = true; } win_T *cwin = win ? win : curwin; // Allow moving cursor to recently opened window and make sure it is drawn #28868. if (opts->cursor && (!cwin->w_grid.target || !cwin->w_grid.target->valid)) { - flush = true; + opts->flush = true; } // Redraw pending screen updates when explicitly requested or when determined // that it is necessary to properly draw other requested components. - if (flush && !cmdpreview) { + if (opts->flush && !cmdpreview) { update_screen(); } if (opts->cursor) { setcursor_mayforce(cwin, true); + flush_ui = true; } - ui_flush(); + if (flush_ui) { + ui_flush(); + } RedrawingDisabled = save_rd; p_lz = save_lz; |