mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 05:28:33 +00:00
fix(api): only flush nvim__redraw when necessary #31250
Problem: Not possible to only set a "redraw later" type with nvim__redraw, which seems to be desired for the treesitter highlighter. Solution: Do not update the screen when "flush" is explicitly set to false and only redraw later types are present. In that case, do not call ui_flush() either.
This commit is contained in:
@@ -2396,9 +2396,16 @@ void nvim__redraw(Dict(redraw) *opts, Error *err)
|
||||
last = rbuf->b_ml.ml_line_count;
|
||||
}
|
||||
redraw_buf_range_later(rbuf, first, last);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
@@ -2406,6 +2413,7 @@ void nvim__redraw(Dict(redraw) *opts, Error *err)
|
||||
} else {
|
||||
draw_tabline();
|
||||
}
|
||||
flush_ui = true;
|
||||
}
|
||||
|
||||
bool save_lz = p_lz;
|
||||
@@ -2422,6 +2430,7 @@ void nvim__redraw(Dict(redraw) *opts, Error *err)
|
||||
} else {
|
||||
redraw_status(win, opts, &opts->flush);
|
||||
}
|
||||
flush_ui = true;
|
||||
}
|
||||
|
||||
win_T *cwin = win ? win : curwin;
|
||||
@@ -2438,9 +2447,12 @@ void nvim__redraw(Dict(redraw) *opts, Error *err)
|
||||
|
||||
if (opts->cursor) {
|
||||
setcursor_mayforce(cwin, true);
|
||||
flush_ui = true;
|
||||
}
|
||||
|
||||
ui_flush();
|
||||
if (flush_ui) {
|
||||
ui_flush();
|
||||
}
|
||||
|
||||
RedrawingDisabled = save_rd;
|
||||
p_lz = save_lz;
|
||||
|
Reference in New Issue
Block a user