diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 387639faff..1364d39617 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -9038,6 +9038,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/edit.c b/src/edit.c index 1324d4606d..e78a8a155b 100644 --- a/src/edit.c +++ b/src/edit.c @@ -9432,7 +9432,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; @@ -9452,7 +9452,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 021ba659ac..5fd6d90f15 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -4389,6 +4389,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 76ac955fd4..e773cde069 100644 --- a/src/gui.c +++ b/src/gui.c @@ -4982,7 +4982,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) @@ -5006,6 +5006,8 @@ xy2win(int x UNUSED, int y UNUSED) return NULL; # endif 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 a2e4661549..4ca46b0bb8 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). @@ -4629,7 +4635,7 @@ nv_mousescroll(cmdarg_T *cap) int scroll_wheel_force = 0; # endif # ifdef FEAT_WINDOWS - win_T *old_curwin = curwin; + win_T *old_curwin = curwin, *wp; if (mouse_row >= 0 && mouse_col >= 0) { @@ -4639,7 +4645,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/option.c b/src/option.c index 623cad16a2..826baba63b 100644 --- a/src/option.c +++ b/src/option.c @@ -3195,6 +3195,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 54cf21b8f1..8f4a7bb143 100644 --- a/src/option.h +++ b/src/option.h @@ -989,6 +989,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 95f63f4c6d..fba774d567 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". @@ -2773,11 +2774,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/ui.c b/src/ui.c index 050800a3c9..cea3e78ff9 100644 --- a/src/ui.c +++ b/src/ui.c @@ -2729,6 +2729,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 @@ -3137,11 +3139,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; @@ -3168,7 +3172,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 @@ -3192,6 +3201,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 85dd80db92..05fe663cb7 100644 --- a/src/version.c +++ b/src/version.c @@ -784,6 +784,12 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 949, +/**/ + 948, +/**/ + 947, /**/ 946, /**/