From 6fe15bbc87cb996912fe3c2c4068e356071ac516 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 16 Aug 2017 21:09:18 +0200 Subject: [PATCH 1/3] patch 8.0.0947: entering terminal using C-O C-W C-W goes to Insert mode Problem: When in Insert mode and using CTRL-O CTRL-W CTRL-W to move to a termainal window, get in a weird Insert mode. Solution: Don't go to Insert mode in a terminal window. (closes #1977) --- src/normal.c | 6 ++++++ src/version.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/normal.c b/src/normal.c index 24ab06ddf2..ea963667d4 100644 --- a/src/normal.c +++ b/src/normal.c @@ -1308,6 +1308,12 @@ normal_end: } #endif +#ifdef FEAT_TERMINAL + /* don't go to Insert mode from Terminal-Job mode */ + if (term_use_loop()) + restart_edit = 0; +#endif + /* * May restart edit(), if we got here with CTRL-O in Insert mode (but not * if still inside a mapping that started in Visual mode). diff --git a/src/version.c b/src/version.c index f3e5a3ad35..ebfa0bf2e6 100644 --- a/src/version.c +++ b/src/version.c @@ -769,6 +769,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 947, /**/ 946, /**/ From 989a70c590c2bd109eb362d3a0e48cb1427ae13d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 16 Aug 2017 22:46:01 +0200 Subject: [PATCH 2/3] patch 8.0.0948: crash if timer closes window while dragging status line Problem: Crash if timer closes window while dragging status line. Solution: Check if the window still exists. (Yasuhiro Matsumoto, closes #1979) --- src/edit.c | 7 +++++-- src/evalfunc.c | 2 ++ src/gui.c | 4 +++- src/normal.c | 7 +++++-- src/ui.c | 13 ++++++++++++- src/version.c | 2 ++ 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/edit.c b/src/edit.c index e08370863c..3a9b3aaf9f 100644 --- a/src/edit.c +++ b/src/edit.c @@ -9418,7 +9418,7 @@ ins_mousescroll(int dir) { pos_T tpos; # if defined(FEAT_WINDOWS) - win_T *old_curwin = curwin; + win_T *old_curwin = curwin, *wp; # endif # ifdef FEAT_INS_EXPAND int did_scroll = FALSE; @@ -9435,7 +9435,10 @@ ins_mousescroll(int dir) col = mouse_col; /* find the window at the pointer coordinates */ - curwin = mouse_find_win(&row, &col); + wp = mouse_find_win(&row, &col); + if (wp == NULL) + return; + curwin = wp; curbuf = curwin->w_buffer; } if (curwin == old_curwin) diff --git a/src/evalfunc.c b/src/evalfunc.c index 2be7fe1bf2..452183594f 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -4382,6 +4382,8 @@ f_getchar(typval_T *argvars, typval_T *rettv) /* Find the window at the mouse coordinates and compute the * text position. */ win = mouse_find_win(&row, &col); + if (win == NULL) + return; (void)mouse_comp_pos(win, &row, &col, &lnum); # ifdef FEAT_WINDOWS for (wp = firstwin; wp != win; wp = wp->w_next) diff --git a/src/gui.c b/src/gui.c index 63625bfc40..f774750f2b 100644 --- a/src/gui.c +++ b/src/gui.c @@ -4933,7 +4933,7 @@ gui_mouse_correct(void) } /* - * Find window where the mouse pointer "y" coordinate is in. + * Find window where the mouse pointer "x" / "y" coordinate is in. */ static win_T * xy2win(int x UNUSED, int y UNUSED) @@ -4948,6 +4948,8 @@ xy2win(int x UNUSED, int y UNUSED) if (row < 0 || col < 0) /* before first window */ return NULL; wp = mouse_find_win(&row, &col); + if (wp == NULL) + return NULL; # ifdef FEAT_MOUSESHAPE if (State == HITRETURN || State == ASKMORE) { diff --git a/src/normal.c b/src/normal.c index ea963667d4..c543635ef4 100644 --- a/src/normal.c +++ b/src/normal.c @@ -4627,7 +4627,7 @@ nv_screengo(oparg_T *oap, int dir, long dist) nv_mousescroll(cmdarg_T *cap) { # ifdef FEAT_WINDOWS - win_T *old_curwin = curwin; + win_T *old_curwin = curwin, *wp; if (mouse_row >= 0 && mouse_col >= 0) { @@ -4637,7 +4637,10 @@ nv_mousescroll(cmdarg_T *cap) col = mouse_col; /* find the window at the pointer coordinates */ - curwin = mouse_find_win(&row, &col); + wp = mouse_find_win(&row, &col); + if (wp == NULL) + return; + curwin = wp; curbuf = curwin->w_buffer; } # endif diff --git a/src/ui.c b/src/ui.c index 907390e6b8..ddae372664 100644 --- a/src/ui.c +++ b/src/ui.c @@ -2709,6 +2709,8 @@ retnomove: #ifdef FEAT_WINDOWS /* find the window where the row is in */ wp = mouse_find_win(&row, &col); + if (wp == NULL) + return IN_UNKNOWN; #else wp = firstwin; #endif @@ -3117,11 +3119,13 @@ mouse_comp_pos( /* * Find the window at screen position "*rowp" and "*colp". The positions are * updated to become relative to the top-left of the window. + * Returns NULL when something is wrong. */ win_T * mouse_find_win(int *rowp, int *colp UNUSED) { frame_T *fp; + win_T *wp; fp = topframe; *rowp -= firstwin->w_winrow; @@ -3148,7 +3152,12 @@ mouse_find_win(int *rowp, int *colp UNUSED) } } } - return fp->fr_win; + /* When using a timer that closes a window the window might not actually + * exist. */ + FOR_ALL_WINDOWS(wp) + if (wp == fp->fr_win) + return wp; + return NULL; } #endif @@ -3171,6 +3180,8 @@ get_fpos_of_mouse(pos_T *mpos) #ifdef FEAT_WINDOWS /* find the window where the row is in */ wp = mouse_find_win(&row, &col); + if (wp == NULL) + return IN_UNKNOWN; #else wp = firstwin; #endif diff --git a/src/version.c b/src/version.c index ebfa0bf2e6..b2de15d169 100644 --- a/src/version.c +++ b/src/version.c @@ -769,6 +769,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 948, /**/ 947, /**/ From 9e13aa7729486d79a530ecae1a7a95d10da27d61 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 16 Aug 2017 23:14:08 +0200 Subject: [PATCH 3/3] patch 8.0.0949: winpty.dll name is fixed Problem: winpty.dll name is fixed. Solution: Add the 'winptydll' option. Make the default name depend on whether it is a 32-bit or 64-bit build. (idea by Yasuhiro Matsumoto, closes #1978) --- runtime/doc/options.txt | 14 ++++++++++++++ src/option.c | 14 ++++++++++++++ src/option.h | 3 +++ src/terminal.c | 11 ++++++++--- src/version.c | 2 ++ 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 73955f4ba8..ff7bb8f1d8 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -8831,6 +8831,20 @@ A jump table for the options with a short description can be found at |Q_op|. large number, it will cause errors when opening more than a few windows. A value of 0 to 12 is reasonable. + *'winptydll'* +'winptydll' string (default "winpty32.dll" or "winpty64.dll") + global + {not in Vi} + {only available when compiled with the |terminal| + feature on MS-Windows} + Specifies the name of the winpty shared library, used for the + |:terminal| command. The default depends on whether was build as a + 32-bit or 64-bit executable. If not found, "win32pty.dll" is tried as + a fallback. + Environment variables are expanded |:set_env|. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. + *'winwidth'* *'wiw'* *E592* 'winwidth' 'wiw' number (default 20) global diff --git a/src/option.c b/src/option.c index 1877b7e47f..3dc52f8e73 100644 --- a/src/option.c +++ b/src/option.c @@ -3098,6 +3098,20 @@ static struct vimoption options[] = (char_u *)NULL, PV_NONE, #endif {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, + {"winptydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, +#if defined(WIN3264) && defined(TERMINAL) + (char_u *)&p_winptydll, PV_NONE, { +# ifdef _WIN64 + (char_u *)"winpty64.dll", +# else + (char_u *)"winpty32.dll", +# endif + (char_u *)0L} +#else + (char_u *)NULL, PV_NONE, + {(char_u *)0L, (char_u *)0L} +#endif + SCRIPTID_INIT}, {"winwidth", "wiw", P_NUM|P_VI_DEF, #ifdef FEAT_WINDOWS (char_u *)&p_wiw, PV_NONE, diff --git a/src/option.h b/src/option.h index 9b7e88f0d2..b772a8eded 100644 --- a/src/option.h +++ b/src/option.h @@ -966,6 +966,9 @@ EXTERN long p_wmh; /* 'winminheight' */ EXTERN long p_wmw; /* 'winminwidth' */ EXTERN long p_wiw; /* 'winwidth' */ #endif +#if defined(WIN3264) && defined(TERMINAL) +EXTERN char_u *p_winptydll; /* 'winptydll' */ +#endif EXTERN int p_ws; /* 'wrapscan' */ EXTERN int p_write; /* 'write' */ EXTERN int p_wa; /* 'writeany' */ diff --git a/src/terminal.c b/src/terminal.c index 149679e3fc..c4fa847677 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -38,6 +38,7 @@ * in tl_scrollback are no longer used. * * TODO: + * - make [range]terminal pipe [range] lines to the terminal * - implement term_setsize() * - add test for giving error for invalid 'termsize' value. * - support minimal size when 'termsize' is "rows*cols". @@ -2768,11 +2769,15 @@ dyn_winpty_init(void) /* No need to initialize twice. */ if (hWinPtyDLL) return 1; - /* Load winpty.dll */ - hWinPtyDLL = vimLoadLib(WINPTY_DLL); + /* Load winpty.dll, prefer using the 'winptydll' option, fall back to just + * winpty.dll. */ + if (*p_winptydll != NUL) + hWinPtyDLL = vimLoadLib((char *)p_winptydll); + if (!hWinPtyDLL) + hWinPtyDLL = vimLoadLib(WINPTY_DLL); if (!hWinPtyDLL) { - EMSG2(_(e_loadlib), WINPTY_DLL); + EMSG2(_(e_loadlib), *p_winptydll != NUL ? p_winptydll : WINPTY_DLL); return 0; } for (i = 0; winpty_entry[i].name != NULL diff --git a/src/version.c b/src/version.c index b2de15d169..085b2e1e47 100644 --- a/src/version.c +++ b/src/version.c @@ -769,6 +769,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 949, /**/ 948, /**/