mirror of
https://github.com/neovim/neovim.git
synced 2026-02-20 10:28:33 +00:00
fix(terminal): wrong scrollback with nvim_open_term() on buffer (#37791)
Problem: Wrong scrollback when passing a buffer with many lines to
nvim_open_term().
Solution: Delete all buffer lines before opening the terminal.
I tried to use buf_clear(), but it crashes inside deleted_lines_mark(),
so I'll just use deleted_lines_buf() for now. The behavior of marks can
be decided later.
This commit is contained in:
@@ -544,8 +544,8 @@ Terminal *terminal_alloc(buf_T *buf, TerminalOptions opts)
|
||||
}
|
||||
vterm_state_set_termprop(state, VTERM_PROP_CURSORBLINK, &cursor_blink);
|
||||
|
||||
// force a initial refresh of the screen to ensure the buffer will always
|
||||
// have as many lines as screen rows when refresh_scrollback is called
|
||||
// Force a initial refresh of the screen to ensure the buffer will always
|
||||
// have as many lines as screen rows when refresh_scrollback() is called.
|
||||
term->invalid_start = 0;
|
||||
term->invalid_end = opts.height;
|
||||
|
||||
@@ -556,6 +556,12 @@ Terminal *terminal_alloc(buf_T *buf, TerminalOptions opts)
|
||||
// events from this queue are copied back onto the main event queue.
|
||||
term->pending.events = multiqueue_new(NULL, NULL);
|
||||
|
||||
linenr_T line_count = buf->b_ml.ml_line_count;
|
||||
while (!(buf->b_ml.ml_flags & ML_EMPTY)) {
|
||||
ml_delete_buf(buf, 1, false);
|
||||
}
|
||||
deleted_lines_buf(buf, 1, line_count);
|
||||
|
||||
return term;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user