Skip to content

Commit 43da3e3

Browse files
committed
patch 8.0.0759: MS-Windows: terminal does not adjust size
Problem: MS-Windows: terminal does not adjust size to the Vim window size. Solution: Add a call to winpty_set_size(). (Yasuhiro Matsumoto, closes #1863)
1 parent cdeae99 commit 43da3e3

2 files changed

Lines changed: 39 additions & 18 deletions

File tree

src/terminal.c

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ static term_T *first_term = NULL;
118118
* Functions with separate implementation for MS-Windows and Unix-like systems.
119119
*/
120120
static int term_and_job_init(term_T *term, int rows, int cols, char_u *cmd);
121+
static void term_report_winsize(term_T *term, int rows, int cols);
121122
static void term_free(term_T *term);
122123

123124
/**************************************
@@ -765,24 +766,7 @@ term_update_window(win_T *wp)
765766
vterm_set_size(vterm, rows, cols);
766767
ch_logn(term->tl_job->jv_channel, "Resizing terminal to %d lines",
767768
rows);
768-
769-
#if defined(UNIX)
770-
/* Use an ioctl() to report the new window size to the job. */
771-
if (term->tl_job != NULL && term->tl_job->jv_channel != NULL)
772-
{
773-
int fd = -1;
774-
int part;
775-
776-
for (part = PART_OUT; part < PART_COUNT; ++part)
777-
{
778-
fd = term->tl_job->jv_channel->ch_part[part].ch_fd;
779-
if (isatty(fd))
780-
break;
781-
}
782-
if (part < PART_COUNT && mch_report_winsize(fd, rows, cols) == OK)
783-
mch_stop_job(term->tl_job, (char_u *)"winch");
784-
}
785-
#endif
769+
term_report_winsize(term, rows, cols);
786770
}
787771

788772
/* The cursor may have been moved when resizing. */
@@ -921,6 +905,7 @@ void (*winpty_config_free)(void*);
921905
void (*winpty_spawn_config_free)(void*);
922906
void (*winpty_error_free)(void*);
923907
LPCWSTR (*winpty_error_msg)(void*);
908+
BOOL (*winpty_set_size)(void*, int, int, void*);
924909

925910
/**************************************
926911
* 2. MS-Windows implementation.
@@ -953,6 +938,7 @@ dyn_winpty_init(void)
953938
{"winpty_spawn_config_free", (FARPROC*)&winpty_spawn_config_free},
954939
{"winpty_spawn_config_new", (FARPROC*)&winpty_spawn_config_new},
955940
{"winpty_error_msg", (FARPROC*)&winpty_error_msg},
941+
{"winpty_set_size", (FARPROC*)&winpty_set_size},
956942
{NULL, NULL}
957943
};
958944

@@ -1122,6 +1108,15 @@ term_free(term_T *term)
11221108
vterm_free(term->tl_vterm);
11231109
}
11241110

1111+
/*
1112+
* Request size to terminal.
1113+
*/
1114+
static void
1115+
term_report_winsize(term_T *term, int rows, int cols)
1116+
{
1117+
winpty_set_size(term->tl_winpty, cols, rows, NULL);
1118+
}
1119+
11251120
# else
11261121

11271122
/**************************************
@@ -1161,6 +1156,30 @@ term_free(term_T *term)
11611156
if (term->tl_vterm != NULL)
11621157
vterm_free(term->tl_vterm);
11631158
}
1159+
1160+
/*
1161+
* Request size to terminal.
1162+
*/
1163+
static void
1164+
term_report_winsize(term_T *term, int rows, int cols)
1165+
{
1166+
/* Use an ioctl() to report the new window size to the job. */
1167+
if (term->tl_job != NULL && term->tl_job->jv_channel != NULL)
1168+
{
1169+
int fd = -1;
1170+
int part;
1171+
1172+
for (part = PART_OUT; part < PART_COUNT; ++part)
1173+
{
1174+
fd = term->tl_job->jv_channel->ch_part[part].ch_fd;
1175+
if (isatty(fd))
1176+
break;
1177+
}
1178+
if (part < PART_COUNT && mch_report_winsize(fd, rows, cols) == OK)
1179+
mch_stop_job(term->tl_job, (char_u *)"winch");
1180+
}
1181+
}
1182+
11641183
# endif
11651184

11661185
#endif /* FEAT_TERMINAL */

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
759,
772774
/**/
773775
758,
774776
/**/

0 commit comments

Comments
 (0)