mirror of
https://github.com/neovim/neovim.git
synced 2025-10-09 11:26:37 +00:00
terminal: handle size when switching buffers in window
This commit is contained in:
@@ -1472,6 +1472,10 @@ void set_curbuf(buf_T *buf, int action)
|
||||
if (old_tw != curbuf->b_p_tw)
|
||||
check_colorcolumn(curwin);
|
||||
}
|
||||
|
||||
if (bufref_valid(&prevbufref) && prevbuf->terminal != NULL) {
|
||||
terminal_check_size(prevbuf->terminal);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -1034,10 +1034,13 @@ struct window_S {
|
||||
int w_width; /* Width of window, excluding separation. */
|
||||
int w_vsep_width; /* Number of separator columns (0 or 1). */
|
||||
|
||||
// inner size of window, which can be overriden by external UI
|
||||
int w_height_inner;
|
||||
int w_width_inner;
|
||||
// external UI request. If non-zero, the inner size will use this.
|
||||
int w_height_request;
|
||||
int w_width_request;
|
||||
|
||||
/*
|
||||
* === start of cached values ====
|
||||
*/
|
||||
|
@@ -2678,6 +2678,10 @@ int do_ecmd(
|
||||
|
||||
|
||||
theend:
|
||||
if (bufref_valid(&old_curbuf) && old_curbuf.br_buf->terminal != NULL) {
|
||||
terminal_check_size(old_curbuf.br_buf->terminal);
|
||||
}
|
||||
|
||||
if (did_inc_redrawing_disabled) {
|
||||
RedrawingDisabled--;
|
||||
}
|
||||
|
@@ -1452,7 +1452,8 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
|
||||
curwin->w_topline = loff.lnum) {
|
||||
loff.lnum = curwin->w_topline;
|
||||
topline_back(&loff);
|
||||
if (loff.height == MAXCOL || used + loff.height > curwin->w_height_inner) {
|
||||
if (loff.height == MAXCOL
|
||||
|| used + loff.height > curwin->w_height_inner) {
|
||||
break;
|
||||
}
|
||||
used += loff.height;
|
||||
|
@@ -337,19 +337,16 @@ void terminal_close(Terminal *term, char *msg)
|
||||
void terminal_check_size(Terminal *term)
|
||||
{
|
||||
if (term->closed) {
|
||||
// TODO: WTF does this mean:
|
||||
// If two windows display the same terminal and one is closed by keypress.
|
||||
return;
|
||||
}
|
||||
|
||||
int curwidth, curheight;
|
||||
vterm_get_size(term->vt, &curheight, &curwidth);
|
||||
uint16_t width = 0, height = 0;
|
||||
|
||||
bool window_seen = false;
|
||||
|
||||
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||
if (wp->w_buffer && wp->w_buffer->terminal == term) {
|
||||
window_seen = true;
|
||||
const uint16_t win_width =
|
||||
(uint16_t)(MAX(0, wp->w_width_inner - win_col_off(wp)));
|
||||
width = MAX(width, win_width);
|
||||
@@ -357,6 +354,8 @@ void terminal_check_size(Terminal *term)
|
||||
}
|
||||
}
|
||||
|
||||
// if no window displays the terminal, or such all windows are zero-height,
|
||||
// don't resize the terminal.
|
||||
if ((curheight == height && curwidth == width) || height == 0 || width == 0) {
|
||||
return;
|
||||
}
|
||||
|
@@ -453,7 +453,7 @@ void ui_grid_resize(handle_T grid_handle, int width, int height, Error *error)
|
||||
}
|
||||
|
||||
// non-positive indicates no request
|
||||
wp->w_height_request = (int)MAX(height,0);
|
||||
wp->w_width_request = (int)MAX(width,0);
|
||||
wp->w_height_request = (int)MAX(height, 0);
|
||||
wp->w_width_request = (int)MAX(width, 0);
|
||||
win_set_inner_size(wp);
|
||||
}
|
||||
|
@@ -4126,7 +4126,7 @@ void win_alloc_lines(win_T *wp)
|
||||
{
|
||||
wp->w_lines_valid = 0;
|
||||
assert(wp->w_height_inner >= 0);
|
||||
// TODO(bfredl) :this should work, add call to win_set_inner_size?
|
||||
// TODO(bfredl): this should work, add call to win_set_inner_size?
|
||||
// wp->w_lines = xcalloc(wp->w_height_inner+1, sizeof(wline_T));
|
||||
wp->w_lines = xcalloc(MAX(wp->w_height_inner + 1, Rows), sizeof(wline_T));
|
||||
}
|
||||
|
Reference in New Issue
Block a user