fix(terminal): don't poll for output during scrollback refresh (#38365)

Problem:
If buffer update callbacks poll for uv events during terminal scrollback
refresh, new output from PTY process may lead to incorrect scrollback.

Solution:
Don't poll for output to the same terminal as the one being refreshed.
This commit is contained in:
zeertzjq
2026-03-19 18:16:57 +08:00
committed by GitHub
parent 08c64bb036
commit 7d6b6b2d14
5 changed files with 69 additions and 8 deletions

View File

@@ -1153,6 +1153,7 @@ Integer nvim_open_term(Buffer buffer, Dict(open_term) *opts, Error *err)
// displaying the buffer
.width = (uint16_t)MAX(curwin->w_view_width - win_col_off(curwin), 0),
.height = (uint16_t)curwin->w_view_height,
.read_pause_cb = term_read_pause,
.write_cb = term_write,
.resize_cb = term_resize,
.resume_cb = term_resume,
@@ -1185,6 +1186,11 @@ Integer nvim_open_term(Buffer buffer, Dict(open_term) *opts, Error *err)
return (Integer)chan->id;
}
static void term_read_pause(bool pause, void *data)
{
// Not currently needed as sending to channel isn't allowed during buffer updates.
}
static void term_write(const char *buf, size_t size, void *data)
{
Channel *chan = data;