Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 533d4a3

Browse filesBrowse files
authored
TUI: do not resize host-terminal on startup (#9645)
...unless the 'lines' and/or 'columns' options were set. ref 5732340 fixes #5843
1 parent 88652c4 commit 533d4a3
Copy full SHA for 533d4a3

File tree

1 file changed

+10
-5
lines changed
Filter options

1 file changed

+10
-5
lines changed

‎src/nvim/tui/tui.c

Copy file name to clipboardExpand all lines: src/nvim/tui/tui.c
+10-5Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ typedef struct {
129129
} TUIData;
130130

131131
static bool volatile got_winch = false;
132+
static bool did_user_set_dimensions = false;
132133
static bool cursor_style_enabled = false;
133134

134135
#ifdef INCLUDE_GENERATED_DECLARATIONS
@@ -338,7 +339,7 @@ static void tui_terminal_start(UI *ui)
338339
data->print_attr_id = -1;
339340
ugrid_init(&data->grid);
340341
terminfo_start(ui);
341-
update_size(ui);
342+
tui_guess_size(ui);
342343
signal_watcher_start(&data->winch_handle, sigwinch_cb, SIGWINCH);
343344
term_input_start(&data->input);
344345
}
@@ -465,7 +466,7 @@ static void sigwinch_cb(SignalWatcher *watcher, int signum, void *data)
465466
return;
466467
}
467468

468-
update_size(ui);
469+
tui_guess_size(ui);
469470
ui_schedule_refresh();
470471
}
471472

@@ -889,7 +890,8 @@ static void tui_grid_resize(UI *ui, Integer g, Integer width, Integer height)
889890
r->right = MIN(r->right, grid->width);
890891
}
891892

892-
if (!got_winch) { // Try to resize the terminal window.
893+
if (!got_winch && (!starting || did_user_set_dimensions)) {
894+
// Resize the _host_ terminal.
893895
UNIBI_SET_NUM_VAR(data->params[0], (int)height);
894896
UNIBI_SET_NUM_VAR(data->params[1], (int)width);
895897
unibi_out_ext(ui, data->unibi_ext.resize_screen);
@@ -1347,13 +1349,16 @@ static void invalidate(UI *ui, int top, int bot, int left, int right)
13471349
}
13481350
}
13491351

1350-
static void update_size(UI *ui)
1352+
/// Tries to get the user's wanted dimensions (columns and rows) for the entire
1353+
/// application (i.e., the host terminal).
1354+
static void tui_guess_size(UI *ui)
13511355
{
13521356
TUIData *data = ui->data;
13531357
int width = 0, height = 0;
13541358

13551359
// 1 - look for non-default 'columns' and 'lines' options during startup
1356-
if (starting != 0 && (Columns != DFLT_COLS || Rows != DFLT_ROWS)) {
1360+
if (starting && (Columns != DFLT_COLS || Rows != DFLT_ROWS)) {
1361+
did_user_set_dimensions = true;
13571362
assert(Columns >= INT_MIN && Columns <= INT_MAX);
13581363
assert(Rows >= INT_MIN && Rows <= INT_MAX);
13591364
width = (int)Columns;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.