refactor(terminal): remove unnecessary buf_valid() (#37224)

In close_buffer(), free_buffer() is called to remove the buffer from
buffer_handles immediately after removing it from the buffer list, so as
long as a buffer is in buffer_handles it is always valid.

(cherry picked from commit 033302d97d)
This commit is contained in:
zeertzjq
2026-01-05 08:20:24 +08:00
committed by github-actions[bot]
parent ceed171485
commit 4e90ea5dca

View File

@@ -2109,12 +2109,8 @@ static void invalidate_terminal(Terminal *term, int start_row, int end_row)
static void refresh_terminal(Terminal *term)
{
buf_T *buf = handle_get_buffer(term->buf_handle);
bool valid = true;
if (!buf || !(valid = buf_valid(buf))) {
if (!buf) {
// Destroyed by `close_buffer`. Do not do anything else.
if (!valid) {
term->buf_handle = 0;
}
return;
}
linenr_T ml_before = buf->b_ml.ml_line_count;