From 3cea8a9a51c7b26a01a75dc29d9d8a621fc70b57 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 17 Oct 2019 21:55:24 +0200 Subject: [PATCH 01/30] patch 8.1.2169: terminal flags are never reset Problem: Terminal flags are never reset. Solution: Reset the flags when setting 'term'. --- src/term.c | 2 ++ src/testdir/test_termcodes.vim | 11 +++++++++++ src/version.c | 2 ++ 3 files changed, 15 insertions(+) diff --git a/src/term.c b/src/term.c index 2158fe37fe..b287121692 100644 --- a/src/term.c +++ b/src/term.c @@ -1957,6 +1957,8 @@ set_termname(char_u *term) #if defined(UNIX) || defined(VMS) term_is_xterm = vim_is_xterm(term); #endif + is_not_xterm = FALSE; + is_mac_terminal = FALSE; #ifdef FEAT_MOUSE # if defined(UNIX) || defined(VMS) diff --git a/src/testdir/test_termcodes.vim b/src/testdir/test_termcodes.vim index 0a4170e38b..ae20280fe3 100644 --- a/src/testdir/test_termcodes.vim +++ b/src/testdir/test_termcodes.vim @@ -906,7 +906,18 @@ func Test_xx03_xterm_response() " Termresponse is only parsed when t_RV is not empty. set t_RV=x + " Do Terminal.app first to check that is_mac_terminal is reset. + set ttymouse=xterm + call test_option_not_set('ttymouse') + let seq = "\[>1;95;0c" + call feedkeys(seq, 'Lx!') + call assert_equal(seq, v:termresponse) + call assert_equal('sgr', &ttymouse) + " xterm < 95: "xterm" (actually unmodified) + set t_RV= + set term=xterm + set t_RV=x set ttymouse=xterm call test_option_not_set('ttymouse') let seq = "\[>0;94;0c" diff --git a/src/version.c b/src/version.c index 4f0e6faa5c..78d0dc9bae 100644 --- a/src/version.c +++ b/src/version.c @@ -753,6 +753,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2169, /**/ 2168, /**/ From 0d2c4bf1714a6b286bd7a10061044414e0b17a15 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 17 Oct 2019 22:17:02 +0200 Subject: [PATCH 02/30] patch 8.1.2170: cannot build without the +termresponse feature Problem: Cannot build without the +termresponse feature. Solution: Add #ifdef. --- src/term.c | 2 ++ src/version.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/term.c b/src/term.c index b287121692..ef857a1a62 100644 --- a/src/term.c +++ b/src/term.c @@ -1957,8 +1957,10 @@ set_termname(char_u *term) #if defined(UNIX) || defined(VMS) term_is_xterm = vim_is_xterm(term); #endif +#ifdef FEAT_TERMRESPONSE is_not_xterm = FALSE; is_mac_terminal = FALSE; +#endif #ifdef FEAT_MOUSE # if defined(UNIX) || defined(VMS) diff --git a/src/version.c b/src/version.c index 78d0dc9bae..b7d9cb7d87 100644 --- a/src/version.c +++ b/src/version.c @@ -753,6 +753,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2170, /**/ 2169, /**/ From a1cb1d1dce14dd005797590721f1bcd0e7c3b35f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 17 Oct 2019 23:00:07 +0200 Subject: [PATCH 03/30] patch 8.1.2171: mouse support not always available Problem: Mouse support not always available. Solution: Enable mouse support also in tiny version. Do not define FEAT_MOUSE_XTERM on MS-Windows (didn't really work). --- src/edit.c | 9 +----- src/evalfunc.c | 4 --- src/ex_getln.c | 15 ++------- src/feature.h | 41 +++++++----------------- src/getchar.c | 12 ++----- src/globals.h | 14 +++------ src/message.c | 7 +---- src/misc1.c | 4 --- src/mouse.c | 54 ++++++++------------------------ src/move.c | 28 +++-------------- src/normal.c | 16 ++-------- src/ops.c | 2 -- src/option.c | 4 +-- src/option.h | 2 +- src/optiondefs.h | 2 +- src/optionstr.c | 17 +++------- src/os_unix.c | 54 +++++++++++++++----------------- src/os_win32.c | 58 +++++++++++----------------------- src/os_win32.h | 2 +- src/register.c | 2 -- src/term.c | 57 +++++++++++++--------------------- src/testing.c | 2 -- src/version.c | 18 +++-------- src/vim.h | 81 +++++++++++++++++++++++------------------------- src/window.c | 3 -- 25 files changed, 157 insertions(+), 351 deletions(-) diff --git a/src/edit.c b/src/edit.c index 78f5cd74fe..4cbfc773b3 100644 --- a/src/edit.c +++ b/src/edit.c @@ -235,7 +235,6 @@ edit( conceal_check_cursor_line(); #endif -#ifdef FEAT_MOUSE /* * When doing a paste with the middle mouse button, Insstart is set to * where the paste started. @@ -243,7 +242,6 @@ edit( if (where_paste_started.lnum != 0) Insstart = where_paste_started; else -#endif { Insstart = curwin->w_cursor; if (startln) @@ -336,7 +334,6 @@ edit( */ if (restart_edit != 0 && stuff_empty()) { -#ifdef FEAT_MOUSE /* * After a paste we consider text typed to be part of the insert for * the pasted text. You can backspace over the pasted text too. @@ -344,7 +341,6 @@ edit( if (where_paste_started.lnum) arrow_used = FALSE; else -#endif arrow_used = TRUE; restart_edit = 0; @@ -381,9 +377,7 @@ edit( /* Need to save the line for undo before inserting the first char. */ ins_need_undo = TRUE; -#ifdef FEAT_MOUSE where_paste_started.lnum = 0; -#endif #ifdef FEAT_CINDENT can_cindent = TRUE; #endif @@ -980,7 +974,6 @@ doESCkey: inserted_space = FALSE; break; -#ifdef FEAT_MOUSE case K_LEFTMOUSE: /* mouse keys */ case K_LEFTMOUSE_NM: case K_LEFTDRAG: @@ -1017,7 +1010,7 @@ doESCkey: case K_MOUSERIGHT: /* Scroll wheel right */ ins_mousescroll(MSCR_RIGHT); break; -#endif + case K_PS: bracketed_paste(PASTE_INSERT, FALSE, NULL); if (cmdchar == K_PS) diff --git a/src/evalfunc.c b/src/evalfunc.c index 962c6c49bb..c43c8839bd 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -815,9 +815,7 @@ static funcentry_T global_functions[] = #ifdef FEAT_GUI {"test_scrollbar", 3, 3, FEARG_2, f_test_scrollbar}, #endif -#ifdef FEAT_MOUSE {"test_setmouse", 2, 2, 0, f_test_setmouse}, -#endif {"test_settime", 1, 1, FEARG_1, f_test_settime}, #ifdef FEAT_TIMERS {"timer_info", 0, 1, FEARG_1, f_timer_info}, @@ -3433,9 +3431,7 @@ f_has(typval_T *argvars, typval_T *rettv) "mksession", #endif "modify_fname", -#ifdef FEAT_MOUSE "mouse", -#endif #ifdef FEAT_MOUSESHAPE "mouseshape", #endif diff --git a/src/ex_getln.c b/src/ex_getln.c index 838bd84045..5816f3f9e7 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -795,11 +795,9 @@ getcmdline_int( int save_msg_scroll = msg_scroll; int save_State = State; /* remember State when called */ int some_key_typed = FALSE; /* one of the keys was typed */ -#ifdef FEAT_MOUSE /* mouse drag and release events are ignored, unless they are * preceded with a mouse down event */ int ignore_drag_release = TRUE; -#endif #ifdef FEAT_EVAL int break_ctrl_c = FALSE; #endif @@ -1856,7 +1854,6 @@ getcmdline_int( break; #endif -#ifdef FEAT_MOUSE case K_MIDDLEDRAG: case K_MIDDLERELEASE: goto cmdline_not_changed; /* Ignore mouse */ @@ -1961,8 +1958,6 @@ getcmdline_int( case K_MOUSEMOVE: goto cmdline_not_changed; -#endif /* FEAT_MOUSE */ - #ifdef FEAT_GUI case K_LEFTMOUSE_NM: /* mousefocus click, ignored */ case K_LEFTRELEASE_NM: @@ -2195,9 +2190,7 @@ getcmdline_int( case Ctrl_V: case Ctrl_Q: -#ifdef FEAT_MOUSE ignore_drag_release = TRUE; -#endif putcmdline('^', TRUE); c = get_literal(); /* get next (two) character(s) */ do_abbr = FALSE; /* don't do abbreviation now */ @@ -2213,13 +2206,11 @@ getcmdline_int( #ifdef FEAT_DIGRAPHS case Ctrl_K: -#ifdef FEAT_MOUSE ignore_drag_release = TRUE; -#endif putcmdline('?', TRUE); -#ifdef USE_ON_FLY_SCROLL +# ifdef USE_ON_FLY_SCROLL dont_scroll = TRUE; /* disallow scrolling here */ -#endif +# endif c = get_digraph(TRUE); extra_char = NUL; if (c != NUL) @@ -2227,7 +2218,7 @@ getcmdline_int( redrawcmd(); goto cmdline_not_changed; -#endif /* FEAT_DIGRAPHS */ +#endif // FEAT_DIGRAPHS #ifdef FEAT_RIGHTLEFT case Ctrl__: /* CTRL-_: switch language mode */ diff --git a/src/feature.h b/src/feature.h index b2ba1623ef..04bb30cc63 100644 --- a/src/feature.h +++ b/src/feature.h @@ -964,12 +964,12 @@ * console mouse handling. * +mouse_urxvt Unix only: Include code for for urxvt mosue handling. * +mouse Any mouse support (any of the above enabled). + * Always included, since either FEAT_MOUSE_XTERM or + * DOS_MOUSE is defined. */ /* OS/2 and Amiga console have no mouse support */ -#if !defined(AMIGA) -# ifdef FEAT_NORMAL -# define FEAT_MOUSE_XTERM -# endif +#if defined(UNIX) || defined(VMS) +# define FEAT_MOUSE_XTERM # ifdef FEAT_BIG # define FEAT_MOUSE_NET # endif @@ -979,12 +979,12 @@ # ifdef FEAT_BIG # define FEAT_MOUSE_URXVT # endif -# if defined(FEAT_NORMAL) && defined(MSWIN) -# define DOS_MOUSE -# endif -# if defined(FEAT_NORMAL) && defined(__QNX__) -# define FEAT_MOUSE_PTERM -# endif +#endif +#if defined(MSWIN) +# define DOS_MOUSE +#endif +#if defined(__QNX__) +# define FEAT_MOUSE_PTERM #endif /* @@ -1002,28 +1002,11 @@ # define FEAT_SYSMOUSE #endif -/* urxvt is a small variation of mouse_xterm, and shares its code */ +// urxvt is a small variation of mouse_xterm, and shares its code #if defined(FEAT_MOUSE_URXVT) && !defined(FEAT_MOUSE_XTERM) # define FEAT_MOUSE_XTERM #endif -/* Define FEAT_MOUSE when any of the above is defined or FEAT_GUI. */ -#if !defined(FEAT_MOUSE_TTY) \ - && (defined(FEAT_MOUSE_XTERM) \ - || defined(FEAT_MOUSE_NET) \ - || defined(FEAT_MOUSE_DEC) \ - || defined(DOS_MOUSE) \ - || defined(FEAT_MOUSE_GPM) \ - || defined(FEAT_MOUSE_JSB) \ - || defined(FEAT_MOUSE_PTERM) \ - || defined(FEAT_SYSMOUSE) \ - || defined(FEAT_MOUSE_URXVT)) -# define FEAT_MOUSE_TTY /* include non-GUI mouse support */ -#endif -#if !defined(FEAT_MOUSE) && (defined(FEAT_MOUSE_TTY) || defined(FEAT_GUI)) -# define FEAT_MOUSE /* include generic mouse support */ -#endif - /* * +clipboard Clipboard support. Always used for the GUI. * +xterm_clipboard Unix only: Include code for handling the clipboard @@ -1093,7 +1076,7 @@ * to check if mouse dragging can be used and if term * codes can be obtained. */ -#if (defined(FEAT_NORMAL) || defined(FEAT_MOUSE)) && defined(HAVE_TGETENT) +#if defined(HAVE_TGETENT) # define FEAT_TERMRESPONSE #endif diff --git a/src/getchar.c b/src/getchar.c index 475bfca8e1..03a67be34a 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -1325,10 +1325,8 @@ save_typebuf(void) static int old_char = -1; /* character put back by vungetc() */ static int old_mod_mask; /* mod_mask for ungotten character */ -#ifdef FEAT_MOUSE static int old_mouse_row; /* mouse_row related to old_char */ static int old_mouse_col; /* mouse_col related to old_char */ -#endif /* * Save all three kinds of typeahead, so that the user must type at a prompt. @@ -1559,10 +1557,8 @@ vgetc(void) c = old_char; old_char = -1; mod_mask = old_mod_mask; -#ifdef FEAT_MOUSE mouse_row = old_mouse_row; mouse_col = old_mouse_col; -#endif } else { @@ -2007,7 +2003,6 @@ f_getchar(typval_T *argvars, typval_T *rettv) rettv->v_type = VAR_STRING; rettv->vval.v_string = vim_strsave(temp); -#ifdef FEAT_MOUSE if (is_mouse_key(n)) { int row = mouse_row; @@ -2025,11 +2020,11 @@ f_getchar(typval_T *argvars, typval_T *rettv) if (win == NULL) return; (void)mouse_comp_pos(win, &row, &col, &lnum, NULL); -# ifdef FEAT_TEXT_PROP +#ifdef FEAT_TEXT_PROP if (WIN_IS_POPUP(win)) winnr = 0; else -# endif +#endif for (wp = firstwin; wp != win && wp != NULL; wp = wp->w_next) ++winnr; @@ -2039,7 +2034,6 @@ f_getchar(typval_T *argvars, typval_T *rettv) set_vim_var_nr(VV_MOUSE_COL, col + 1); } } -#endif } } @@ -2636,10 +2630,8 @@ vungetc(int c) { old_char = c; old_mod_mask = mod_mask; -#ifdef FEAT_MOUSE old_mouse_row = mouse_row; old_mouse_col = mouse_col; -#endif } /* diff --git a/src/globals.h b/src/globals.h index 014fca2ad4..3f883d1cf3 100644 --- a/src/globals.h +++ b/src/globals.h @@ -470,7 +470,6 @@ EXTERN bufref_T au_new_curbuf INIT(= {NULL COMMA 0 COMMA 0}); EXTERN buf_T *au_pending_free_buf INIT(= NULL); EXTERN win_T *au_pending_free_win INIT(= NULL); -#ifdef FEAT_MOUSE /* * Mouse coordinates, set by check_termcode() */ @@ -480,15 +479,15 @@ EXTERN int mouse_past_bottom INIT(= FALSE);// mouse below last line EXTERN int mouse_past_eol INIT(= FALSE); // mouse right of line EXTERN int mouse_dragging INIT(= 0); // extending Visual area with // mouse dragging -# if defined(FEAT_MOUSE_DEC) +#if defined(FEAT_MOUSE_DEC) /* * When the DEC mouse has been pressed but not yet released we enable * automatic queries for the mouse position. */ EXTERN int WantQueryMouse INIT(= FALSE); -# endif +#endif -# ifdef FEAT_GUI +#ifdef FEAT_GUI // When the window layout is about to be changed, need_mouse_correct is set, // so that gui_mouse_correct() is called afterwards, to correct the mouse // pointer when focus-follow-mouse is being used. @@ -496,10 +495,10 @@ EXTERN int need_mouse_correct INIT(= FALSE); // When double clicking, topline must be the same EXTERN linenr_T gui_prev_topline INIT(= 0); -# ifdef FEAT_DIFF +# ifdef FEAT_DIFF EXTERN int gui_prev_topfill INIT(= 0); -# endif # endif +#endif # ifdef FEAT_MOUSESHAPE EXTERN int drag_status_line INIT(= FALSE); // dragging the status line @@ -508,7 +507,6 @@ EXTERN int postponed_mouseshape INIT(= FALSE); // postponed updating the EXTERN int drag_sep_line INIT(= FALSE); // dragging vert separator # endif -#endif #ifdef FEAT_DIFF // Value set from 'diffopt'. @@ -785,13 +783,11 @@ EXTERN int resel_VIsual_mode INIT(= NUL); // 'v', 'V', or Ctrl-V EXTERN linenr_T resel_VIsual_line_count; // number of lines EXTERN colnr_T resel_VIsual_vcol; // nr of cols or end col -#ifdef FEAT_MOUSE /* * When pasting text with the middle mouse button in visual mode with * restart_edit set, remember where it started so we can set Insstart. */ EXTERN pos_T where_paste_started; -#endif /* * This flag is used to make auto-indent work right on lines where only a diff --git a/src/message.c b/src/message.c index fddb28e2b8..8af5d7b03b 100644 --- a/src/message.c +++ b/src/message.c @@ -1200,7 +1200,6 @@ wait_return(int redraw) #ifdef FEAT_GUI || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR #endif -#ifdef FEAT_MOUSE || c == K_LEFTDRAG || c == K_LEFTRELEASE || c == K_MIDDLEDRAG || c == K_MIDDLERELEASE || c == K_RIGHTDRAG || c == K_RIGHTRELEASE @@ -1214,19 +1213,15 @@ wait_return(int redraw) || c == K_RIGHTMOUSE || c == K_X1MOUSE || c == K_X2MOUSE)) -#endif ); ui_breakcheck(); -#ifdef FEAT_MOUSE /* * Avoid that the mouse-up event causes visual mode to start. */ if (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE || c == K_RIGHTMOUSE || c == K_X1MOUSE || c == K_X2MOUSE) (void)jump_to_mouse(MOUSE_SETPOS, NULL, 0); - else -#endif - if (vim_strchr((char_u *)"\r\n ", c) == NULL && c != Ctrl_C) + else if (vim_strchr((char_u *)"\r\n ", c) == NULL && c != Ctrl_C) { /* Put the character back in the typeahead buffer. Don't use the * stuff buffer, because lmaps wouldn't work. */ diff --git a/src/misc1.c b/src/misc1.c index d359ffd978..0e182555ac 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -847,9 +847,7 @@ get_keystroke(void) n = TO_SPECIAL(buf[1], buf[2]); if (buf[1] == KS_MODIFIER || n == K_IGNORE -#ifdef FEAT_MOUSE || (is_mouse_key(n) && n != K_LEFTMOUSE) -#endif #ifdef FEAT_GUI || n == K_VER_SCROLLBAR || n == K_HOR_SCROLLBAR @@ -929,14 +927,12 @@ get_number( } n /= 10; } -#ifdef FEAT_MOUSE else if (mouse_used != NULL && c == K_LEFTMOUSE) { *mouse_used = TRUE; n = mouse_row + 1; break; } -#endif else if (n == 0 && c == ':' && colon) { stuffcharReadbuff(':'); diff --git a/src/mouse.c b/src/mouse.c index 498ff049bf..b71ef37a4c 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -13,8 +13,6 @@ #include "vim.h" -#if defined(FEAT_MOUSE) || defined(PROTO) - /* * Get class of a character for selection: same class means same word. * 0: blank @@ -1258,20 +1256,17 @@ get_pseudo_mouse_code( return (int)KE_IGNORE; // not recognized, ignore it } -# ifdef FEAT_MOUSE_TTY -# define HMT_NORMAL 1 -# define HMT_NETTERM 2 -# define HMT_DEC 4 -# define HMT_JSBTERM 8 -# define HMT_PTERM 16 -# define HMT_URXVT 32 -# define HMT_GPM 64 -# define HMT_SGR 128 -# define HMT_SGR_REL 256 +# define HMT_NORMAL 1 +# define HMT_NETTERM 2 +# define HMT_DEC 4 +# define HMT_JSBTERM 8 +# define HMT_PTERM 16 +# define HMT_URXVT 32 +# define HMT_GPM 64 +# define HMT_SGR 128 +# define HMT_SGR_REL 256 static int has_mouse_termcode = 0; -# endif -# if (!defined(UNIX) || defined(FEAT_MOUSE_TTY)) || defined(PROTO) void set_mouse_termcode( int n, // KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE @@ -1282,7 +1277,6 @@ set_mouse_termcode( name[0] = n; name[1] = KE_FILLER; add_termcode(name, s, FALSE); -# ifdef FEAT_MOUSE_TTY # ifdef FEAT_MOUSE_JSB if (n == KS_JSBTERM_MOUSE) has_mouse_termcode |= HMT_JSBTERM; @@ -1319,12 +1313,9 @@ set_mouse_termcode( has_mouse_termcode |= HMT_SGR_REL; else has_mouse_termcode |= HMT_NORMAL; -# endif } -# endif -# if ((defined(UNIX) || defined(VMS)) \ - && defined(FEAT_MOUSE_TTY)) || defined(PROTO) +# if defined(UNIX) || defined(VMS) || defined(PROTO) void del_mouse_termcode( int n) // KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE @@ -1334,7 +1325,6 @@ del_mouse_termcode( name[0] = n; name[1] = KE_FILLER; del_termcode(name); -# ifdef FEAT_MOUSE_TTY # ifdef FEAT_MOUSE_JSB if (n == KS_JSBTERM_MOUSE) has_mouse_termcode &= ~HMT_JSBTERM; @@ -1371,7 +1361,6 @@ del_mouse_termcode( has_mouse_termcode &= ~HMT_SGR_REL; else has_mouse_termcode &= ~HMT_NORMAL; -# endif } # endif @@ -1381,15 +1370,13 @@ del_mouse_termcode( void setmouse(void) { -# ifdef FEAT_MOUSE_TTY int checkfor; -# endif # ifdef FEAT_MOUSESHAPE update_mouseshape(-1); # endif -# ifdef FEAT_MOUSE_TTY // Should be outside proc, but may break MOUSESHAPE + // Should be outside proc, but may break MOUSESHAPE # ifdef FEAT_GUI // In the GUI the mouse is always enabled. if (gui.in_use) @@ -1423,7 +1410,6 @@ setmouse(void) mch_setmouse(TRUE); else mch_setmouse(FALSE); -# endif } /* @@ -2289,7 +2275,7 @@ check_termcode_mouse( # endif ) { -# if defined(UNIX) && defined(FEAT_MOUSE_TTY) +# if defined(UNIX) if (use_xterm_mouse() > 1 && mouse_code >= 0x80) // mouse-move event, using MOUSE_DRAG works mouse_code = MOUSE_DRAG; @@ -2314,7 +2300,7 @@ check_termcode_mouse( } # endif -# if defined(UNIX) && defined(FEAT_MOUSE_TTY) +# if defined(UNIX) else if (use_xterm_mouse() > 1) { if (mouse_code & MOUSE_DRAG_XTERM) @@ -2810,10 +2796,8 @@ check_termcode_mouse( return 0; } -#endif // FEAT_MOUSE // Functions also used for popup windows. -#if defined(FEAT_MOUSE) || defined(FEAT_TEXT_PROP) || defined(PROTO) /* * Compute the buffer line position from the screen position "rowp" / "colp" in @@ -3017,15 +3001,3 @@ vcol2col(win_T *wp, linenr_T lnum, int vcol) return (int)(ptr - line); } #endif - -#else // FEAT_MOUSE - -/* - * Dummy implementation of setmouse() to avoid lots of #ifdefs. - */ - void -setmouse(void) -{ -} - -#endif // FEAT_MOUSE diff --git a/src/move.c b/src/move.c index 223ed5417e..97f5ac1b7d 100644 --- a/src/move.c +++ b/src/move.c @@ -190,9 +190,7 @@ update_topline(void) int check_topline = FALSE; int check_botline = FALSE; long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so; -#ifdef FEAT_MOUSE int save_so = *so_ptr; -#endif /* If there is no valid screen and when the window height is zero just use * the cursor line. */ @@ -209,11 +207,9 @@ update_topline(void) if (curwin->w_valid & VALID_TOPLINE) return; -#ifdef FEAT_MOUSE /* When dragging with the mouse, don't scroll that quickly */ if (mouse_dragging > 0) *so_ptr = mouse_dragging - 1; -#endif old_topline = curwin->w_topline; #ifdef FEAT_DIFF @@ -418,9 +414,7 @@ update_topline(void) validate_cursor(); } -#ifdef FEAT_MOUSE *so_ptr = save_so; -#endif } /* @@ -1751,10 +1745,8 @@ scroll_cursor_top(int min_scroll, int always) linenr_T new_topline; int off = get_scrolloff_value(); -#ifdef FEAT_MOUSE if (mouse_dragging > 0) off = mouse_dragging - 1; -#endif /* * Decrease topline until: @@ -2004,11 +1996,7 @@ scroll_cursor_bot(int min_scroll, int set_topbot) /* Stop when scrolled nothing or at least "min_scroll", found "extra" * context for 'scrolloff' and counted all lines below the window. */ if ((((scrolled <= 0 || scrolled >= min_scroll) - && extra >= ( -#ifdef FEAT_MOUSE - mouse_dragging > 0 ? mouse_dragging - 1 : -#endif - so)) + && extra >= (mouse_dragging > 0 ? mouse_dragging - 1 : so)) || boff.lnum + 1 > curbuf->b_ml.ml_line_count) && loff.lnum <= curwin->w_botline #ifdef FEAT_DIFF @@ -2050,11 +2038,8 @@ scroll_cursor_bot(int min_scroll, int set_topbot) used += boff.height; if (used > curwin->w_height) break; - if (extra < ( -#ifdef FEAT_MOUSE - mouse_dragging > 0 ? mouse_dragging - 1 : -#endif - so) || scrolled < min_scroll) + if (extra < ( mouse_dragging > 0 ? mouse_dragging - 1 : so) + || scrolled < min_scroll) { extra += boff.height; if (boff.lnum >= curwin->w_botline @@ -2230,13 +2215,11 @@ cursor_correct(void) */ above_wanted = so; below_wanted = so; -#ifdef FEAT_MOUSE if (mouse_dragging > 0) { above_wanted = mouse_dragging - 1; below_wanted = mouse_dragging - 1; } -#endif if (curwin->w_topline == 1) { above_wanted = 0; @@ -2246,10 +2229,7 @@ cursor_correct(void) } validate_botline(); if (curwin->w_botline == curbuf->b_ml.ml_line_count + 1 -#ifdef FEAT_MOUSE - && mouse_dragging == 0 -#endif - ) + && mouse_dragging == 0) { below_wanted = 0; max_off = (curwin->w_height - 1) / 2; diff --git a/src/normal.c b/src/normal.c index 50f7b3185d..87754eb40e 100644 --- a/src/normal.c +++ b/src/normal.c @@ -303,7 +303,6 @@ static const struct nv_cmd /* pound sign */ {POUND, nv_ident, 0, 0}, -#ifdef FEAT_MOUSE {K_MOUSEUP, nv_mousescroll, 0, MSCR_UP}, {K_MOUSEDOWN, nv_mousescroll, 0, MSCR_DOWN}, {K_MOUSELEFT, nv_mousescroll, 0, MSCR_LEFT}, @@ -326,7 +325,6 @@ static const struct nv_cmd {K_X2MOUSE, nv_mouse, 0, 0}, {K_X2DRAG, nv_mouse, 0, 0}, {K_X2RELEASE, nv_mouse, 0, 0}, -#endif {K_IGNORE, nv_ignore, NV_KEEPREG, 0}, {K_NOP, nv_nop, 0, 0}, {K_INS, nv_edit, 0, 0}, @@ -1319,10 +1317,8 @@ end_visual_mode(void) #endif VIsual_active = FALSE; -#ifdef FEAT_MOUSE setmouse(); mouse_dragging = 0; -#endif /* Save the current VIsual area for '< and '> marks, and "gv" */ curbuf->b_visual.vi_mode = VIsual_mode; @@ -1849,14 +1845,13 @@ add_to_showcmd(int c) int old_len; int extra_len; int overflow; -#if defined(FEAT_MOUSE) int i; static int ignore[] = { -# ifdef FEAT_GUI +#ifdef FEAT_GUI K_VER_SCROLLBAR, K_HOR_SCROLLBAR, K_LEFTMOUSE_NM, K_LEFTRELEASE_NM, -# endif +#endif K_IGNORE, K_PS, K_LEFTMOUSE, K_LEFTDRAG, K_LEFTRELEASE, K_MOUSEMOVE, K_MIDDLEMOUSE, K_MIDDLEDRAG, K_MIDDLERELEASE, @@ -1866,7 +1861,6 @@ add_to_showcmd(int c) K_CURSORHOLD, 0 }; -#endif if (!p_sc || msg_silent != 0) return FALSE; @@ -1877,13 +1871,11 @@ add_to_showcmd(int c) showcmd_visual = FALSE; } -#if defined(FEAT_MOUSE) /* Ignore keys that are scrollbar updates and mouse clicks */ if (IS_SPECIAL(c)) for (i = 0; ignore[i] != 0; ++i) if (ignore[i] == c) return FALSE; -#endif p = transchar(c); if (*p == ' ') @@ -4625,7 +4617,6 @@ nv_brackets(cmdarg_T *cap) nv_cursormark(cap, cap->nchar == '\'', pos); } -#ifdef FEAT_MOUSE /* * [ or ] followed by a middle mouse click: put selected text with * indent adjustment. Any other button just does as usual. @@ -4636,7 +4627,6 @@ nv_brackets(cmdarg_T *cap) (cap->cmdchar == ']') ? FORWARD : BACKWARD, cap->count1, PUT_FIXINDENT); } -#endif /* FEAT_MOUSE */ #ifdef FEAT_FOLDING /* @@ -6220,7 +6210,6 @@ nv_g_cmd(cmdarg_T *cap) nv_gd(oap, cap->nchar, (int)cap->count0); break; -#ifdef FEAT_MOUSE /* * g<*Mouse> : */ @@ -6243,7 +6232,6 @@ nv_g_cmd(cmdarg_T *cap) mod_mask = MOD_MASK_CTRL; (void)do_mouse(oap, cap->nchar, BACKWARD, cap->count1, 0); break; -#endif case K_IGNORE: break; diff --git a/src/ops.c b/src/ops.c index a008a9d48b..6a9fbba816 100644 --- a/src/ops.c +++ b/src/ops.c @@ -4369,10 +4369,8 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) if (!gui_yank) { VIsual_active = FALSE; -#ifdef FEAT_MOUSE setmouse(); mouse_dragging = 0; -#endif may_clear_cmdline(); if ((oap->op_type == OP_YANK || oap->op_type == OP_COLON diff --git a/src/option.c b/src/option.c index 898068b416..d27c73c3b4 100644 --- a/src/option.c +++ b/src/option.c @@ -4976,9 +4976,7 @@ clear_termoptions(void) * outputting a few things that the terminal doesn't understand, but the * screen will be cleared later, so this is OK. */ -#ifdef FEAT_MOUSE_TTY - mch_setmouse(FALSE); /* switch mouse off */ -#endif + mch_setmouse(FALSE); // switch mouse off #ifdef FEAT_TITLE mch_restore_title(SAVE_RESTORE_BOTH); /* restore window titles */ #endif diff --git a/src/option.h b/src/option.h index aaa9443776..254ca6a282 100644 --- a/src/option.h +++ b/src/option.h @@ -979,7 +979,7 @@ EXTERN unsigned tbis_flags; # define TBIS_GIANT 0x20 #endif EXTERN long p_ttyscroll; // 'ttyscroll' -#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS)) +#if defined(UNIX) || defined(VMS) EXTERN char_u *p_ttym; // 'ttymouse' EXTERN unsigned ttym_flags; # define TTYM_XTERM 0x01 diff --git a/src/optiondefs.h b/src/optiondefs.h index 47f17ed392..b557771cfb 100644 --- a/src/optiondefs.h +++ b/src/optiondefs.h @@ -2655,7 +2655,7 @@ static struct vimoption options[] = (char_u *)&p_tf, PV_NONE, {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF, -#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS)) +#if defined(UNIX) || defined(VMS) (char_u *)&p_ttym, PV_NONE, #else (char_u *)NULL, PV_NONE, diff --git a/src/optionstr.c b/src/optionstr.c index a5b5b55a57..7b83aed250 100644 --- a/src/optionstr.c +++ b/src/optionstr.c @@ -47,7 +47,7 @@ static char *(p_toolbar_values[]) = {"text", "icons", "tooltips", "horiz", NULL} #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) static char *(p_tbis_values[]) = {"tiny", "small", "medium", "large", "huge", "giant", NULL}; #endif -#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS)) +#if defined(UNIX) || defined(VMS) static char *(p_ttym_values[]) = {"xterm", "xterm2", "dec", "netterm", "jsbterm", "pterm", "urxvt", "sgr", NULL}; #endif static char *(p_ve_values[]) = {"block", "insert", "all", "onemore", NULL}; @@ -110,7 +110,7 @@ didset_string_options(void) (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE); (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE); (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE); -#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS)) +#if defined(UNIX) || defined(VMS) (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE); #endif #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) @@ -1588,7 +1588,7 @@ did_set_string_option( } #endif -#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS)) +#if defined(UNIX) || defined(VMS) // 'ttymouse' else if (varp == &p_ttym) { @@ -2254,12 +2254,7 @@ did_set_string_option( #endif else if (varp == &p_mouse) // 'mouse' { -#ifdef FEAT_MOUSE p = (char_u *)MOUSE_ALL; -#else - if (*p_mouse != NUL) - errmsg = N_("E538: No mouse support"); -#endif } #if defined(FEAT_GUI) else if (varp == &p_go) // 'guioptions' @@ -2389,20 +2384,16 @@ did_set_string_option( #endif } -#ifdef FEAT_MOUSE if (varp == &p_mouse) { -# ifdef FEAT_MOUSE_TTY if (*p_mouse == NUL) mch_setmouse(FALSE); // switch mouse off else -# endif setmouse(); // in case 'mouse' changed } -#endif if (curwin->w_curswant != MAXCOL - && (get_option_flags(opt_idx) & (P_CURSWANT | P_RALL)) != 0) + && (get_option_flags(opt_idx) & (P_CURSWANT | P_RALL)) != 0) curwin->w_set_curswant = TRUE; #ifdef FEAT_GUI diff --git a/src/os_unix.c b/src/os_unix.c index 54989af88d..e518bb91fc 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2282,7 +2282,6 @@ use_xterm_like_mouse(char_u *name) } #endif -#if defined(FEAT_MOUSE_TTY) || defined(PROTO) /* * Return non-zero when using an xterm mouse, according to 'ttymouse'. * Return 1 for "xterm". @@ -2303,7 +2302,6 @@ use_xterm_mouse(void) return 1; return 0; } -#endif int vim_is_iris(char_u *name) @@ -3592,7 +3590,6 @@ get_tty_info(int fd, ttyinfo_T *info) #endif /* VMS */ -#if defined(FEAT_MOUSE_TTY) || defined(PROTO) static int mouse_ison = FALSE; /* @@ -3601,29 +3598,29 @@ static int mouse_ison = FALSE; void mch_setmouse(int on) { -# ifdef FEAT_BEVAL_TERM +#ifdef FEAT_BEVAL_TERM static int bevalterm_ison = FALSE; -# endif +#endif int xterm_mouse_vers; -# if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) +#if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) if (!on) // Make sure not tracing mouse movements. Important when a button-down // was received but no release yet. stop_xterm_trace(); -# endif +#endif if (on == mouse_ison -# ifdef FEAT_BEVAL_TERM +#ifdef FEAT_BEVAL_TERM && p_bevalterm == bevalterm_ison -# endif +#endif ) /* return quickly if nothing to do */ return; xterm_mouse_vers = use_xterm_mouse(); -# ifdef FEAT_MOUSE_URXVT +#ifdef FEAT_MOUSE_URXVT if (ttym_flags == TTYM_URXVT) { out_str_nf((char_u *) @@ -3632,7 +3629,7 @@ mch_setmouse(int on) : IF_EB("\033[?1015l", ESC_STR "[?1015l"))); mouse_ison = on; } -# endif +#endif if (ttym_flags == TTYM_SGR) { @@ -3644,7 +3641,7 @@ mch_setmouse(int on) mouse_ison = on; } -# ifdef FEAT_BEVAL_TERM +#ifdef FEAT_BEVAL_TERM if (bevalterm_ison != (p_bevalterm && on)) { bevalterm_ison = (p_bevalterm && on); @@ -3653,7 +3650,7 @@ mch_setmouse(int on) out_str_nf((char_u *) (IF_EB("\033[?1003l", ESC_STR "[?1003l"))); } -# endif +#endif if (xterm_mouse_vers > 0) { @@ -3661,10 +3658,10 @@ mch_setmouse(int on) out_str_nf((char_u *) (xterm_mouse_vers > 1 ? ( -# ifdef FEAT_BEVAL_TERM +#ifdef FEAT_BEVAL_TERM bevalterm_ison ? IF_EB("\033[?1003h", ESC_STR "[?1003h") : -# endif +#endif IF_EB("\033[?1002h", ESC_STR "[?1002h")) : IF_EB("\033[?1000h", ESC_STR "[?1000h"))); else /* disable mouse events, could probably always send the same */ @@ -3675,7 +3672,7 @@ mch_setmouse(int on) mouse_ison = on; } -# ifdef FEAT_MOUSE_DEC +#ifdef FEAT_MOUSE_DEC else if (ttym_flags == TTYM_DEC) { if (on) /* enable mouse events */ @@ -3684,9 +3681,9 @@ mch_setmouse(int on) out_str_nf((char_u *)"\033['z"); mouse_ison = on; } -# endif +#endif -# ifdef FEAT_MOUSE_GPM +#ifdef FEAT_MOUSE_GPM else { if (on) @@ -3700,9 +3697,9 @@ mch_setmouse(int on) mouse_ison = FALSE; } } -# endif +#endif -# ifdef FEAT_SYSMOUSE +#ifdef FEAT_SYSMOUSE else { if (on) @@ -3716,9 +3713,9 @@ mch_setmouse(int on) mouse_ison = FALSE; } } -# endif +#endif -# ifdef FEAT_MOUSE_JSB +#ifdef FEAT_MOUSE_JSB else { if (on) @@ -3738,14 +3735,14 @@ mch_setmouse(int on) * 4 = Windows Cross Hair * 5 = Windows UP Arrow */ -# ifdef JSBTERM_MOUSE_NONADVANCED +# ifdef JSBTERM_MOUSE_NONADVANCED /* Disables full feedback of pointer movements */ out_str_nf((char_u *)IF_EB("\033[0~ZwLMRK1Q\033\\", ESC_STR "[0~ZwLMRK1Q" ESC_STR "\\")); -# else +# else out_str_nf((char_u *)IF_EB("\033[0~ZwLMRK+1Q\033\\", ESC_STR "[0~ZwLMRK+1Q" ESC_STR "\\")); -# endif +# endif mouse_ison = TRUE; } else @@ -3755,8 +3752,8 @@ mch_setmouse(int on) mouse_ison = FALSE; } } -# endif -# ifdef FEAT_MOUSE_PTERM +#endif +#ifdef FEAT_MOUSE_PTERM else { /* 1 = button press, 6 = release, 7 = drag, 1h...9l = right button */ @@ -3766,7 +3763,7 @@ mch_setmouse(int on) out_str_nf("\033[>1l\033[>6l\033[>7l\033[>1l\033[>9h"); mouse_ison = on; } -# endif +#endif } #if defined(FEAT_BEVAL_TERM) || defined(PROTO) @@ -3929,7 +3926,6 @@ check_mouse_termcode(void) del_mouse_termcode(KS_SGR_MOUSE_RELEASE); } } -#endif /* * set screen mode, always fails. diff --git a/src/os_win32.c b/src/os_win32.c index 9badbed41f..13960d167e 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -1127,17 +1127,15 @@ decode_key_event( #endif /* FEAT_GUI_MSWIN */ -#ifdef FEAT_MOUSE - /* * For the GUI the mouse handling is in gui_w32.c. */ -# if defined(FEAT_GUI_MSWIN) && !defined(VIMDLL) +#if defined(FEAT_GUI_MSWIN) && !defined(VIMDLL) void mch_setmouse(int on UNUSED) { } -# else +#else static int g_fMouseAvail = FALSE; /* mouse present */ static int g_fMouseActive = FALSE; /* mouse enabled */ static int g_nMouseClick = -1; /* mouse status */ @@ -1152,10 +1150,10 @@ mch_setmouse(int on) { DWORD cmodein; -# ifdef VIMDLL +# ifdef VIMDLL if (gui.in_use) return; -# endif +# endif if (!g_fMouseAvail) return; @@ -1171,7 +1169,7 @@ mch_setmouse(int on) } -#if defined(FEAT_BEVAL_TERM) || defined(PROTO) +# if defined(FEAT_BEVAL_TERM) || defined(PROTO) /* * Called when 'balloonevalterm' changed. */ @@ -1180,7 +1178,7 @@ mch_bevalterm_changed(void) { mch_setmouse(g_fMouseActive); } -#endif +# endif /* * Decode a MOUSE_EVENT. If it's a valid event, return MOUSE_LEFT, @@ -1218,9 +1216,9 @@ decode_mouse_event( static int s_xOldMouse = -1; static int s_yOldMouse = -1; static linenr_T s_old_topline = 0; -#ifdef FEAT_DIFF +# ifdef FEAT_DIFF static int s_old_topfill = 0; -#endif +# endif static int s_cClicks = 1; static BOOL s_fReleased = TRUE; static DWORD s_dwLastClickTime = 0; @@ -1275,12 +1273,12 @@ decode_mouse_event( /* If the last thing returned was MOUSE_RELEASE, ignore this */ if (s_fReleased) { -#ifdef FEAT_BEVAL_TERM +# ifdef FEAT_BEVAL_TERM /* do return mouse move events when we want them */ if (p_bevalterm) nButton = MOUSE_DRAG; else -#endif +# endif return FALSE; } @@ -1386,9 +1384,9 @@ decode_mouse_event( || s_yOldMouse != g_yMouse || s_nOldButton != nButton || s_old_topline != curwin->w_topline -#ifdef FEAT_DIFF +# ifdef FEAT_DIFF || s_old_topfill != curwin->w_topfill -#endif +# endif || (int)(dwCurrentTime - s_dwLastClickTime) > p_mouset) { s_cClicks = 1; @@ -1439,16 +1437,15 @@ decode_mouse_event( s_xOldMouse = g_xMouse; s_yOldMouse = g_yMouse; s_old_topline = curwin->w_topline; -#ifdef FEAT_DIFF +# ifdef FEAT_DIFF s_old_topfill = curwin->w_topfill; -#endif +# endif s_nOldMouseClick = g_nMouseClick; return TRUE; } -# endif /* FEAT_GUI_MSWIN */ -#endif /* FEAT_MOUSE */ +#endif // FEAT_GUI_MSWIN #ifdef MCH_CURSOR_SHAPE @@ -1547,10 +1544,7 @@ WaitForChar(long msec, int ignore_input) #endif } - if (0 -#ifdef FEAT_MOUSE - || g_nMouseClick != -1 -#endif + if (g_nMouseClick != -1 #ifdef FEAT_CLIENTSERVER || (!ignore_input && input_available()) #endif @@ -1683,11 +1677,9 @@ WaitForChar(long msec, int ignore_input) shell_resized(); } } -#ifdef FEAT_MOUSE else if (ir.EventType == MOUSE_EVENT && decode_mouse_event(&ir.Event.MouseEvent)) return TRUE; -#endif } else if (msec == 0) break; @@ -1760,10 +1752,8 @@ tgetch(int *pmodifiers, WCHAR *pch2) (void)WaitForChar(-1L, FALSE); if (input_available()) return 0; -# ifdef FEAT_MOUSE if (g_nMouseClick != -1) return 0; -# endif #endif if (read_console_input(g_hConIn, &ir, 1, &cRecords) == 0) { @@ -1783,13 +1773,11 @@ tgetch(int *pmodifiers, WCHAR *pch2) handle_focus_event(ir); else if (ir.EventType == WINDOW_BUFFER_SIZE_EVENT) shell_resized(); -#ifdef FEAT_MOUSE else if (ir.EventType == MOUSE_EVENT) { if (decode_mouse_event(&ir.Event.MouseEvent)) return 0; } -#endif } } #endif /* !FEAT_GUI_MSWIN */ @@ -1879,14 +1867,13 @@ mch_inchar( typeaheadlen = 0; break; } -#ifdef FEAT_MOUSE if (g_nMouseClick != -1) { -# ifdef MCH_WRITE_DUMP +#ifdef MCH_WRITE_DUMP if (fdDump) fprintf(fdDump, "{%02x @ %d, %d}", g_nMouseClick, g_xMouse, g_yMouse); -# endif +#endif typeahead[typeaheadlen++] = ESC + 128; typeahead[typeaheadlen++] = 'M'; typeahead[typeaheadlen++] = g_nMouseClick; @@ -1895,7 +1882,6 @@ mch_inchar( g_nMouseClick = -1; } else -#endif { WCHAR ch2 = NUL; int modifiers = 0; @@ -1918,9 +1904,7 @@ mch_inchar( got_int = TRUE; } -#ifdef FEAT_MOUSE if (g_nMouseClick == -1) -#endif { int n = 1; @@ -2675,9 +2659,7 @@ mch_init_c(void) g_fWindInitCalled = TRUE; -#ifdef FEAT_MOUSE g_fMouseAvail = GetSystemMetrics(SM_MOUSEPRESENT); -#endif #ifdef FEAT_CLIPBOARD win_clip_init(); @@ -3609,10 +3591,8 @@ mch_settmode(int tmode) { cmodein &= ~(ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_ECHO_INPUT); -#ifdef FEAT_MOUSE if (g_fMouseActive) cmodein |= ENABLE_MOUSE_INPUT; -#endif cmodeout &= ~( #ifdef FEAT_TERMGUICOLORS /* Do not turn off the ENABLE_PROCESSED_OUTPUT flag when using @@ -5501,12 +5481,10 @@ termcap_mode_start(void) #endif GetConsoleMode(g_hConIn, &cmodein); -#ifdef FEAT_MOUSE if (g_fMouseActive) cmodein |= ENABLE_MOUSE_INPUT; else cmodein &= ~ENABLE_MOUSE_INPUT; -#endif cmodein |= ENABLE_WINDOW_INPUT; SetConsoleMode(g_hConIn, cmodein); diff --git a/src/os_win32.h b/src/os_win32.h index 2169bd3115..ac89911e16 100644 --- a/src/os_win32.h +++ b/src/os_win32.h @@ -62,7 +62,7 @@ #endif #define USE_FNAME_CASE /* adjust case of file names */ -#if !defined(FEAT_CLIPBOARD) && defined(FEAT_MOUSE) +#if !defined(FEAT_CLIPBOARD) # define FEAT_CLIPBOARD /* include clipboard support */ #endif #if defined(__DATE__) && defined(__TIME__) diff --git a/src/register.c b/src/register.c index eb40bba62e..a7e13775b2 100644 --- a/src/register.c +++ b/src/register.c @@ -352,7 +352,6 @@ free_register(void *reg) } #endif -#if defined(FEAT_MOUSE) || defined(PROTO) /* * return TRUE if the current yank register has type MLINE */ @@ -366,7 +365,6 @@ yank_register_mline(int regname) get_yank_register(regname, FALSE); return (y_current->y_type == MLINE); } -#endif /* * Start or stop recording into a yank register. diff --git a/src/term.c b/src/term.c index ef857a1a62..cfbd7fe597 100644 --- a/src/term.c +++ b/src/term.c @@ -1962,9 +1962,7 @@ set_termname(char_u *term) is_mac_terminal = FALSE; #endif -#ifdef FEAT_MOUSE -# if defined(UNIX) || defined(VMS) -# ifdef FEAT_MOUSE_TTY +#if defined(UNIX) || defined(VMS) /* * For Unix, set the 'ttymouse' option to the type of mouse to be used. * The termcode for the mouse is added as a side effect in option.c. @@ -1972,7 +1970,7 @@ set_termname(char_u *term) { char_u *p = (char_u *)""; -# ifdef FEAT_MOUSE_XTERM +# ifdef FEAT_MOUSE_XTERM if (use_xterm_like_mouse(term)) { if (use_xterm_mouse()) @@ -1980,7 +1978,7 @@ set_termname(char_u *term) else p = (char_u *)"xterm"; } -# endif +# endif if (p != NULL) { set_option_value((char_u *)"ttym", 0L, p, 0); @@ -1989,17 +1987,15 @@ set_termname(char_u *term) reset_option_was_set((char_u *)"ttym"); } if (p == NULL -# ifdef FEAT_GUI +# ifdef FEAT_GUI || gui.in_use -# endif +# endif ) check_mouse_termcode(); /* set mouse termcode anyway */ } -# endif -# else +#else set_mouse_termcode(KS_MOUSE, (char_u *)"\233M"); -# endif -#endif /* FEAT_MOUSE */ +#endif #ifdef USE_TERM_CONSOLE /* DEFAULT_TERM indicates that it is the machine console. */ @@ -2565,8 +2561,6 @@ out_char_nf(unsigned c) out_flush(); } -#if defined(FEAT_TITLE) || defined(FEAT_MOUSE_TTY) || defined(FEAT_GUI) \ - || defined(FEAT_TERMRESPONSE) || defined(PROTO) /* * A never-padding out_str. * use this whenever you don't want to run the string through tputs. @@ -2590,7 +2584,6 @@ out_str_nf(char_u *s) if (p_wd) out_flush(); } -#endif /* * A conditional-flushing out_str, mainly for visualbell. @@ -3151,9 +3144,6 @@ get_long_from_buf(char_u *buf, long_u *val) } #endif -#if defined(FEAT_GUI) \ - || (defined(FEAT_MOUSE) && (!defined(UNIX) || defined(FEAT_MOUSE_XTERM) \ - || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE))) /* * Read the next num_bytes bytes from buf, and store them in bytes. Assume * that buf has been through inchar(). Returns the actual number of bytes used @@ -3191,7 +3181,6 @@ get_bytes_from_buf(char_u *buf, char_u *bytes, int num_bytes) } return len; } -#endif /* * Check if the new shell size is valid, correct it if it's too small or way @@ -3436,10 +3425,8 @@ settmode(int tmode) check_for_codes_from_term(); } #endif -#ifdef FEAT_MOUSE_TTY if (tmode != TMODE_RAW) mch_setmouse(FALSE); // switch mouse off -#endif if (termcap_active) { if (tmode != TMODE_RAW) @@ -5084,8 +5071,7 @@ not_enough: /* We only get here when we have a complete termcode match */ -#ifdef FEAT_MOUSE -# ifdef FEAT_GUI +#ifdef FEAT_GUI /* * Only in the GUI: Fetch the pointer coordinates of the scroll event * so that we know which window to scroll later. @@ -5109,29 +5095,29 @@ not_enough: slen += num_bytes; } else -# endif +#endif /* * If it is a mouse click, get the coordinates. */ if (key_name[0] == KS_MOUSE -# ifdef FEAT_MOUSE_GPM +#ifdef FEAT_MOUSE_GPM || key_name[0] == KS_GPM_MOUSE -# endif -# ifdef FEAT_MOUSE_JSB +#endif +#ifdef FEAT_MOUSE_JSB || key_name[0] == KS_JSBTERM_MOUSE -# endif -# ifdef FEAT_MOUSE_NET +#endif +#ifdef FEAT_MOUSE_NET || key_name[0] == KS_NETTERM_MOUSE -# endif -# ifdef FEAT_MOUSE_DEC +#endif +#ifdef FEAT_MOUSE_DEC || key_name[0] == KS_DEC_MOUSE -# endif -# ifdef FEAT_MOUSE_PTERM +#endif +#ifdef FEAT_MOUSE_PTERM || key_name[0] == KS_PTERM_MOUSE -# endif -# ifdef FEAT_MOUSE_URXVT +#endif +#ifdef FEAT_MOUSE_URXVT || key_name[0] == KS_URXVT_MOUSE -# endif +#endif || key_name[0] == KS_SGR_MOUSE || key_name[0] == KS_SGR_MOUSE_RELEASE) { @@ -5139,7 +5125,6 @@ not_enough: &modifiers) == -1) return -1; } -#endif /* FEAT_MOUSE */ #ifdef FEAT_GUI /* diff --git a/src/testing.c b/src/testing.c index 748ec46e46..7543dd88b1 100644 --- a/src/testing.c +++ b/src/testing.c @@ -926,14 +926,12 @@ f_test_scrollbar(typval_T *argvars, typval_T *rettv UNUSED) } #endif -#ifdef FEAT_MOUSE void f_test_setmouse(typval_T *argvars, typval_T *rettv UNUSED) { mouse_row = (time_t)tv_get_number(&argvars[0]) - 1; mouse_col = (time_t)tv_get_number(&argvars[1]) - 1; } -#endif void f_test_settime(typval_T *argvars, typval_T *rettv UNUSED) diff --git a/src/version.c b/src/version.c index b7d9cb7d87..0dd36774db 100644 --- a/src/version.c +++ b/src/version.c @@ -359,15 +359,11 @@ static char *(features[]) = "-mksession", #endif "+modify_fname", -#ifdef FEAT_MOUSE "+mouse", -# ifdef FEAT_MOUSESHAPE +#ifdef FEAT_MOUSESHAPE "+mouseshape", -# else +#else "-mouseshape", -# endif -# else - "-mouse", #endif #if defined(UNIX) || defined(VMS) @@ -402,11 +398,7 @@ static char *(features[]) = #endif #if defined(UNIX) || defined(VMS) -# ifdef FEAT_MOUSE_XTERM "+mouse_sgr", -# else - "-mouse_sgr", -# endif # ifdef FEAT_SYSMOUSE "+mouse_sysmouse", # else @@ -417,11 +409,7 @@ static char *(features[]) = # else "-mouse_urxvt", # endif -# ifdef FEAT_MOUSE_XTERM "+mouse_xterm", -# else - "-mouse_xterm", -# endif #endif #ifdef FEAT_MBYTE_IME @@ -753,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2171, /**/ 2170, /**/ diff --git a/src/vim.h b/src/vim.h index 5a977a8afe..d361f8a766 100644 --- a/src/vim.h +++ b/src/vim.h @@ -151,9 +151,6 @@ # if defined(FEAT_SMALL) && !defined(FEAT_CLIPBOARD) # define FEAT_CLIPBOARD # endif -# if defined(FEAT_SMALL) && !defined(FEAT_MOUSE) -# define FEAT_MOUSE -# endif #endif // +x11 is only enabled when it's both available and wanted. @@ -1817,80 +1814,78 @@ typedef int sock_T; #define PROF_YES 1 // profiling busy #define PROF_PAUSED 2 // profiling paused -#ifdef FEAT_MOUSE // Codes for mouse button events in lower three bits: -# define MOUSE_LEFT 0x00 -# define MOUSE_MIDDLE 0x01 -# define MOUSE_RIGHT 0x02 -# define MOUSE_RELEASE 0x03 +#define MOUSE_LEFT 0x00 +#define MOUSE_MIDDLE 0x01 +#define MOUSE_RIGHT 0x02 +#define MOUSE_RELEASE 0x03 // bit masks for modifiers: -# define MOUSE_SHIFT 0x04 -# define MOUSE_ALT 0x08 -# define MOUSE_CTRL 0x10 +#define MOUSE_SHIFT 0x04 +#define MOUSE_ALT 0x08 +#define MOUSE_CTRL 0x10 // mouse buttons that are handled like a key press (GUI only) // Note that the scroll wheel keys are inverted: MOUSE_5 scrolls lines up but // the result of this is that the window moves down, similarly MOUSE_6 scrolls // columns left but the window moves right. -# define MOUSE_4 0x100 // scroll wheel down -# define MOUSE_5 0x200 // scroll wheel up +#define MOUSE_4 0x100 // scroll wheel down +#define MOUSE_5 0x200 // scroll wheel up -# define MOUSE_X1 0x300 // Mouse-button X1 (6th) -# define MOUSE_X2 0x400 // Mouse-button X2 +#define MOUSE_X1 0x300 // Mouse-button X1 (6th) +#define MOUSE_X2 0x400 // Mouse-button X2 -# define MOUSE_6 0x500 // scroll wheel left -# define MOUSE_7 0x600 // scroll wheel right +#define MOUSE_6 0x500 // scroll wheel left +#define MOUSE_7 0x600 // scroll wheel right // 0x20 is reserved by xterm -# define MOUSE_DRAG_XTERM 0x40 +#define MOUSE_DRAG_XTERM 0x40 -# define MOUSE_DRAG (0x40 | MOUSE_RELEASE) +#define MOUSE_DRAG (0x40 | MOUSE_RELEASE) // Lowest button code for using the mouse wheel (xterm only) -# define MOUSEWHEEL_LOW 0x60 +#define MOUSEWHEEL_LOW 0x60 -# define MOUSE_CLICK_MASK 0x03 +#define MOUSE_CLICK_MASK 0x03 -# define NUM_MOUSE_CLICKS(code) \ +#define NUM_MOUSE_CLICKS(code) \ (((unsigned)((code) & 0xC0) >> 6) + 1) -# define SET_NUM_MOUSE_CLICKS(code, num) \ +#define SET_NUM_MOUSE_CLICKS(code, num) \ (code) = ((code) & 0x3f) | ((((num) - 1) & 3) << 6) // Added to mouse column for GUI when 'mousefocus' wants to give focus to a // window by simulating a click on its status line. We could use up to 128 * // 128 = 16384 columns, now it's reduced to 10000. -# define MOUSE_COLOFF 10000 +#define MOUSE_COLOFF 10000 /* * jump_to_mouse() returns one of first four these values, possibly with * some of the other three added. */ -# define IN_UNKNOWN 0 -# define IN_BUFFER 1 -# define IN_STATUS_LINE 2 // on status or command line -# define IN_SEP_LINE 4 // on vertical separator line -# define IN_OTHER_WIN 8 // in other window but can't go there -# define CURSOR_MOVED 0x100 -# define MOUSE_FOLD_CLOSE 0x200 // clicked on '-' in fold column -# define MOUSE_FOLD_OPEN 0x400 // clicked on '+' in fold column -# define MOUSE_WINBAR 0x800 // in window toolbar +#define IN_UNKNOWN 0 +#define IN_BUFFER 1 +#define IN_STATUS_LINE 2 // on status or command line +#define IN_SEP_LINE 4 // on vertical separator line +#define IN_OTHER_WIN 8 // in other window but can't go there +#define CURSOR_MOVED 0x100 +#define MOUSE_FOLD_CLOSE 0x200 // clicked on '-' in fold column +#define MOUSE_FOLD_OPEN 0x400 // clicked on '+' in fold column +#define MOUSE_WINBAR 0x800 // in window toolbar // flags for jump_to_mouse() -# define MOUSE_FOCUS 0x01 // need to stay in this window -# define MOUSE_MAY_VIS 0x02 // may start Visual mode -# define MOUSE_DID_MOVE 0x04 // only act when mouse has moved -# define MOUSE_SETPOS 0x08 // only set current mouse position -# define MOUSE_MAY_STOP_VIS 0x10 // may stop Visual mode -# define MOUSE_RELEASED 0x20 // button was released +#define MOUSE_FOCUS 0x01 // need to stay in this window +#define MOUSE_MAY_VIS 0x02 // may start Visual mode +#define MOUSE_DID_MOVE 0x04 // only act when mouse has moved +#define MOUSE_SETPOS 0x08 // only set current mouse position +#define MOUSE_MAY_STOP_VIS 0x10 // may stop Visual mode +#define MOUSE_RELEASED 0x20 // button was released -# if defined(UNIX) && defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) -# define CHECK_DOUBLE_CLICK 1 // Checking for double clicks ourselves. -# endif +#if defined(UNIX) && defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) +# define CHECK_DOUBLE_CLICK 1 // Checking for double clicks ourselves. +#endif -#endif // FEAT_MOUSE // defines for eval_vars() #define VALID_PATH 1 diff --git a/src/window.c b/src/window.c index fb8a5a7ede..8bb3269a0f 100644 --- a/src/window.c +++ b/src/window.c @@ -5725,8 +5725,6 @@ win_setminwidth(void) } } -#if defined(FEAT_MOUSE) || defined(PROTO) - /* * Status line of dragwin is dragged "offset" lines down (negative is up). */ @@ -5958,7 +5956,6 @@ win_drag_vsep_line(win_T *dragwin, int offset) (void)win_comp_pos(); redraw_all_later(NOT_VALID); } -#endif /* FEAT_MOUSE */ #define FRACTION_MULT 16384L From 7751d1d1a3d447d0d48f57f34e0da9f7c6ac433d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 18 Oct 2019 20:37:08 +0200 Subject: [PATCH 04/30] patch 8.1.2172: spell highlight is wrong at start of the line Problem: Spell highlight is wrong at start of the line. Solution: Fix setting the "v" variable. (closes #5078) --- src/drawline.c | 4 +++- src/testdir/dumps/Test_spell_1.dump | 8 ++++++++ src/testdir/test_spell.vim | 25 +++++++++++++++++++++++++ src/version.c | 2 ++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/testdir/dumps/Test_spell_1.dump diff --git a/src/drawline.c b/src/drawline.c index 9a4ff7dc5d..333eeba297 100644 --- a/src/drawline.c +++ b/src/drawline.c @@ -1824,6 +1824,7 @@ win_line( // Only do this when there is no syntax highlighting, the // @Spell cluster is not used or the current syntax item // contains the @Spell cluster. + v = (long)(ptr - line); if (has_spell && v >= word_end && v > cur_checked_col) { spell_attr = 0; @@ -1874,7 +1875,8 @@ win_line( // Remember that the good word continues at the // start of the next line. checked_lnum = lnum + 1; - checked_col = (int)((p - nextline) + len - nextline_idx); + checked_col = (int)((p - nextline) + + len - nextline_idx); } // Turn index into actual attributes. diff --git a/src/testdir/dumps/Test_spell_1.dump b/src/testdir/dumps/Test_spell_1.dump new file mode 100644 index 0000000000..2025be18e7 --- /dev/null +++ b/src/testdir/dumps/Test_spell_1.dump @@ -0,0 +1,8 @@ +>T+0&#ffffff0|h|i|s| |i|s| |s|o|m|e| |t|e|x|t| |w|i|t|h|o|u|t| |a|n|y| |s|p|e|l@1| |e|r@1|o|r|s|.| @1|E|v|e|r|y|t|h|i|n|g| @19 +|s|h|o|u|l|d| |j|u|s|t| |b|e| |b|l|a|c|k|,| |n|o|t|h|i|n|g| |w|r|o|n|g| |h|e|r|e|.| @33 +@75 +|T|h|i|s| |l|i|n|e| |h|a|s| |a| |s+0&#ffd7d7255|e|p|l@1| +0&#ffffff0|e|r@1|o|r|.| |a+0fd7ff255|n|d| +0&#ffffff0|m|i|s@1|i|n|g| |c|a|p|s|.| @28 +|A+0&#ffd7d7255|n|d| |a|n|d| +0&#ffffff0|t|h|i|s| |i|s| |t+0&#ffd7d7255|h|e| |t|h|e| +0&#ffffff0|d|u|p|l|i|c|a|t|i|o|n|.| @38 +|w+0fd7ff255|i|t|h| +0&#ffffff0|m|i|s@1|i|n|g| |c|a|p|s| |h|e|r|e|.| @51 +|~+0#4040ff13&| @73 +| +0#0000000&@56|1|,|1| @10|A|l@1| diff --git a/src/testdir/test_spell.vim b/src/testdir/test_spell.vim index 9cbfaa50e8..146e421d03 100644 --- a/src/testdir/test_spell.vim +++ b/src/testdir/test_spell.vim @@ -4,6 +4,8 @@ source check.vim CheckFeature spell +source screendump.vim + func TearDown() set nospell call delete('Xtest.aff') @@ -460,6 +462,29 @@ func RunGoodBad(good, bad, expected_words, expected_bad_words) bwipe! endfunc +func Test_spell_screendump() + CheckScreendump + + let lines =<< trim END + call setline(1, [ + \ "This is some text without any spell errors. Everything", + \ "should just be black, nothing wrong here.", + \ "", + \ "This line has a sepll error. and missing caps.", + \ "And and this is the the duplication.", + \ "with missing caps here.", + \ ]) + set spell spelllang=en_nz + END + call writefile(lines, 'XtestSpell') + let buf = RunVimInTerminal('-S XtestSpell', {'rows': 8}) + call VerifyScreenDump(buf, 'Test_spell_1', {}) + + " clean up + call StopVimInTerminal(buf) + call delete('XtestSpell') +endfunc + let g:test_data_aff1 = [ \"SET ISO8859-1", \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ", diff --git a/src/version.c b/src/version.c index 0dd36774db..901bf32ccf 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2172, /**/ 2171, /**/ From 92ea26b925a0835badb0af2d5887238a4198cabb Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 18 Oct 2019 20:53:34 +0200 Subject: [PATCH 05/30] patch 8.1.2173: searchit() has too many arguments Problem: Searchit() has too many arguments. Solution: Move optional arguments to a struct. Add the "wrapped" argument. --- src/evalfunc.c | 21 ++++++++++++++++++--- src/ex_docmd.c | 5 ++--- src/ex_getln.c | 12 ++++++++---- src/gui.c | 4 ++-- src/insexpand.c | 2 +- src/normal.c | 26 ++++++++++++++++---------- src/proto/search.pro | 6 +++--- src/quickfix.c | 3 +-- src/search.c | 40 ++++++++++++++++++++++++++-------------- src/spell.c | 2 +- src/structs.h | 13 +++++++++++++ src/tag.c | 8 ++++---- src/version.c | 2 ++ 13 files changed, 97 insertions(+), 47 deletions(-) diff --git a/src/evalfunc.c b/src/evalfunc.c index c43c8839bd..62a7f06070 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -5694,12 +5694,13 @@ search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp) int dir; int retval = 0; /* default: FAIL */ long lnum_stop = 0; - proftime_T tm; #ifdef FEAT_RELTIME + proftime_T tm; long time_limit = 0; #endif int options = SEARCH_KEEP; int subpatnum; + searchit_arg_T sia; pat = tv_get_string(&argvars[0]); dir = get_search_arg(&argvars[1], flagsp); /* may set p_ws */ @@ -5748,8 +5749,13 @@ search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp) } pos = save_cursor = curwin->w_cursor; + vim_memset(&sia, 0, sizeof(sia)); + sia.sa_stop_lnum = (linenr_T)lnum_stop; +#ifdef FEAT_RELTIME + sia.sa_tm = &tm; +#endif subpatnum = searchit(curwin, curbuf, &pos, NULL, dir, pat, 1L, - options, RE_SEARCH, (linenr_T)lnum_stop, &tm, NULL); + options, RE_SEARCH, &sia); if (subpatnum != FAIL) { if (flags & SP_SUBPAT) @@ -6147,7 +6153,9 @@ do_searchpair( int use_skip = FALSE; int err; int options = SEARCH_KEEP; +#ifdef FEAT_RELTIME proftime_T tm; +#endif /* Make 'cpoptions' empty, the 'l' flag should not be used here. */ save_cpo = p_cpo; @@ -6188,8 +6196,15 @@ do_searchpair( pat = pat3; for (;;) { + searchit_arg_T sia; + + vim_memset(&sia, 0, sizeof(sia)); + sia.sa_stop_lnum = lnum_stop; +#ifdef FEAT_RELTIME + sia.sa_tm = &tm; +#endif n = searchit(curwin, curbuf, &pos, NULL, dir, pat, 1L, - options, RE_SEARCH, lnum_stop, &tm, NULL); + options, RE_SEARCH, &sia); if (n == FAIL || (firstpos.lnum != 0 && EQUAL_POS(pos, firstpos))) /* didn't find it or found the first match again: FAIL */ break; diff --git a/src/ex_docmd.c b/src/ex_docmd.c index f4c327140d..4dd7ba23d8 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -3600,7 +3600,7 @@ get_address( curwin->w_cursor.col = 0; searchcmdlen = 0; flags = silent ? 0 : SEARCH_HIS | SEARCH_MSG; - if (!do_search(NULL, c, cmd, 1L, flags, NULL, NULL)) + if (!do_search(NULL, c, cmd, 1L, flags, NULL)) { curwin->w_cursor = pos; cmd = NULL; @@ -3654,8 +3654,7 @@ get_address( pos.coladd = 0; if (searchit(curwin, curbuf, &pos, NULL, *cmd == '?' ? BACKWARD : FORWARD, - (char_u *)"", 1L, SEARCH_MSG, - i, (linenr_T)0, NULL, NULL) != FAIL) + (char_u *)"", 1L, SEARCH_MSG, i, NULL) != FAIL) lnum = pos.lnum; else { diff --git a/src/ex_getln.c b/src/ex_getln.c index 5816f3f9e7..45a0a36321 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -373,6 +373,7 @@ may_do_incsearch_highlighting( pos_T end_pos; #ifdef FEAT_RELTIME proftime_T tm; + searchit_arg_T sia; #endif int next_char; int use_last_pat; @@ -445,12 +446,16 @@ may_do_incsearch_highlighting( if (search_first_line != 0) search_flags += SEARCH_START; ccline.cmdbuff[skiplen + patlen] = NUL; +#ifdef FEAT_RELTIME + vim_memset(&sia, 0, sizeof(sia)); + sia.sa_tm = &tm; +#endif found = do_search(NULL, firstc == ':' ? '/' : firstc, ccline.cmdbuff + skiplen, count, search_flags, #ifdef FEAT_RELTIME - &tm, NULL + &sia #else - NULL, NULL + NULL #endif ); ccline.cmdbuff[skiplen + patlen] = next_char; @@ -597,8 +602,7 @@ may_adjust_incsearch_highlighting( pat[patlen] = NUL; i = searchit(curwin, curbuf, &t, NULL, c == Ctrl_G ? FORWARD : BACKWARD, - pat, count, search_flags, - RE_SEARCH, 0, NULL, NULL); + pat, count, search_flags, RE_SEARCH, NULL); --emsg_off; pat[patlen] = save; if (i) diff --git a/src/gui.c b/src/gui.c index 860add2b43..31be46c7f2 100644 --- a/src/gui.c +++ b/src/gui.c @@ -5383,7 +5383,7 @@ gui_do_findrepl( i = msg_scroll; if (down) { - (void)do_search(NULL, '/', ga.ga_data, 1L, searchflags, NULL, NULL); + (void)do_search(NULL, '/', ga.ga_data, 1L, searchflags, NULL); } else { @@ -5391,7 +5391,7 @@ gui_do_findrepl( * direction */ p = vim_strsave_escaped(ga.ga_data, (char_u *)"?"); if (p != NULL) - (void)do_search(NULL, '?', p, 1L, searchflags, NULL, NULL); + (void)do_search(NULL, '?', p, 1L, searchflags, NULL); vim_free(p); } diff --git a/src/insexpand.c b/src/insexpand.c index 644542e94f..31b952bf59 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -2881,7 +2881,7 @@ ins_compl_get_exp(pos_T *ini) found_new_match = searchit(NULL, ins_buf, pos, NULL, compl_direction, compl_pattern, 1L, SEARCH_KEEP + SEARCH_NFMSG, - RE_LAST, (linenr_T)0, NULL, NULL); + RE_LAST, NULL); --msg_silent; if (!compl_started || set_match_pos) { diff --git a/src/normal.c b/src/normal.c index 87754eb40e..f66a97c34b 100644 --- a/src/normal.c +++ b/src/normal.c @@ -65,7 +65,7 @@ static void nv_end(cmdarg_T *cap); static void nv_dollar(cmdarg_T *cap); static void nv_search(cmdarg_T *cap); static void nv_next(cmdarg_T *cap); -static int normal_search(cmdarg_T *cap, int dir, char_u *pat, int opt); +static int normal_search(cmdarg_T *cap, int dir, char_u *pat, int opt, int *wrapped); static void nv_csearch(cmdarg_T *cap); static void nv_brackets(cmdarg_T *cap); static void nv_percent(cmdarg_T *cap); @@ -2346,7 +2346,7 @@ find_decl( for (;;) { t = searchit(curwin, curbuf, &curwin->w_cursor, NULL, FORWARD, - pat, 1L, searchflags, RE_LAST, (linenr_T)0, NULL, NULL); + pat, 1L, searchflags, RE_LAST, NULL); if (curwin->w_cursor.lnum >= old_pos.lnum) t = FAIL; /* match after start is failure too */ @@ -3730,7 +3730,7 @@ nv_ident(cmdarg_T *cap) init_history(); add_to_history(HIST_SEARCH, buf, TRUE, NUL); - (void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0); + (void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL); } else { @@ -4257,7 +4257,7 @@ nv_search(cmdarg_T *cap) (void)normal_search(cap, cap->cmdchar, cap->searchbuf, (cap->arg || !EQUAL_POS(save_cursor, curwin->w_cursor)) - ? 0 : SEARCH_MARK); + ? 0 : SEARCH_MARK, NULL); } /* @@ -4267,16 +4267,17 @@ nv_search(cmdarg_T *cap) static void nv_next(cmdarg_T *cap) { - pos_T old = curwin->w_cursor; - int i = normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg); + pos_T old = curwin->w_cursor; + int wrapped = FALSE; + int i = normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, &wrapped); - if (i == 1 && EQUAL_POS(old, curwin->w_cursor)) + if (i == 1 && !wrapped && EQUAL_POS(old, curwin->w_cursor)) { /* Avoid getting stuck on the current cursor position, which can * happen when an offset is given and the cursor is on the last char * in the buffer: Repeat with count + 1. */ cap->count1 += 1; - (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg); + (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, NULL); cap->count1 -= 1; } } @@ -4291,17 +4292,22 @@ normal_search( cmdarg_T *cap, int dir, char_u *pat, - int opt) /* extra flags for do_search() */ + int opt, // extra flags for do_search() + int *wrapped) { int i; + searchit_arg_T sia; cap->oap->motion_type = MCHAR; cap->oap->inclusive = FALSE; cap->oap->use_reg_one = TRUE; curwin->w_set_curswant = TRUE; + vim_memset(&sia, 0, sizeof(sia)); i = do_search(cap->oap, dir, pat, cap->count1, - opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, NULL, NULL); + opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, &sia); + if (wrapped != NULL) + *wrapped = sia.sa_wrapped; if (i == 0) clearop(cap->oap); else diff --git a/src/proto/search.pro b/src/proto/search.pro index 143333d467..e6ac11b2cb 100644 --- a/src/proto/search.pro +++ b/src/proto/search.pro @@ -22,9 +22,9 @@ char_u *last_search_pat(void); void reset_search_dir(void); void set_last_search_pat(char_u *s, int idx, int magic, int setlast); void last_pat_prog(regmmatch_T *regmatch); -int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, int dir, char_u *pat, long count, int options, int pat_use, linenr_T stop_lnum, proftime_T *tm, int *timed_out); +int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, int dir, char_u *pat, long count, int options, int pat_use, searchit_arg_T *extra_arg); void set_search_direction(int cdir); -int do_search(oparg_T *oap, int dirc, char_u *pat, long count, int options, proftime_T *tm, int *timed_out); +int do_search(oparg_T *oap, int dirc, char_u *pat, long count, int options, searchit_arg_T *sia); int search_for_exact_line(buf_T *buf, pos_T *pos, int dir, char_u *pat); int searchc(cmdarg_T *cap, int t_cmd); pos_T *findmatch(oparg_T *oap, int initc); @@ -46,6 +46,6 @@ int current_quote(oparg_T *oap, long count, int include, int quotechar); int current_search(long count, int forward); int linewhite(linenr_T lnum); void find_pattern_in_path(char_u *ptr, int dir, int len, int whole, int skip_comments, int type, long count, int action, linenr_T start_lnum, linenr_T end_lnum); -struct spat *get_spat(int idx); +spat_T *get_spat(int idx); int get_spat_last_idx(void); /* vim: set ft=c : */ diff --git a/src/quickfix.c b/src/quickfix.c index 36456ed4ff..067dbffd08 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -3207,8 +3207,7 @@ qf_jump_goto_line( // Move the cursor to the first line in the buffer save_cursor = curwin->w_cursor; curwin->w_cursor.lnum = 0; - if (!do_search(NULL, '/', qf_pattern, (long)1, - SEARCH_KEEP, NULL, NULL)) + if (!do_search(NULL, '/', qf_pattern, (long)1, SEARCH_KEEP, NULL)) curwin->w_cursor = save_cursor; } } diff --git a/src/search.c b/src/search.c index 77c3aa4922..91f53c606d 100644 --- a/src/search.c +++ b/src/search.c @@ -595,8 +595,8 @@ last_pat_prog(regmmatch_T *regmatch) */ int searchit( - win_T *win, /* window to search in; can be NULL for a - buffer without a window! */ + win_T *win, // window to search in; can be NULL for a + // buffer without a window! buf_T *buf, pos_T *pos, pos_T *end_pos, // set to end of the match, unless NULL @@ -604,10 +604,8 @@ searchit( char_u *pat, long count, int options, - int pat_use, /* which pattern to use when "pat" is empty */ - linenr_T stop_lnum, /* stop after this line number when != 0 */ - proftime_T *tm UNUSED, /* timeout limit or NULL */ - int *timed_out UNUSED) /* set when timed out or NULL */ + int pat_use, // which pattern to use when "pat" is empty + searchit_arg_T *extra_arg) // optional extra arguments, can be NULL { int found; linenr_T lnum; /* no init to shut up Apollo cc */ @@ -630,6 +628,20 @@ searchit( #ifdef FEAT_SEARCH_EXTRA int break_loop = FALSE; #endif + linenr_T stop_lnum = 0; // stop after this line number when != 0 +#ifdef FEAT_RELTIME + proftime_T *tm = NULL; // timeout limit or NULL + int *timed_out = NULL; // set when timed out or NULL +#endif + + if (extra_arg != NULL) + { + stop_lnum = extra_arg->sa_stop_lnum; +#ifdef FEAT_RELTIME + tm = extra_arg->sa_tm; + timed_out = &extra_arg->sa_timed_out; +#endif + } if (search_regcomp(pat, RE_SEARCH, pat_use, (options & (SEARCH_HIS + SEARCH_KEEP)), ®match) == FAIL) @@ -1067,6 +1079,8 @@ searchit( if (!shortmess(SHM_SEARCH) && (options & SEARCH_MSG)) give_warning((char_u *)_(dir == BACKWARD ? top_bot_msg : bot_top_msg), TRUE); + if (extra_arg != NULL) + extra_arg->sa_wrapped = TRUE; } if (got_int || called_emsg #ifdef FEAT_RELTIME @@ -1178,8 +1192,7 @@ do_search( char_u *pat, long count, int options, - proftime_T *tm, /* timeout limit or NULL */ - int *timed_out) /* flag set on timeout or NULL */ + searchit_arg_T *sia) // optional arguments or NULL { pos_T pos; /* position of the last match */ char_u *searchstr; @@ -1269,7 +1282,7 @@ do_search( */ for (;;) { - int show_top_bot_msg = FALSE; + int show_top_bot_msg = FALSE; searchstr = pat; dircp = NULL; @@ -1511,7 +1524,7 @@ do_search( (SEARCH_KEEP + SEARCH_PEEK + SEARCH_HIS + SEARCH_MSG + SEARCH_START + ((pat != NULL && *pat == ';') ? 0 : SEARCH_NOOF))), - RE_LAST, (linenr_T)0, tm, timed_out); + RE_LAST, sia); if (dircp != NULL) *dircp = dirc; // restore second '/' or '?' for normal_cmd() @@ -4741,7 +4754,7 @@ current_search( result = searchit(curwin, curbuf, &pos, &end_pos, (dir ? FORWARD : BACKWARD), spats[last_idx].pat, (long) (i ? count : 1), - SEARCH_KEEP | flags, RE_SEARCH, 0, NULL, NULL); + SEARCH_KEEP | flags, RE_SEARCH, NULL); /* First search may fail, but then start searching from the * beginning of the file (cursor might be on the search match) @@ -4854,7 +4867,7 @@ is_one_char(char_u *pattern, int move, pos_T *cur, int direction) } if (searchit(curwin, curbuf, &pos, NULL, direction, pattern, 1, - SEARCH_KEEP + flag, RE_SEARCH, 0, NULL, NULL) != FAIL) + SEARCH_KEEP + flag, RE_SEARCH, NULL) != FAIL) { /* Zero-width pattern should match somewhere, then we can check if * start and end are in the same position. */ @@ -4954,8 +4967,7 @@ search_stat( profile_setlimit(20L, &start); #endif while (!got_int && searchit(curwin, curbuf, &lastpos, NULL, - FORWARD, NULL, 1, SEARCH_KEEP, RE_LAST, - (linenr_T)0, NULL, NULL) != FAIL) + FORWARD, NULL, 1, SEARCH_KEEP, RE_LAST, NULL) != FAIL) { #ifdef FEAT_RELTIME // Stop after passing the time limit. diff --git a/src/spell.c b/src/spell.c index 04e4af601f..46209077c6 100644 --- a/src/spell.c +++ b/src/spell.c @@ -2861,7 +2861,7 @@ ex_spellrepall(exarg_T *eap UNUSED) curwin->w_cursor.lnum = 0; while (!got_int) { - if (do_search(NULL, '/', frompat, 1L, SEARCH_KEEP, NULL, NULL) == 0 + if (do_search(NULL, '/', frompat, 1L, SEARCH_KEEP, NULL) == 0 || u_save_cursor() == FAIL) break; diff --git a/src/structs.h b/src/structs.h index 7c0bfce8fd..9cc2452528 100644 --- a/src/structs.h +++ b/src/structs.h @@ -3871,6 +3871,19 @@ typedef struct spat soffset_T off; } spat_T; +/* + * Optional extra arguments for searchit(). + */ +typedef struct +{ + linenr_T sa_stop_lnum; // stop after this line number when != 0 +#ifdef FEAT_RELTIME + proftime_T *sa_tm; // timeout limit or NULL + int sa_timed_out; // set when timed out +#endif + int sa_wrapped; // search wrapped around +} searchit_arg_T; + #define WRITEBUFSIZE 8192 // size of normal write buffer #define FIO_LATIN1 0x01 // convert Latin1 diff --git a/src/tag.c b/src/tag.c index 75ff026c55..136fea5204 100644 --- a/src/tag.c +++ b/src/tag.c @@ -3542,7 +3542,7 @@ jumpto_tag( save_lnum = curwin->w_cursor.lnum; curwin->w_cursor.lnum = 0; /* start search before first line */ if (do_search(NULL, pbuf[0], pbuf + 1, (long)1, - search_options, NULL, NULL)) + search_options, NULL)) retval = OK; else { @@ -3554,7 +3554,7 @@ jumpto_tag( */ p_ic = TRUE; if (!do_search(NULL, pbuf[0], pbuf + 1, (long)1, - search_options, NULL, NULL)) + search_options, NULL)) { /* * Failed to find pattern, take a guess: "^func (" @@ -3565,13 +3565,13 @@ jumpto_tag( *tagp.tagname_end = NUL; sprintf((char *)pbuf, "^%s\\s\\*(", tagp.tagname); if (!do_search(NULL, '/', pbuf, (long)1, - search_options, NULL, NULL)) + search_options, NULL)) { /* Guess again: "^char * \ Date: Fri, 18 Oct 2019 21:26:05 +0200 Subject: [PATCH 06/30] patch 8.1.2174: screen not recognized as supporting "sgr" mouse codes Problem: Screen not recognized as supporting "sgr" mouse codes. Solution: Recognize screen 4.7. (Jordan Christiansen, closes #5042) --- src/term.c | 16 ++++-- src/testdir/test_termcodes.vim | 94 ++++++++++++++++++++++++++++++++-- src/version.c | 2 + 3 files changed, 104 insertions(+), 8 deletions(-) diff --git a/src/term.c b/src/term.c index cfbd7fe597..fa4375e4e8 100644 --- a/src/term.c +++ b/src/term.c @@ -4649,8 +4649,8 @@ not_enough: if (tp[0] == CSI) switch_to_8bit(); - // rxvt sends its version number: "20703" is 2.7.3. // Screen sends 40500. + // rxvt sends its version number: "20703" is 2.7.3. // Ignore it for when the user has set 'term' to xterm, // even though it's an rxvt. if (version > 20000) @@ -4661,6 +4661,7 @@ not_enough: int need_flush = FALSE; int is_iterm2 = FALSE; int is_mintty = FALSE; + int is_screen = FALSE; // mintty 2.9.5 sends 77;20905;0c. // (77 is ASCII 'M' for mintty.) @@ -4706,14 +4707,21 @@ not_enough: is_not_xterm = TRUE; } + // screen sends 83;40500;0 83 is 'S' in ASCII. + if (arg[0] == 83) + is_screen = TRUE; + // Only set 'ttymouse' automatically if it was not set // by the user already. if (!option_was_set((char_u *)"ttym")) { // Xterm version 277 supports SGR. Also support - // Terminal.app, iTerm2 and mintty. - if (version >= 277 || is_iterm2 || is_mac_terminal - || is_mintty) + // Terminal.app, iTerm2, mintty, and screen 4.7+. + if ((!is_screen && version >= 277) + || is_iterm2 + || is_mac_terminal + || is_mintty + || (is_screen && arg[1] >= 40700)) set_option_value((char_u *)"ttym", 0L, (char_u *)"sgr", 0); // if xterm version >= 95 use mouse dragging diff --git a/src/testdir/test_termcodes.vim b/src/testdir/test_termcodes.vim index ae20280fe3..c4d9cb004e 100644 --- a/src/testdir/test_termcodes.vim +++ b/src/testdir/test_termcodes.vim @@ -882,10 +882,35 @@ func Test_xx01_term_style_response() set t_RV= endfunc +" This checks the iTerm2 version response. +" This must be after other tests, because it has side effects to xterm +" properties. +func Test_xx02_iTerm2_response() + " Termresponse is only parsed when t_RV is not empty. + set t_RV=x + + " Old versions of iTerm2 used a different style term response. + set ttymouse=xterm + call test_option_not_set('ttymouse') + let seq = "\[>0;95;c" + call feedkeys(seq, 'Lx!') + call assert_equal(seq, v:termresponse) + call assert_equal('xterm', &ttymouse) + + set ttymouse=xterm + call test_option_not_set('ttymouse') + let seq = "\[>0;95;0c" + call feedkeys(seq, 'Lx!') + call assert_equal(seq, v:termresponse) + call assert_equal('sgr', &ttymouse) + + set t_RV= +endfunc + " This checks the libvterm version response. " This must be after other tests, because it has side effects to xterm " properties. -func Test_xx02_libvterm_response() +func Test_xx03_libvterm_response() " Termresponse is only parsed when t_RV is not empty. set t_RV=x @@ -899,10 +924,73 @@ func Test_xx02_libvterm_response() set t_RV= endfunc +" This checks the Mac Terminal.app version response. +" This must be after other tests, because it has side effects to xterm +" properties. +func Test_xx04_Mac_Terminal_response() + " Termresponse is only parsed when t_RV is not empty. + set t_RV=x + + set ttymouse=xterm + call test_option_not_set('ttymouse') + let seq = "\[>1;95;0c" + call feedkeys(seq, 'Lx!') + call assert_equal(seq, v:termresponse) + call assert_equal('sgr', &ttymouse) + + " Reset is_not_xterm and is_mac_terminal. + set t_RV= + set term=xterm + set t_RV=x +endfunc + +" This checks the mintty version response. +" This must be after other tests, because it has side effects to xterm +" properties. +func Test_xx05_mintty_response() + " Termresponse is only parsed when t_RV is not empty. + set t_RV=x + + set ttymouse=xterm + call test_option_not_set('ttymouse') + let seq = "\[>77;20905;0c" + call feedkeys(seq, 'Lx!') + call assert_equal(seq, v:termresponse) + call assert_equal('sgr', &ttymouse) + + set t_RV= +endfunc + +" This checks the screen version response. +" This must be after other tests, because it has side effects to xterm +" properties. +func Test_xx06_screen_response() + " Termresponse is only parsed when t_RV is not empty. + set t_RV=x + + " Old versions of screen don't support SGR mouse mode. + set ttymouse=xterm + call test_option_not_set('ttymouse') + let seq = "\[>83;40500;0c" + call feedkeys(seq, 'Lx!') + call assert_equal(seq, v:termresponse) + call assert_equal('xterm', &ttymouse) + + " screen supports SGR mouse mode starting in version 4.7. + set ttymouse=xterm + call test_option_not_set('ttymouse') + let seq = "\[>83;40700;0c" + call feedkeys(seq, 'Lx!') + call assert_equal(seq, v:termresponse) + call assert_equal('sgr', &ttymouse) + + set t_RV= +endfunc + " This checks the xterm version response. " This must be after other tests, because it has side effects to xterm " properties. -func Test_xx03_xterm_response() +func Test_xx07_xterm_response() " Termresponse is only parsed when t_RV is not empty. set t_RV=x @@ -944,8 +1032,6 @@ func Test_xx03_xterm_response() set t_RV= endfunc -" TODO: check other terminals response - func Test_get_termcode() try let k1 = &t_k1 diff --git a/src/version.c b/src/version.c index 73e7e532d1..e2e213e9f3 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2174, /**/ 2173, /**/ From c3bf7b56f2703e2d6f36dfb05fd32b5b43ce3c3f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 18 Oct 2019 22:09:34 +0200 Subject: [PATCH 07/30] patch 8.1.2175: meson files are not recognized Problem: Meson files are not recognized. Solution: Add the meson filetype. (Liam Beguin , Nirbheek Chauhan, closes #5056) Also recognize hollywood. --- runtime/filetype.vim | 3 +++ src/testdir/test_filetype.vim | 2 ++ src/version.c | 2 ++ 3 files changed, 7 insertions(+) diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 9af37ad2a8..a27dc41953 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -979,6 +979,9 @@ au BufNewFile,BufRead hg-editor-*.txt setf hgcommit " Mercurial config (looks like generic config file) au BufNewFile,BufRead *.hgrc,*hgrc setf cfg +" Meson Build system config +au BufNewFile,BufRead meson.build,meson_options.txt setf meson + " Messages (logs mostly) au BufNewFile,BufRead */log/{auth,cron,daemon,debug,kern,lpr,mail,messages,news/news,syslog,user}{,.log,.err,.info,.warn,.crit,.notice}{,.[0-9]*,-[0-9]*} setf messages diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim index 19fd19a9ac..736dc79ebf 100644 --- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -201,6 +201,7 @@ let s:filename_checks = { \ 'hex': ['file.hex', 'file.h32'], \ 'hgcommit': ['hg-editor-file.txt'], \ 'hog': ['file.hog', 'snort.conf', 'vision.conf'], + \ 'hollywood': ['file.hws'], \ 'hostconf': ['/etc/host.conf'], \ 'hostsaccess': ['/etc/hosts.allow', '/etc/hosts.deny'], \ 'template': ['file.tmpl'], @@ -274,6 +275,7 @@ let s:filename_checks = { \ 'mason': ['file.mason', 'file.mhtml', 'file.comp'], \ 'master': ['file.mas', 'file.master'], \ 'mel': ['file.mel'], + \ 'meson': ['meson.build', 'meson_options.txt'], \ 'messages': ['/log/auth', '/log/cron', '/log/daemon', '/log/debug', '/log/kern', '/log/lpr', '/log/mail', '/log/messages', '/log/news/news', '/log/syslog', '/log/user', \ '/log/auth.log', '/log/cron.log', '/log/daemon.log', '/log/debug.log', '/log/kern.log', '/log/lpr.log', '/log/mail.log', '/log/messages.log', '/log/news/news.log', '/log/syslog.log', '/log/user.log', \ '/log/auth.err', '/log/cron.err', '/log/daemon.err', '/log/debug.err', '/log/kern.err', '/log/lpr.err', '/log/mail.err', '/log/messages.err', '/log/news/news.err', '/log/syslog.err', '/log/user.err', diff --git a/src/version.c b/src/version.c index e2e213e9f3..e371d68dbf 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2175, /**/ 2174, /**/ From 8459006af5e78bd0bd6dcfc6d54ddac35a91ee1c Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 18 Oct 2019 23:12:20 +0200 Subject: [PATCH 08/30] patch 8.1.2176: syntax attributes not combined with Visual highlighting Problem: Syntax attributes not combined with Visual highlighting. (Arseny Nasokin) Solution: Combine the attributes. (closes #5083) --- src/drawline.c | 12 ++++++++++++ src/testdir/dumps/Test_syntax_c_01.dump | 10 +++++----- src/testdir/test_syntax.vim | 7 ++++++- src/version.c | 2 ++ 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/drawline.c b/src/drawline.c index 333eeba297..ef3b69f8c2 100644 --- a/src/drawline.c +++ b/src/drawline.c @@ -1470,9 +1470,21 @@ win_line( attr_pri = TRUE; #ifdef LINE_ATTR if (area_attr != 0) + { char_attr = hl_combine_attr(line_attr, area_attr); +# ifdef FEAT_SYN_HL + if (syntax_attr != 0) + char_attr = hl_combine_attr(syntax_attr, char_attr); +# endif + } else if (search_attr != 0) + { char_attr = hl_combine_attr(line_attr, search_attr); +# ifdef FEAT_SYN_HL + if (syntax_attr != 0) + char_attr = hl_combine_attr(syntax_attr, char_attr); +# endif + } # ifdef FEAT_TEXT_PROP else if (text_prop_type != NULL) { diff --git a/src/testdir/dumps/Test_syntax_c_01.dump b/src/testdir/dumps/Test_syntax_c_01.dump index 54e34a6035..d70f45ac61 100644 --- a/src/testdir/dumps/Test_syntax_c_01.dump +++ b/src/testdir/dumps/Test_syntax_c_01.dump @@ -1,4 +1,4 @@ ->/+0#0000e05#ffffff0|*| |c|o|m@1|e|n|t| |l|i|n|e| |a|t| |t|h|e| |t|o|p| |*|/| +0#0000000&@45 +|/+0#0000e05#ffffff0|*| |c|o|m@1|e|n|t| |l|i|n|e| |a|t| |t|h|e| |t|o|p| |*|/| +0#0000000&@45 @2|i+0#00e0003&|n|t| +0#0000000&@69 |m|a|i|n|(|i+0#00e0003&|n|t| +0#0000000&|a|r|g|c|,| |c+0#00e0003&|h|a|r| +0#0000000&|*@1|a|r|g|v|)|/+0#0000e05&@1| |a|n|o|t|h|e|r| |c|o|m@1|e|n|t| +0#0000000&@29 |{| @73 @@ -6,15 +6,15 @@ | +0#0000e05&@2|i|n|t| @2|n|o|t|_|u|s|e|d|;| +0#0000000&@56 |#+0#e000e06&|e|l|s|e| +0#0000000&@69 @3|i+0#00e0003&|n|t| +0#0000000&@2|u|s|e|d|;| @60 -|#+0#e000e06&|e|n|d|i|f| +0#0000000&@68 -@3|p|r|i|n|t|f|(|"+0#e000002&|J|u|s|t| |a|n| |e|x|a|m|p|l|e| |p|i|e|c|e| |o|f| |C| |c|o|d|e|\+0#e000e06&|n|"+0#e000002&|)+0#0000000&|;| @27 +|#+0#e000e06&|e+0&#e0e0e08|n|d|i|f| +0#0000000&| +0&#ffffff0@67 +| +0&#e0e0e08@2|p|r|i|n|t|f|(|"+0#e000002&|J|u|s|t| |a|n| |e|x|a|m|p|l|e| |p|i|e|c|e| |o|f| >C+0&#ffffff0| |c|o|d|e|\+0#e000e06&|n|"+0#e000002&|)+0#0000000&|;| @27 @3|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|0+0#e000002&|x|0|f@1|;+0#0000000&| @58 |}| @73 @3|s+0#00e0003&|t|a|t|i|c| +0#0000000&|v+0#00e0003&|o|i|d| +0#0000000&@60 |m|y|F|u|n|c|t|i|o|n|(|c+0#00e0003&|o|n|s|t| +0#0000000&|d+0#00e0003&|o|u|b|l|e| +0#0000000&|c|o|u|n|t|,| |s+0#00e0003&|t|r|u|c|t| +0#0000000&|n|o|t|h|i|n|g|,| |l+0#00e0003&|o|n|g| +0#0000000&|t|h|e|r|e|)| |{| @14 -@1| +0#0000e05&@6|/@1| |1+0#e000002&|2|3|:+0#0000e05&| |n|o|t|h|i|n|g| |t|o| |r|e|a|d| |h|e|r|e| +0#0000000&@38 +@1| +0#0000e05&@6|/@1| |1+0#e000002&|2|3|:+0#0000e05&| |n|o|t|h|i|n|g| |t|o| |e+0&#ffff4012|n|d|i|f| +0&#ffffff0|h|e|r|e| +0#0000000&@37 @1| +0#af5f00255&@6|f|o|r| +0#0000000&|(|i+0#00e0003&|n|t| +0#0000000&|i| |=| |0+0#e000002&|;+0#0000000&| |i| |<| |c|o|u|n|t|;| |+@1|i|)| |{| @33 @11|b+0#af5f00255&|r|e|a|k|;+0#0000000&| @57 @8|}| @65 |}| @73 -|"|X|t|e|s|t|.|c|"| |1|9|L|,| |3|6|1|C| @37|1|,|1| @10|A|l@1| +|-+2&&@1| |V|I|S|U|A|L| |-@1| +0&&@34|2| @8|1|0|,|3|7| @8|A|l@1| diff --git a/src/testdir/test_syntax.vim b/src/testdir/test_syntax.vim index c7d6f2db85..6705c57b5f 100644 --- a/src/testdir/test_syntax.vim +++ b/src/testdir/test_syntax.vim @@ -551,7 +551,7 @@ func Test_syntax_c() \ '}', \ ' static void', \ 'myFunction(const double count, struct nothing, long there) {', - \ "\t// 123: nothing to read here", + \ "\t// 123: nothing to endif here", \ "\tfor (int i = 0; i < count; ++i) {", \ "\t break;", \ "\t}", @@ -563,7 +563,12 @@ func Test_syntax_c() let $COLORFGBG = '15;0' let buf = RunVimInTerminal('Xtest.c', {}) + call term_sendkeys(buf, ":set hlsearch\r") + call term_sendkeys(buf, "/endif\r") + call term_sendkeys(buf, "vjfC") call VerifyScreenDump(buf, 'Test_syntax_c_01', {}) + + call term_sendkeys(buf, "\") call StopVimInTerminal(buf) let $COLORFGBG = '' diff --git a/src/version.c b/src/version.c index e371d68dbf..3a7347c879 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2176, /**/ 2175, /**/ From afbdb905c37675851e79d21239f502cd8e4ced9e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 19 Oct 2019 14:10:21 +0200 Subject: [PATCH 09/30] patch 8.1.2177: Dart files are not recognized Problem: Dart files are not recognized. Solution: Add a filetype rule. (Eugene Ciurana, closes #5087) --- runtime/filetype.vim | 3 +++ src/testdir/test_filetype.vim | 1 + src/version.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/runtime/filetype.vim b/runtime/filetype.vim index a27dc41953..39121cf17d 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -425,6 +425,9 @@ au BufNewFile,BufRead *.csp,*.fdr setf csp au BufNewFile,BufRead *.pld setf cupl au BufNewFile,BufRead *.si setf cuplsim +" Dart +au BufRead,BufNewfile *.dart,*.drt setf dart + " Debian Control au BufNewFile,BufRead */debian/control setf debcontrol au BufNewFile,BufRead control diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim index 736dc79ebf..93def930d7 100644 --- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -122,6 +122,7 @@ let s:filename_checks = { \ 'cvs': ['cvs123'], \ 'cvsrc': ['.cvsrc'], \ 'cynpp': ['file.cyn'], + \ 'dart': ['file.dart', 'file.drt'], \ 'datascript': ['file.ds'], \ 'dcd': ['file.dcd'], \ 'debcontrol': ['/debian/control'], diff --git a/src/version.c b/src/version.c index 3a7347c879..f96160e63f 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2177, /**/ 2176, /**/ From 15ee567809a9808693163dd7c357ef0c172ecc9e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 19 Oct 2019 14:35:02 +0200 Subject: [PATCH 10/30] patch 8.1.2178: accessing uninitialized memory in test Problem: Accessing uninitialized memory in test. Solution: Check if there was a match before using the match position. (Dominique Pelle, closes #5088) --- src/search.c | 7 ++++--- src/version.c | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/search.c b/src/search.c index 91f53c606d..ab0edc48b9 100644 --- a/src/search.c +++ b/src/search.c @@ -4877,7 +4877,7 @@ is_one_char(char_u *pattern, int move, pos_T *cur, int direction) regmatch.startpos[0].col++; nmatched = vim_regexec_multi(®match, curwin, curbuf, pos.lnum, regmatch.startpos[0].col, NULL, NULL); - if (!nmatched) + if (nmatched != 0) break; } while (direction == FORWARD ? regmatch.startpos[0].col < pos.col : regmatch.startpos[0].col > pos.col); @@ -4887,8 +4887,9 @@ is_one_char(char_u *pattern, int move, pos_T *cur, int direction) result = (nmatched != 0 && regmatch.startpos[0].lnum == regmatch.endpos[0].lnum && regmatch.startpos[0].col == regmatch.endpos[0].col); - /* one char width */ - if (!result && inc(&pos) >= 0 && pos.col == regmatch.endpos[0].col) + // one char width + if (!result && nmatched != 0 + && inc(&pos) >= 0 && pos.col == regmatch.endpos[0].col) result = TRUE; } } diff --git a/src/version.c b/src/version.c index f96160e63f..6a58b3db0e 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2178, /**/ 2177, /**/ From b98678a974914aaf1d00b575364c13a6446353bf Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 19 Oct 2019 15:18:44 +0200 Subject: [PATCH 11/30] patch 8.1.2179: pressing "q" at the more prompt doesn't stop Python output Problem: Pressing "q" at the more prompt doesn't stop Python output. (Daniel Hahler) Solution: Check for got_int in writer(). (closes #5053) Also do this for Lua. --- src/if_lua.c | 3 ++- src/if_py_both.h | 15 ++++++++++----- src/version.c | 2 ++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/if_lua.c b/src/if_lua.c index 4c0eb42a49..31d9659236 100644 --- a/src/if_lua.c +++ b/src/if_lua.c @@ -1612,7 +1612,8 @@ luaV_print(lua_State *L) lua_pop(L, 1); } luaL_pushresult(&b); - luaV_msg(L); + if (!got_int) + luaV_msg(L); return 0; } diff --git a/src/if_py_both.h b/src/if_py_both.h index aa44bf8e31..ee848f9f8b 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -375,9 +375,13 @@ writer(writefn fn, char_u *str, PyInt n) PythonIO_Flush(); old_fn = fn; - /* Write each NL separated line. Text after the last NL is kept for - * writing later. */ - while (n > 0 && (ptr = memchr(str, '\n', n)) != NULL) + // Write each NL separated line. Text after the last NL is kept for + // writing later. + // For normal messages: Do not output when "got_int" was set. This avoids + // a loop gone crazy flooding the terminal with messages. Also for when + // "q" is pressed at the more-prompt. + while (n > 0 && (ptr = memchr(str, '\n', n)) != NULL + && (fn == (writefn)emsg || !got_int)) { PyInt len = ptr - str; @@ -392,8 +396,9 @@ writer(writefn fn, char_u *str, PyInt n) io_ga.ga_len = 0; } - /* Put the remaining text into io_ga for later printing. */ - if (n > 0 && ga_grow(&io_ga, (int)(n + 1)) == OK) + // Put the remaining text into io_ga for later printing. + if (n > 0 && (fn == (writefn)emsg || !got_int) + && ga_grow(&io_ga, (int)(n + 1)) == OK) { mch_memmove(((char *)io_ga.ga_data) + io_ga.ga_len, str, (size_t)n); io_ga.ga_len += (int)n; diff --git a/src/version.c b/src/version.c index 6a58b3db0e..38f82778b3 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2179, /**/ 2178, /**/ From 00e192becd50a38cb21a1bc3f86fcc7a21f8ee88 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 19 Oct 2019 17:01:28 +0200 Subject: [PATCH 12/30] patch 8.1.2180: Error E303 is not useful when 'directory' is empty Problem: Error E303 is not useful when 'directory' is empty. Solution: Skip the error message. (Daniel Hahler, #5067) --- runtime/doc/message.txt | 3 ++- runtime/doc/options.txt | 2 +- src/memline.c | 4 ++-- src/testdir/test_recover.vim | 6 ++++++ src/version.c | 2 ++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/runtime/doc/message.txt b/runtime/doc/message.txt index c4e08f27fc..8160d2157a 100644 --- a/runtime/doc/message.txt +++ b/runtime/doc/message.txt @@ -582,7 +582,8 @@ allowed for the command that was used. Vim was not able to create a swap file. You can still edit the file, but if Vim unexpectedly exits the changes will be lost. And Vim may consume a lot of memory when editing a big file. You may want to change the 'directory' option -to avoid this error. See |swap-file|. +to avoid this error. This error is not given when 'directory' is empty. See +|swap-file|. *E140* > Use ! to write partial buffer diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 34fb484f07..8436c8a0df 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -2693,7 +2693,7 @@ A jump table for the options with a short description can be found at |Q_op|. - The swap file will be created in the first directory where this is possible. - Empty means that no swap file will be used (recovery is - impossible!). + impossible!) and no |E303| error will be given. - A directory "." means to put the swap file in the same directory as the edited file. On Unix, a dot is prepended to the file name, so it doesn't show in a directory listing. On MS-Windows the "hidden" diff --git a/src/memline.c b/src/memline.c index c77d1df9ee..a26e4016ab 100644 --- a/src/memline.c +++ b/src/memline.c @@ -804,9 +804,9 @@ ml_open_file(buf_T *buf) } } - if (mfp->mf_fname == NULL) /* Failed! */ + if (*p_dir != NUL && mfp->mf_fname == NULL) { - need_wait_return = TRUE; /* call wait_return later */ + need_wait_return = TRUE; // call wait_return later ++no_wait_return; (void)semsg(_("E303: Unable to open swap file for \"%s\", recovery impossible"), buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname); diff --git a/src/testdir/test_recover.vim b/src/testdir/test_recover.vim index a9934a1624..a1c7bc4b04 100644 --- a/src/testdir/test_recover.vim +++ b/src/testdir/test_recover.vim @@ -12,6 +12,12 @@ func Test_recover_root_dir() set dir=/notexist/ endif call assert_fails('split Xtest', 'E303:') + + " No error with empty 'directory' setting. + set directory= + split XtestOK + close! + set dir& endfunc diff --git a/src/version.c b/src/version.c index 38f82778b3..aebadab03d 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2180, /**/ 2179, /**/ From a74fda6f4d21d8e0652e9cfa04dd3e041f779f62 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 19 Oct 2019 17:38:03 +0200 Subject: [PATCH 13/30] patch 8.1.2181: highlighting wrong when item follows tab Problem: Highlighting wrong when item follows tab. Solution: Don't use syntax attribute when n_extra is non-zero. (Christian Brabandt, closes #5076) --- src/drawline.c | 25 +++++++----------- src/feature.h | 35 ++++++++++++++----------- src/testdir/dumps/Test_syntax_c_01.dump | 8 +++--- src/version.c | 2 ++ 4 files changed, 36 insertions(+), 34 deletions(-) diff --git a/src/drawline.c b/src/drawline.c index ef3b69f8c2..a13c330c51 100644 --- a/src/drawline.c +++ b/src/drawline.c @@ -1399,14 +1399,14 @@ win_line( } #endif - if (extra_check) +#ifdef FEAT_SYN_HL + syntax_attr = 0; + if (extra_check && n_extra == 0) { -#ifdef FEAT_TERMINAL +# ifdef FEAT_TERMINAL if (get_term_attr) syntax_attr = term_get_attr(wp->w_buffer, lnum, vcol); -#endif - -#ifdef FEAT_SYN_HL +# endif // Get syntax attribute. if (has_syntax) { @@ -1463,8 +1463,8 @@ win_line( syntax_flags = get_syntax_info(&syntax_seqnr); # endif } -#endif } +#endif // Decide which of the highlight attributes to use. attr_pri = TRUE; @@ -1502,7 +1502,7 @@ win_line( // Use line_attr when not in the Visual or 'incsearch' area // (area_attr may be 0 when "noinvcur" is set). # ifdef FEAT_SYN_HL - if (has_syntax) + if (syntax_attr != 0) char_attr = hl_combine_attr(syntax_attr, line_attr); else # endif @@ -1531,15 +1531,10 @@ win_line( else #endif #ifdef FEAT_SYN_HL - if (has_syntax -# ifdef FEAT_TERMINAL - || get_term_attr -# endif - ) - char_attr = syntax_attr; - else -#endif + char_attr = syntax_attr; +#else char_attr = 0; +#endif } } if (char_attr == 0) diff --git a/src/feature.h b/src/feature.h index 04bb30cc63..4c0758d523 100644 --- a/src/feature.h +++ b/src/feature.h @@ -429,18 +429,6 @@ # define FEAT_CONCEAL #endif -/* - * +textprop Text properties and popup windows - */ -#if defined(FEAT_EVAL) && defined(FEAT_SYN_HL) -# define FEAT_TEXT_PROP -#endif - -#if defined(FEAT_SYN_HL) && defined(FEAT_RELTIME) -// Can limit syntax highlight time to 'redrawtime'. -# define SYN_TIME_LIMIT 1 -#endif - /* * +spell spell checking * @@ -1119,10 +1107,6 @@ # define FEAT_ARP #endif -/* - * +GUI_Athena To compile Vim with or without the GUI (gvim) you have - * +GUI_Motif to edit the Makefile. - */ /* * +ole Win32 OLE automation: Use Makefile.ovc. @@ -1138,6 +1122,8 @@ * +tcl TCL interface: "--enable-tclinterp" * +netbeans_intg Netbeans integration * +channel Inter process communication + * +GUI_Athena Athena GUI + * +GUI_Motif Motif GUI */ /* @@ -1170,6 +1156,23 @@ #if defined(FEAT_TERMINAL) && !defined(CURSOR_SHAPE) # define CURSOR_SHAPE #endif +#if defined(FEAT_TERMINAL) && !defined(FEAT_SYN_HL) +// simplify the code a bit by enabling +syntax when +terminal is enabled +# define FEAT_SYN_HL +#endif + +/* + * +textprop Text properties and popup windows + */ +#if defined(FEAT_EVAL) && defined(FEAT_SYN_HL) +# define FEAT_TEXT_PROP +#endif + +#if defined(FEAT_SYN_HL) && defined(FEAT_RELTIME) +// Can limit syntax highlight time to 'redrawtime'. +# define SYN_TIME_LIMIT 1 +#endif + /* * +signs Allow signs to be displayed to the left of text lines. diff --git a/src/testdir/dumps/Test_syntax_c_01.dump b/src/testdir/dumps/Test_syntax_c_01.dump index d70f45ac61..bb1c3c231e 100644 --- a/src/testdir/dumps/Test_syntax_c_01.dump +++ b/src/testdir/dumps/Test_syntax_c_01.dump @@ -12,9 +12,11 @@ |}| @73 @3|s+0#00e0003&|t|a|t|i|c| +0#0000000&|v+0#00e0003&|o|i|d| +0#0000000&@60 |m|y|F|u|n|c|t|i|o|n|(|c+0#00e0003&|o|n|s|t| +0#0000000&|d+0#00e0003&|o|u|b|l|e| +0#0000000&|c|o|u|n|t|,| |s+0#00e0003&|t|r|u|c|t| +0#0000000&|n|o|t|h|i|n|g|,| |l+0#00e0003&|o|n|g| +0#0000000&|t|h|e|r|e|)| |{| @14 -@1| +0#0000e05&@6|/@1| |1+0#e000002&|2|3|:+0#0000e05&| |n|o|t|h|i|n|g| |t|o| |e+0&#ffff4012|n|d|i|f| +0&#ffffff0|h|e|r|e| +0#0000000&@37 -@1| +0#af5f00255&@6|f|o|r| +0#0000000&|(|i+0#00e0003&|n|t| +0#0000000&|i| |=| |0+0#e000002&|;+0#0000000&| |i| |<| |c|o|u|n|t|;| |+@1|i|)| |{| @33 +@8|/+0#0000e05&@1| |1+0#e000002&|2|3|:+0#0000e05&| |n|o|t|h|i|n|g| |t|o| |e+0&#ffff4012|n|d|i|f| +0&#ffffff0|h|e|r|e| +0#0000000&@37 +@8|f+0#af5f00255&|o|r| +0#0000000&|(|i+0#00e0003&|n|t| +0#0000000&|i| |=| |0+0#e000002&|;+0#0000000&| |i| |<| |c|o|u|n|t|;| |+@1|i|)| |{| @33 @11|b+0#af5f00255&|r|e|a|k|;+0#0000000&| @57 @8|}| @65 +@8|N+0&#ffff4012|o|t|e|:+0&#ffffff0| |a|s|d|f| @56 |}| @73 -|-+2&&@1| |V|I|S|U|A|L| |-@1| +0&&@34|2| @8|1|0|,|3|7| @8|A|l@1| +|~+0#4040ff13&| @73 +|-+2#0000000&@1| |V|I|S|U|A|L| |-@1| +0&&@34|2| @8|1|0|,|3|7| @8|A|l@1| diff --git a/src/version.c b/src/version.c index aebadab03d..0fff97d466 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2181, /**/ 2180, /**/ From 5b39d7adb0b9f02afe242f607d4c96250f06965d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 19 Oct 2019 18:37:53 +0200 Subject: [PATCH 14/30] patch 8.1.2182: test42 seen as binary by git diff Problem: Test42 seen as binary by git diff. Solution: Add .gitattributes file. Make explicit that 'cpo' does not contain 'S'. (Daniel Hahler, closes #5072) --- .gitattributes | 1 + Filelist | 1 + src/testdir/test42.in | Bin 2368 -> 2386 bytes src/version.c | 2 ++ 4 files changed, 4 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..9216dbe8db --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +src/testdir/test42.in diff diff --git a/Filelist b/Filelist index e79cbb791e..a2b9f0adb7 100644 --- a/Filelist +++ b/Filelist @@ -4,6 +4,7 @@ # source files for all source archives SRC_ALL = \ .gitignore \ + .gitattributes \ .hgignore \ .lgtm.yml \ .travis.yml \ diff --git a/src/testdir/test42.in b/src/testdir/test42.in index c35569a76c908682eb8e7e7ab8d9a3522d9fa473..1d9d3ab92cd597e8c75fab7763d90cf3906c7da4 100644 GIT binary patch delta 23 ecmX>gbV+DJ7*BFRenClQeqOP*ZScl`4;%n*BndnK delta 10 Rcmca4bU Date: Sat, 19 Oct 2019 18:56:58 +0200 Subject: [PATCH 15/30] patch 8.1.2183: running a test is a bit verbose Problem: Running a test is a bit verbose. Solution: Silence some messages. (Daniel Hahler, closes #5070) --- src/testdir/Makefile | 4 ++-- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/testdir/Makefile b/src/testdir/Makefile index bcf2f8c37b..d4290f96f0 100644 --- a/src/testdir/Makefile +++ b/src/testdir/Makefile @@ -73,8 +73,8 @@ $(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS_RES): $(SCRIPTS_FIRST) # make test_largefile $(NEW_TESTS): rm -f $@.res test.log messages - $(MAKE) -f Makefile $@.res - cat messages + @MAKEFLAGS=--no-print-directory $(MAKE) -f Makefile $@.res + @cat messages @if test -f test.log; then \ exit 1; \ fi diff --git a/src/version.c b/src/version.c index afdc49aeb2..7d61a4f483 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2183, /**/ 2182, /**/ From cfb381421f8be7d6cb4e7dac5b827b23467d3e53 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 19 Oct 2019 20:18:47 +0200 Subject: [PATCH 16/30] patch 8.1.2184: option context is not copied when splitting a window Problem: Option context is not copied when splitting a window. (Daniel Hahler) Solution: Copy the option context, so that ":verbose set" works. (closes #5066) --- src/option.c | 106 ++++++++++++++++++++++++++++++++--- src/testdir/test_options.vim | 36 ++++++++++-- src/version.c | 2 + 3 files changed, 133 insertions(+), 11 deletions(-) diff --git a/src/option.c b/src/option.c index d27c73c3b4..31bf8760b8 100644 --- a/src/option.c +++ b/src/option.c @@ -5641,6 +5641,12 @@ copy_winopt(winopt_T *from, winopt_T *to) #ifdef FEAT_SIGNS to->wo_scl = vim_strsave(from->wo_scl); #endif + +#ifdef FEAT_EVAL + // Copy the script context so that we know where the value was last set. + mch_memmove(to->wo_script_ctx, from->wo_script_ctx, + sizeof(to->wo_script_ctx)); +#endif check_winopt(to); /* don't want NULL pointers */ } @@ -5738,11 +5744,36 @@ clear_winopt(winopt_T *wop UNUSED) #endif } +#ifdef FEAT_EVAL +// Index into the options table for a buffer-local option enum. +static int buf_opt_idx[BV_COUNT]; +# define COPY_OPT_SCTX(buf, bv) buf->b_p_script_ctx[bv] = options[buf_opt_idx[bv]].script_ctx + +/* + * Initialize buf_opt_idx[] if not done already. + */ + static void +init_buf_opt_idx(void) +{ + static int did_init_buf_opt_idx = FALSE; + int i; + + if (did_init_buf_opt_idx) + return; + did_init_buf_opt_idx = TRUE; + for (i = 0; !istermoption_idx(i); i++) + if (options[i].indir & PV_BUF) + buf_opt_idx[options[i].indir & PV_MASK] = i; +} +#else +# define COPY_OPT_SCTX(buf, bv) +#endif + /* * Copy global option values to local options for one buffer. * Used when creating a new buffer and sometimes when entering a buffer. * flags: - * BCO_ENTER We will enter the buf buffer. + * BCO_ENTER We will enter the buffer "buf". * BCO_ALWAYS Always copy the options, but only set b_p_initialized when * appropriate. * BCO_NOHELP Don't copy the values to a help buffer. @@ -5781,12 +5812,16 @@ buf_copy_options(buf_T *buf, int flags) if (should_copy || (flags & BCO_ALWAYS)) { - /* Don't copy the options specific to a help buffer when - * BCO_NOHELP is given or the options were initialized already - * (jumping back to a help file with CTRL-T or CTRL-O) */ + vim_memset(buf->b_p_script_ctx, 0, sizeof(buf->b_p_script_ctx)); +#ifdef FEAT_EVAL + init_buf_opt_idx(); +#endif + // Don't copy the options specific to a help buffer when + // BCO_NOHELP is given or the options were initialized already + // (jumping back to a help file with CTRL-T or CTRL-O) dont_do_help = ((flags & BCO_NOHELP) && buf->b_help) || buf->b_p_initialized; - if (dont_do_help) /* don't free b_p_isk */ + if (dont_do_help) // don't free b_p_isk { save_p_isk = buf->b_p_isk; buf->b_p_isk = NULL; @@ -5821,39 +5856,62 @@ buf_copy_options(buf_T *buf, int flags) free_buf_options(buf, FALSE); buf->b_p_ai = p_ai; + COPY_OPT_SCTX(buf, BV_AI); buf->b_p_ai_nopaste = p_ai_nopaste; buf->b_p_sw = p_sw; + COPY_OPT_SCTX(buf, BV_SW); buf->b_p_tw = p_tw; + COPY_OPT_SCTX(buf, BV_TW); buf->b_p_tw_nopaste = p_tw_nopaste; buf->b_p_tw_nobin = p_tw_nobin; buf->b_p_wm = p_wm; + COPY_OPT_SCTX(buf, BV_WM); buf->b_p_wm_nopaste = p_wm_nopaste; buf->b_p_wm_nobin = p_wm_nobin; buf->b_p_bin = p_bin; + COPY_OPT_SCTX(buf, BV_BIN); buf->b_p_bomb = p_bomb; + COPY_OPT_SCTX(buf, BV_BOMB); buf->b_p_fixeol = p_fixeol; + COPY_OPT_SCTX(buf, BV_FIXEOL); buf->b_p_et = p_et; + COPY_OPT_SCTX(buf, BV_ET); buf->b_p_et_nobin = p_et_nobin; buf->b_p_et_nopaste = p_et_nopaste; buf->b_p_ml = p_ml; + COPY_OPT_SCTX(buf, BV_ML); buf->b_p_ml_nobin = p_ml_nobin; buf->b_p_inf = p_inf; - buf->b_p_swf = cmdmod.noswapfile ? FALSE : p_swf; + COPY_OPT_SCTX(buf, BV_INF); + if (cmdmod.noswapfile) + buf->b_p_swf = FALSE; + else + { + buf->b_p_swf = p_swf; + COPY_OPT_SCTX(buf, BV_INF); + } buf->b_p_cpt = vim_strsave(p_cpt); + COPY_OPT_SCTX(buf, BV_CPT); #ifdef BACKSLASH_IN_FILENAME buf->b_p_csl = vim_strsave(p_csl); + COPY_OPT_SCTX(buf, BV_CSL); #endif #ifdef FEAT_COMPL_FUNC buf->b_p_cfu = vim_strsave(p_cfu); + COPY_OPT_SCTX(buf, BV_CFU); buf->b_p_ofu = vim_strsave(p_ofu); + COPY_OPT_SCTX(buf, BV_OFU); #endif #ifdef FEAT_EVAL buf->b_p_tfu = vim_strsave(p_tfu); + COPY_OPT_SCTX(buf, BV_TFU); #endif buf->b_p_sts = p_sts; + COPY_OPT_SCTX(buf, BV_STS); buf->b_p_sts_nopaste = p_sts_nopaste; #ifdef FEAT_VARTABS buf->b_p_vsts = vim_strsave(p_vsts); + COPY_OPT_SCTX(buf, BV_VSTS); if (p_vsts && p_vsts != empty_option) tabstop_set(p_vsts, &buf->b_p_vsts_array); else @@ -5862,71 +5920,99 @@ buf_copy_options(buf_T *buf, int flags) ? vim_strsave(p_vsts_nopaste) : NULL; #endif buf->b_p_sn = p_sn; + COPY_OPT_SCTX(buf, BV_SN); buf->b_p_com = vim_strsave(p_com); + COPY_OPT_SCTX(buf, BV_COM); #ifdef FEAT_FOLDING buf->b_p_cms = vim_strsave(p_cms); + COPY_OPT_SCTX(buf, BV_CMS); #endif buf->b_p_fo = vim_strsave(p_fo); + COPY_OPT_SCTX(buf, BV_FO); buf->b_p_flp = vim_strsave(p_flp); + COPY_OPT_SCTX(buf, BV_FLP); // NOTE: Valgrind may report a bogus memory leak for 'nrformats' // when it is set to 8 bytes in defaults.vim. buf->b_p_nf = vim_strsave(p_nf); + COPY_OPT_SCTX(buf, BV_NF); buf->b_p_mps = vim_strsave(p_mps); + COPY_OPT_SCTX(buf, BV_MPS); #ifdef FEAT_SMARTINDENT buf->b_p_si = p_si; + COPY_OPT_SCTX(buf, BV_SI); #endif buf->b_p_ci = p_ci; + COPY_OPT_SCTX(buf, BV_CI); #ifdef FEAT_CINDENT buf->b_p_cin = p_cin; + COPY_OPT_SCTX(buf, BV_CIN); buf->b_p_cink = vim_strsave(p_cink); + COPY_OPT_SCTX(buf, BV_CINK); buf->b_p_cino = vim_strsave(p_cino); + COPY_OPT_SCTX(buf, BV_CINO); #endif - /* Don't copy 'filetype', it must be detected */ + // Don't copy 'filetype', it must be detected buf->b_p_ft = empty_option; buf->b_p_pi = p_pi; + COPY_OPT_SCTX(buf, BV_PI); #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) buf->b_p_cinw = vim_strsave(p_cinw); + COPY_OPT_SCTX(buf, BV_CINW); #endif #ifdef FEAT_LISP buf->b_p_lisp = p_lisp; + COPY_OPT_SCTX(buf, BV_LISP); #endif #ifdef FEAT_SYN_HL /* Don't copy 'syntax', it must be set */ buf->b_p_syn = empty_option; buf->b_p_smc = p_smc; + COPY_OPT_SCTX(buf, BV_SMC); buf->b_s.b_syn_isk = empty_option; #endif #ifdef FEAT_SPELL buf->b_s.b_p_spc = vim_strsave(p_spc); + COPY_OPT_SCTX(buf, BV_SPC); (void)compile_cap_prog(&buf->b_s); buf->b_s.b_p_spf = vim_strsave(p_spf); + COPY_OPT_SCTX(buf, BV_SPF); buf->b_s.b_p_spl = vim_strsave(p_spl); + COPY_OPT_SCTX(buf, BV_SPL); #endif #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) buf->b_p_inde = vim_strsave(p_inde); + COPY_OPT_SCTX(buf, BV_INDE); buf->b_p_indk = vim_strsave(p_indk); + COPY_OPT_SCTX(buf, BV_INDK); #endif buf->b_p_fp = empty_option; #if defined(FEAT_EVAL) buf->b_p_fex = vim_strsave(p_fex); + COPY_OPT_SCTX(buf, BV_FEX); #endif #ifdef FEAT_CRYPT buf->b_p_key = vim_strsave(p_key); + COPY_OPT_SCTX(buf, BV_KEY); #endif #ifdef FEAT_SEARCHPATH buf->b_p_sua = vim_strsave(p_sua); + COPY_OPT_SCTX(buf, BV_SUA); #endif #ifdef FEAT_KEYMAP buf->b_p_keymap = vim_strsave(p_keymap); + COPY_OPT_SCTX(buf, BV_KMAP); buf->b_kmap_state |= KEYMAP_INIT; #endif #ifdef FEAT_TERMINAL buf->b_p_twsl = p_twsl; + COPY_OPT_SCTX(buf, BV_TWSL); #endif /* This isn't really an option, but copying the langmap and IME * state from the current buffer is better than resetting it. */ buf->b_p_iminsert = p_iminsert; + COPY_OPT_SCTX(buf, BV_IMI); buf->b_p_imsearch = p_imsearch; + COPY_OPT_SCTX(buf, BV_IMS); /* options that are normally global but also have a local value * are not copied, start using the global value */ @@ -5950,12 +6036,14 @@ buf_copy_options(buf_T *buf, int flags) buf->b_p_inc = empty_option; # ifdef FEAT_EVAL buf->b_p_inex = vim_strsave(p_inex); + COPY_OPT_SCTX(buf, BV_INEX); # endif #endif buf->b_p_dict = empty_option; buf->b_p_tsr = empty_option; #ifdef FEAT_TEXTOBJ buf->b_p_qe = vim_strsave(p_qe); + COPY_OPT_SCTX(buf, BV_QE); #endif #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) buf->b_p_bexpr = empty_option; @@ -5965,6 +6053,7 @@ buf_copy_options(buf_T *buf, int flags) #endif #ifdef FEAT_PERSISTENT_UNDO buf->b_p_udf = p_udf; + COPY_OPT_SCTX(buf, BV_UDF); #endif #ifdef FEAT_LISP buf->b_p_lw = empty_option; @@ -5990,10 +6079,12 @@ buf_copy_options(buf_T *buf, int flags) else { buf->b_p_isk = vim_strsave(p_isk); + COPY_OPT_SCTX(buf, BV_ISK); did_isk = TRUE; buf->b_p_ts = p_ts; #ifdef FEAT_VARTABS buf->b_p_vts = vim_strsave(p_vts); + COPY_OPT_SCTX(buf, BV_VTS); if (p_vts && p_vts != empty_option && !buf->b_p_vts_array) tabstop_set(p_vts, &buf->b_p_vts_array); else @@ -6003,6 +6094,7 @@ buf_copy_options(buf_T *buf, int flags) if (buf->b_p_bt[0] == 'h') clear_string_option(&buf->b_p_bt); buf->b_p_ma = p_ma; + COPY_OPT_SCTX(buf, BV_MA); } } diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim index 3a43356504..65600eea93 100644 --- a/src/testdir/test_options.vim +++ b/src/testdir/test_options.vim @@ -296,20 +296,48 @@ func Test_set_errors() call assert_fails('set t_foo=', 'E846:') endfunc +func CheckWasSet(name) + let verb_cm = execute('verbose set ' .. a:name .. '?') + call assert_match('Last set from.*test_options.vim', verb_cm) +endfunc +func CheckWasNotSet(name) + let verb_cm = execute('verbose set ' .. a:name .. '?') + call assert_notmatch('Last set from', verb_cm) +endfunc + " Must be executed before other tests that set 'term'. func Test_000_term_option_verbose() CheckNotGui - let verb_cm = execute('verbose set t_cm') - call assert_notmatch('Last set from', verb_cm) + call CheckWasNotSet('t_cm') let term_save = &term set term=ansi - let verb_cm = execute('verbose set t_cm') - call assert_match('Last set from.*test_options.vim', verb_cm) + call CheckWasSet('t_cm') let &term = term_save endfunc +func Test_copy_context() + setlocal list + call CheckWasSet('list') + split + call CheckWasSet('list') + quit + setlocal nolist + + set ai + call CheckWasSet('ai') + set filetype=perl + call CheckWasSet('filetype') + set fo=tcroq + call CheckWasSet('fo') + + split Xsomebuf + call CheckWasSet('ai') + call CheckWasNotSet('filetype') + call CheckWasSet('fo') +endfunc + func Test_set_ttytype() CheckUnix CheckNotGui diff --git a/src/version.c b/src/version.c index 7d61a4f483..447f761e04 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2184, /**/ 2183, /**/ From bbfd1562aeaa5b40b6451effc399846b692d6992 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 19 Oct 2019 20:38:15 +0200 Subject: [PATCH 17/30] patch 8.1.2185: syntax test fails Problem: Syntax test fails. Solution: Add missing file patch. --- src/testdir/test_syntax.vim | 4 +++- src/version.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/testdir/test_syntax.vim b/src/testdir/test_syntax.vim index 6705c57b5f..4f431d0cc3 100644 --- a/src/testdir/test_syntax.vim +++ b/src/testdir/test_syntax.vim @@ -555,6 +555,7 @@ func Test_syntax_c() \ "\tfor (int i = 0; i < count; ++i) {", \ "\t break;", \ "\t}", + \ "\tNote: asdf", \ '}', \ ], 'Xtest.c') @@ -562,7 +563,8 @@ func Test_syntax_c() " response to t_RB corrects it to "light". let $COLORFGBG = '15;0' - let buf = RunVimInTerminal('Xtest.c', {}) + let buf = RunVimInTerminal('Xtest.c', #{rows: 22}) + call term_sendkeys(buf, ":syn keyword Search Note\r") call term_sendkeys(buf, ":set hlsearch\r") call term_sendkeys(buf, "/endif\r") call term_sendkeys(buf, "vjfC") diff --git a/src/version.c b/src/version.c index 447f761e04..dd957cd39f 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2185, /**/ 2184, /**/ From 7eed964b4196b0bfc6cf09dc449f0b9650b2d31e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 19 Oct 2019 20:57:28 +0200 Subject: [PATCH 18/30] patch 8.1.2186: error for bad regexp even though regexp is not used Problem: Error for bad regexp even though regexp is not used, when writing a file. (Arseny Nasokin) Solution: Ignore regexp errors. (closes #5059) --- src/option.c | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/option.c b/src/option.c index 31bf8760b8..3314a3c4b7 100644 --- a/src/option.c +++ b/src/option.c @@ -5812,8 +5812,8 @@ buf_copy_options(buf_T *buf, int flags) if (should_copy || (flags & BCO_ALWAYS)) { - vim_memset(buf->b_p_script_ctx, 0, sizeof(buf->b_p_script_ctx)); #ifdef FEAT_EVAL + vim_memset(buf->b_p_script_ctx, 0, sizeof(buf->b_p_script_ctx)); init_buf_opt_idx(); #endif // Don't copy the options specific to a help buffer when diff --git a/src/version.c b/src/version.c index dd957cd39f..65979b2535 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2186, /**/ 2185, /**/ From b40c2576d4e0e2dd2c580414c45947d88556d76d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 19 Oct 2019 21:01:05 +0200 Subject: [PATCH 19/30] patch 8.1.2187: error for bad regexp even though regexp is not used Problem: Error for bad regexp even though regexp is not used when writing a file. (Arseny Nasokin) Solution: Ignore regexp errors. (closes #5059) --- src/cmdexpand.c | 2 ++ src/ex_docmd.c | 3 ++- src/testdir/test_writefile.vim | 7 ++++++- src/version.c | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/cmdexpand.c b/src/cmdexpand.c index b3f18c6dec..7381b0e9b7 100644 --- a/src/cmdexpand.c +++ b/src/cmdexpand.c @@ -1976,6 +1976,8 @@ ExpandFromContext( flags |= EW_KEEPALL; if (options & WILD_SILENT) flags |= EW_SILENT; + if (options & WILD_NOERROR) + flags |= EW_NOERROR; if (options & WILD_ALLLINKS) flags |= EW_ALLLINKS; diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 4dd7ba23d8..1d0476946d 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -4211,7 +4211,8 @@ expand_filename( else /* n == 2 */ { expand_T xpc; - int options = WILD_LIST_NOTFOUND|WILD_ADD_SLASH; + int options = WILD_LIST_NOTFOUND + | WILD_NOERROR | WILD_ADD_SLASH; ExpandInit(&xpc); xpc.xp_context = EXPAND_FILES; diff --git a/src/testdir/test_writefile.vim b/src/testdir/test_writefile.vim index 4b0a6d6c73..8eb2e7809f 100644 --- a/src/testdir/test_writefile.vim +++ b/src/testdir/test_writefile.vim @@ -1,4 +1,4 @@ -" Tests for the writefile() function. +" Tests for the writefile() function and some :write commands. func Test_writefile() let f = tempname() @@ -16,6 +16,11 @@ func Test_writefile() call delete(f) endfunc +func Test_writefile_ignore_regexp_error() + write Xt[z-a]est.txt + call delete('Xt[z-a]est.txt') +endfunc + func Test_writefile_fails_gently() call assert_fails('call writefile(["test"], "Xfile", [])', 'E730:') call assert_false(filereadable("Xfile")) diff --git a/src/version.c b/src/version.c index 65979b2535..c55af5ab5c 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2187, /**/ 2186, /**/ From 2b78ab5d0c91c229715ae140a34978506343bde3 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 19 Oct 2019 22:50:20 +0200 Subject: [PATCH 20/30] patch 8.1.2188: build error for missing define Problem: Build error for missing define. Solution: Add missing change. --- src/version.c | 2 ++ src/vim.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/version.c b/src/version.c index c55af5ab5c..f11a020107 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2188, /**/ 2187, /**/ diff --git a/src/vim.h b/src/vim.h index d361f8a766..e92352c65c 100644 --- a/src/vim.h +++ b/src/vim.h @@ -810,6 +810,7 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring); #define WILD_ICASE 0x100 #define WILD_ALLLINKS 0x200 #define WILD_IGNORE_COMPLETESLASH 0x400 +#define WILD_NOERROR 0x800 // sets EW_NOERROR // Flags for expand_wildcards() #define EW_DIR 0x01 // include directory names From 82260afb0ec358f50df9816511f480d455a1cdac Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 20 Oct 2019 13:16:22 +0200 Subject: [PATCH 21/30] patch 8.1.2189: syntax highlighting wrong for tab Problem: Syntax highlighting wrong for tab. Solution: Don't clear syntax attribute n_extra is non-zero. --- src/drawline.c | 2 +- src/testdir/dumps/Test_syntax_c_01.dump | 4 ++-- src/testdir/test_syntax.vim | 2 ++ src/version.c | 2 ++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/drawline.c b/src/drawline.c index a13c330c51..ac37928427 100644 --- a/src/drawline.c +++ b/src/drawline.c @@ -1400,9 +1400,9 @@ win_line( #endif #ifdef FEAT_SYN_HL - syntax_attr = 0; if (extra_check && n_extra == 0) { + syntax_attr = 0; # ifdef FEAT_TERMINAL if (get_term_attr) syntax_attr = term_get_attr(wp->w_buffer, lnum, vcol); diff --git a/src/testdir/dumps/Test_syntax_c_01.dump b/src/testdir/dumps/Test_syntax_c_01.dump index bb1c3c231e..4bef1b71c8 100644 --- a/src/testdir/dumps/Test_syntax_c_01.dump +++ b/src/testdir/dumps/Test_syntax_c_01.dump @@ -10,6 +10,7 @@ | +0&#e0e0e08@2|p|r|i|n|t|f|(|"+0#e000002&|J|u|s|t| |a|n| |e|x|a|m|p|l|e| |p|i|e|c|e| |o|f| >C+0&#ffffff0| |c|o|d|e|\+0#e000e06&|n|"+0#e000002&|)+0#0000000&|;| @27 @3|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|0+0#e000002&|x|0|f@1|;+0#0000000&| @58 |}| @73 +| +0#ffffff16#ff404010@16| +0#0000000#ffffff0@57 @3|s+0#00e0003&|t|a|t|i|c| +0#0000000&|v+0#00e0003&|o|i|d| +0#0000000&@60 |m|y|F|u|n|c|t|i|o|n|(|c+0#00e0003&|o|n|s|t| +0#0000000&|d+0#00e0003&|o|u|b|l|e| +0#0000000&|c|o|u|n|t|,| |s+0#00e0003&|t|r|u|c|t| +0#0000000&|n|o|t|h|i|n|g|,| |l+0#00e0003&|o|n|g| +0#0000000&|t|h|e|r|e|)| |{| @14 @8|/+0#0000e05&@1| |1+0#e000002&|2|3|:+0#0000e05&| |n|o|t|h|i|n|g| |t|o| |e+0&#ffff4012|n|d|i|f| +0&#ffffff0|h|e|r|e| +0#0000000&@37 @@ -18,5 +19,4 @@ @8|}| @65 @8|N+0&#ffff4012|o|t|e|:+0&#ffffff0| |a|s|d|f| @56 |}| @73 -|~+0#4040ff13&| @73 -|-+2#0000000&@1| |V|I|S|U|A|L| |-@1| +0&&@34|2| @8|1|0|,|3|7| @8|A|l@1| +|-+2&&@1| |V|I|S|U|A|L| |-@1| +0&&@34|2| @8|1|0|,|3|7| @8|A|l@1| diff --git a/src/testdir/test_syntax.vim b/src/testdir/test_syntax.vim index 4f431d0cc3..c87b3d65e3 100644 --- a/src/testdir/test_syntax.vim +++ b/src/testdir/test_syntax.vim @@ -549,6 +549,7 @@ func Test_syntax_c() \ ' printf("Just an example piece of C code\n");', \ ' return 0x0ff;', \ '}', + \ "\t\t ", \ ' static void', \ 'myFunction(const double count, struct nothing, long there) {', \ "\t// 123: nothing to endif here", @@ -565,6 +566,7 @@ func Test_syntax_c() let buf = RunVimInTerminal('Xtest.c', #{rows: 22}) call term_sendkeys(buf, ":syn keyword Search Note\r") + call term_sendkeys(buf, ":syn match Error /^\\s\\+$/\r") call term_sendkeys(buf, ":set hlsearch\r") call term_sendkeys(buf, "/endif\r") call term_sendkeys(buf, "vjfC") diff --git a/src/version.c b/src/version.c index f11a020107..83609888ea 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2189, /**/ 2188, /**/ From 83e9a1ce75818a78c5ddf8dcfb820634ca6fabff Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 20 Oct 2019 14:51:23 +0200 Subject: [PATCH 22/30] patch 8.1.2190: syntax test fails on Mac Problem: Syntax test fails on Mac. Solution: Limit the window size to 20 rows. --- src/testdir/dumps/Test_syntax_c_01.dump | 6 ++---- src/testdir/test_syntax.vim | 6 ++---- src/version.c | 2 ++ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/testdir/dumps/Test_syntax_c_01.dump b/src/testdir/dumps/Test_syntax_c_01.dump index 4bef1b71c8..72242162ed 100644 --- a/src/testdir/dumps/Test_syntax_c_01.dump +++ b/src/testdir/dumps/Test_syntax_c_01.dump @@ -1,7 +1,5 @@ |/+0#0000e05#ffffff0|*| |c|o|m@1|e|n|t| |l|i|n|e| |a|t| |t|h|e| |t|o|p| |*|/| +0#0000000&@45 -@2|i+0#00e0003&|n|t| +0#0000000&@69 -|m|a|i|n|(|i+0#00e0003&|n|t| +0#0000000&|a|r|g|c|,| |c+0#00e0003&|h|a|r| +0#0000000&|*@1|a|r|g|v|)|/+0#0000e05&@1| |a|n|o|t|h|e|r| |c|o|m@1|e|n|t| +0#0000000&@29 -|{| @73 +|i+0#00e0003&|n|t| +0#0000000&|m|a|i|n|(|i+0#00e0003&|n|t| +0#0000000&|a|r|g|c|,| |c+0#00e0003&|h|a|r| +0#0000000&|*@1|a|r|g|v|)| |{| |/+0#0000e05&@1| |a|n|o|t|h|e|r| |c|o|m@1|e|n|t| +0#0000000&@22 |#+0#e000e06&|i|f| |0| +0#0000000&@69 | +0#0000e05&@2|i|n|t| @2|n|o|t|_|u|s|e|d|;| +0#0000000&@56 |#+0#e000e06&|e|l|s|e| +0#0000000&@69 @@ -19,4 +17,4 @@ @8|}| @65 @8|N+0&#ffff4012|o|t|e|:+0&#ffffff0| |a|s|d|f| @56 |}| @73 -|-+2&&@1| |V|I|S|U|A|L| |-@1| +0&&@34|2| @8|1|0|,|3|7| @8|A|l@1| +|-+2&&@1| |V|I|S|U|A|L| |-@1| +0&&@34|2| @8|8|,|3|7| @9|A|l@1| diff --git a/src/testdir/test_syntax.vim b/src/testdir/test_syntax.vim index c87b3d65e3..21ee8dc628 100644 --- a/src/testdir/test_syntax.vim +++ b/src/testdir/test_syntax.vim @@ -538,9 +538,7 @@ func Test_syntax_c() endif call writefile([ \ '/* comment line at the top */', - \ ' int', - \ 'main(int argc, char **argv)// another comment', - \ '{', + \ 'int main(int argc, char **argv) { // another comment', \ '#if 0', \ ' int not_used;', \ '#else', @@ -564,7 +562,7 @@ func Test_syntax_c() " response to t_RB corrects it to "light". let $COLORFGBG = '15;0' - let buf = RunVimInTerminal('Xtest.c', #{rows: 22}) + let buf = RunVimInTerminal('Xtest.c', {}) call term_sendkeys(buf, ":syn keyword Search Note\r") call term_sendkeys(buf, ":syn match Error /^\\s\\+$/\r") call term_sendkeys(buf, ":set hlsearch\r") diff --git a/src/version.c b/src/version.c index 83609888ea..caf8ccf2ba 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2190, /**/ 2189, /**/ From 88d3d09e07dbe0e3ea450bc554e2aadc451450d2 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 20 Oct 2019 16:00:47 +0200 Subject: [PATCH 23/30] patch 8.1.2191: when using modifyOtherKeys CTRL-X mode may not work Problem: When using modifyOtherKeys CTRL-X mode may not work. Solution: Recognize a control character also in the form with a modifier. --- src/getchar.c | 20 +++++++++++++++++++- src/version.c | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/getchar.c b/src/getchar.c index 03a67be34a..f9bfab8297 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -2142,6 +2142,24 @@ typedef enum { map_result_nomatch // no matching mapping, get char } map_result_T; +/* + * Check if the bytes at the start of the typeahead buffer are a character used + * in CTRL-X mode. This includes the form with a CTRL modifier. + */ + static int +at_ctrl_x_key(void) +{ + char_u *p = typebuf.tb_buf + typebuf.tb_off; + int c = *p; + + if (typebuf.tb_len > 3 + && c == K_SPECIAL + && p[1] == KS_MODIFIER + && (p[2] & MOD_MASK_CTRL)) + c = p[3] & 0x1f; + return vim_is_ctrl_x_key(c); +} + /* * Handle mappings in the typeahead buffer. * - When something was mapped, return map_result_retry for recursive mappings. @@ -2193,7 +2211,7 @@ handle_mapping( && !(State == HITRETURN && (tb_c1 == CAR || tb_c1 == ' ')) && State != ASKMORE && State != CONFIRM - && !((ctrl_x_mode_not_default() && vim_is_ctrl_x_key(tb_c1)) + && !((ctrl_x_mode_not_default() && at_ctrl_x_key()) || ((compl_cont_status & CONT_LOCAL) && (tb_c1 == Ctrl_N || tb_c1 == Ctrl_P)))) { diff --git a/src/version.c b/src/version.c index caf8ccf2ba..c9c0943e14 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2191, /**/ 2190, /**/ From dca7abe79cc4f0933473c3e4bcc75b46cc2c48fd Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 20 Oct 2019 18:17:57 +0200 Subject: [PATCH 24/30] patch 8.1.2192: cannot easily fill the info popup asynchronously Problem: Cannot easily fill the info popup asynchronously. Solution: Add the "popuphidden" value to 'completeopt'. (closes #4924) --- runtime/doc/insert.txt | 23 +++++++- runtime/doc/options.txt | 9 ++- src/ex_cmds.c | 17 ++++-- src/optionstr.c | 2 +- src/popupmenu.c | 52 ++++++++++------ src/popupwin.c | 6 +- src/proto/ex_cmds.pro | 2 +- src/proto/popupmenu.pro | 1 + src/proto/popupwin.pro | 1 + .../Test_popupwin_infopopup_hidden_1.dump | 14 +++++ .../Test_popupwin_infopopup_hidden_2.dump | 14 +++++ .../Test_popupwin_infopopup_hidden_3.dump | 14 +++++ src/testdir/test_popupwin.vim | 59 +++++++++++++++++++ src/version.c | 2 + src/vim.h | 7 +++ 15 files changed, 195 insertions(+), 28 deletions(-) create mode 100644 src/testdir/dumps/Test_popupwin_infopopup_hidden_1.dump create mode 100644 src/testdir/dumps/Test_popupwin_infopopup_hidden_2.dump create mode 100644 src/testdir/dumps/Test_popupwin_infopopup_hidden_3.dump diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index dfc3541f55..d28bf59984 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -1,4 +1,4 @@ -*insert.txt* For Vim version 8.1. Last change: 2019 Sep 27 +*insert.txt* For Vim version 8.1. Last change: 2019 Oct 20 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1138,6 +1138,27 @@ below the text, and the bottom of the menu otherwise. After the info popup is created it can be found with |popup_findinfo()| and properties can be changed with |popup_setoptions()|. + *complete-popuphidden* +If the information for the popup is obtained asynchronously, use "popuphidden" +in 'completeopt'. The info popup will then be initally hidden and +|popup_show()| must be called once it has been filled with the info. This can +be done with a |CompleteChanged| autocommand, something like this: > + set completeopt+=popuphidden + au CompleteChanged * call UpdateCompleteInfo() + func UpdateCompleteInfo() + " Cancel any pending info fetch + let item = v:event.completed_item + " Start fetching info for the item then call ShowCompleteInfo(info) + endfunc + func ShowCompleteInfo(info) + let id = popup_findinfo() + if id + call popup_settext(id, 'async info: ' .. a:info) + call popup_show(id) + endif + endfunc + +< *complete-item-kind* The "kind" item uses a single letter to indicate the kind of completion. This may be used to show the completion differently (different color or icon). Currently these types can be used: diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 8436c8a0df..e62ee8974e 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 8.1. Last change: 2019 Sep 28 +*options.txt* For Vim version 8.1. Last change: 2019 Oct 20 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1919,6 +1919,13 @@ A jump table for the options with a short description can be found at |Q_op|. See |'completepopup'| for specifying properties. {only works when compiled with the |+textprop| feature} + popuphidden + Just like "popup" but initially hide the popup. Use a + |CompleteChanged| autocommand to fetch the info and call + |popup_show()| once the popup has been filled. + See the example at |complete-popuphidden|. + {only works when compiled with the |+textprop| feature} + noinsert Do not insert any text for a match until the user selects a match from the menu. Only works in combination with "menu" or "menuone". No effect if "longest" is present. diff --git a/src/ex_cmds.c b/src/ex_cmds.c index fc70e2cfef..bcff7ee716 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -4919,13 +4919,14 @@ free_old_sub(void) #if defined(FEAT_QUICKFIX) || defined(PROTO) /* * Set up for a tagpreview. + * Makes the preview window the current window. * Return TRUE when it was created. */ int prepare_tagpreview( int undo_sync, // sync undo when leaving the window int use_previewpopup, // use popup if 'previewpopup' set - int use_popup) // use other popup window + use_popup_T use_popup) // use other popup window { win_T *wp; @@ -4945,11 +4946,16 @@ prepare_tagpreview( if (wp != NULL) popup_set_wantpos_cursor(wp, wp->w_minwidth); } - else if (use_popup) + else if (use_popup != USEPOPUP_NONE) { wp = popup_find_info_window(); if (wp != NULL) - popup_show(wp); + { + if (use_popup == USEPOPUP_NORMAL) + popup_show(wp); + else + popup_hide(wp); + } } else # endif @@ -4966,8 +4972,9 @@ prepare_tagpreview( * There is no preview window open yet. Create one. */ # ifdef FEAT_TEXT_PROP - if ((use_previewpopup && *p_pvp != NUL) || use_popup) - return popup_create_preview_window(use_popup); + if ((use_previewpopup && *p_pvp != NUL) + || use_popup != USEPOPUP_NONE) + return popup_create_preview_window(use_popup != USEPOPUP_NONE); # endif if (win_split(g_do_tagpreview > 0 ? g_do_tagpreview : 0, 0) == FAIL) return FALSE; diff --git a/src/optionstr.c b/src/optionstr.c index 7b83aed250..bcc737eb17 100644 --- a/src/optionstr.c +++ b/src/optionstr.c @@ -76,7 +76,7 @@ static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax", NULL}; static char *(p_fcl_values[]) = {"all", NULL}; #endif -static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "popup", "noinsert", "noselect", NULL}; +static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "popup", "popuphidden", "noinsert", "noselect", NULL}; #ifdef BACKSLASH_IN_FILENAME static char *(p_csl_values[]) = {"slash", "backslash", NULL}; #endif diff --git a/src/popupmenu.c b/src/popupmenu.c index b88c6531c1..005adb20ba 100644 --- a/src/popupmenu.c +++ b/src/popupmenu.c @@ -622,33 +622,36 @@ pum_redraw(void) } #if defined(FEAT_TEXT_PROP) && defined(FEAT_QUICKFIX) - static void -pum_position_info_popup(void) +/* + * Position the info popup relative to the popup menu item. + */ + void +pum_position_info_popup(win_T *wp) { int col = pum_col + pum_width + 1; int row = pum_row; int botpos = POPPOS_BOTLEFT; - curwin->w_popup_pos = POPPOS_TOPLEFT; + wp->w_popup_pos = POPPOS_TOPLEFT; if (Columns - col < 20 && Columns - col < pum_col) { col = pum_col - 1; - curwin->w_popup_pos = POPPOS_TOPRIGHT; + wp->w_popup_pos = POPPOS_TOPRIGHT; botpos = POPPOS_BOTRIGHT; - curwin->w_maxwidth = pum_col - 1; + wp->w_maxwidth = pum_col - 1; } else - curwin->w_maxwidth = Columns - col + 1; - curwin->w_maxwidth -= popup_extra_width(curwin); + wp->w_maxwidth = Columns - col + 1; + wp->w_maxwidth -= popup_extra_width(wp); - row -= popup_top_extra(curwin); - if (curwin->w_popup_flags & POPF_INFO_MENU) + row -= popup_top_extra(wp); + if (wp->w_popup_flags & POPF_INFO_MENU) { if (pum_row < pum_win_row) { // menu above cursor line, align with bottom row += pum_height; - curwin->w_popup_pos = botpos; + wp->w_popup_pos = botpos; } else // menu below cursor line, align with top @@ -658,7 +661,7 @@ pum_position_info_popup(void) // align with the selected item row += pum_selected - pum_first + 1; - popup_set_wantpos_rowcol(curwin, row, col); + popup_set_wantpos_rowcol(wp, row, col); } #endif @@ -756,15 +759,21 @@ pum_set_selected(int n, int repeat UNUSED) tabpage_T *curtab_save = curtab; int res = OK; # ifdef FEAT_TEXT_PROP - int use_popup = strstr((char *)p_cot, "popup") != NULL; + use_popup_T use_popup; # else -# define use_popup 0 +# define use_popup POPUP_NONE # endif # ifdef FEAT_TEXT_PROP has_info = TRUE; + if (strstr((char *)p_cot, "popuphidden") != NULL) + use_popup = USEPOPUP_HIDDEN; + else if (strstr((char *)p_cot, "popup") != NULL) + use_popup = USEPOPUP_NORMAL; + else + use_popup = USEPOPUP_NONE; # endif - // Open a preview window. 3 lines by default. Prefer - // 'previewheight' if set and smaller. + // Open a preview window and set "curwin" to it. + // 3 lines by default, prefer 'previewheight' if set and smaller. g_do_tagpreview = 3; if (p_pvh > 0 && p_pvh < g_do_tagpreview) g_do_tagpreview = p_pvh; @@ -838,7 +847,7 @@ pum_set_selected(int n, int repeat UNUSED) /* Increase the height of the preview window to show the * text, but no more than 'previewheight' lines. */ - if (repeat == 0 && !use_popup) + if (repeat == 0 && use_popup == USEPOPUP_NONE) { if (lnum > p_pvh) lnum = p_pvh; @@ -863,9 +872,9 @@ pum_set_selected(int n, int repeat UNUSED) curwin->w_cursor.lnum = curwin->w_topline; curwin->w_cursor.col = 0; # ifdef FEAT_TEXT_PROP - if (use_popup) + if (use_popup != USEPOPUP_NONE) { - pum_position_info_popup(); + pum_position_info_popup(curwin); if (win_valid(curwin_save)) redraw_win_later(curwin_save, SOME_VALID); } @@ -907,9 +916,16 @@ pum_set_selected(int n, int repeat UNUSED) if (!resized && win_valid(curwin_save)) { +# ifdef FEAT_TEXT_PROP + win_T *wp = curwin; +# endif ++no_u_sync; win_enter(curwin_save, TRUE); --no_u_sync; +# ifdef FEAT_TEXT_PROP + if (use_popup == USEPOPUP_HIDDEN && win_valid(wp)) + popup_hide(wp); +# endif } /* May need to update the screen again when there are diff --git a/src/popupwin.c b/src/popupwin.c index f9c127a6c4..95435f8fe7 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -2225,7 +2225,7 @@ f_popup_close(typval_T *argvars, typval_T *rettv UNUSED) popup_close_and_callback(wp, &argvars[1]); } - static void + void popup_hide(win_T *wp) { if ((wp->w_popup_flags & POPF_HIDDEN) == 0) @@ -2272,7 +2272,11 @@ f_popup_show(typval_T *argvars, typval_T *rettv UNUSED) win_T *wp = find_popup_win(id); if (wp != NULL) + { popup_show(wp); + if (wp->w_popup_flags & POPF_INFO) + pum_position_info_popup(wp); + } } /* diff --git a/src/proto/ex_cmds.pro b/src/proto/ex_cmds.pro index a4d60ba166..3693cf4265 100644 --- a/src/proto/ex_cmds.pro +++ b/src/proto/ex_cmds.pro @@ -35,7 +35,7 @@ void global_exe(char_u *cmd); char_u *get_old_sub(void); void set_old_sub(char_u *val); void free_old_sub(void); -int prepare_tagpreview(int undo_sync, int use_previewpopup, int use_popup); +int prepare_tagpreview(int undo_sync, int use_previewpopup, use_popup_T use_popup); void ex_help(exarg_T *eap); void ex_helpclose(exarg_T *eap); char_u *check_help_lang(char_u *arg); diff --git a/src/proto/popupmenu.pro b/src/proto/popupmenu.pro index f5b6c0c90f..c6527b8598 100644 --- a/src/proto/popupmenu.pro +++ b/src/proto/popupmenu.pro @@ -3,6 +3,7 @@ void pum_display(pumitem_T *array, int size, int selected); void pum_call_update_screen(void); int pum_under_menu(int row, int col); void pum_redraw(void); +void pum_position_info_popup(win_T *wp); void pum_undisplay(void); void pum_clear(void); int pum_visible(void); diff --git a/src/proto/popupwin.pro b/src/proto/popupwin.pro index d6ba3e7f8b..4ec4a748de 100644 --- a/src/proto/popupwin.pro +++ b/src/proto/popupwin.pro @@ -26,6 +26,7 @@ void f_popup_dialog(typval_T *argvars, typval_T *rettv); void f_popup_menu(typval_T *argvars, typval_T *rettv); void f_popup_notification(typval_T *argvars, typval_T *rettv); void f_popup_close(typval_T *argvars, typval_T *rettv); +void popup_hide(win_T *wp); void f_popup_hide(typval_T *argvars, typval_T *rettv); void popup_show(win_T *wp); void f_popup_show(typval_T *argvars, typval_T *rettv); diff --git a/src/testdir/dumps/Test_popupwin_infopopup_hidden_1.dump b/src/testdir/dumps/Test_popupwin_infopopup_hidden_1.dump new file mode 100644 index 0000000000..f56ebc4479 --- /dev/null +++ b/src/testdir/dumps/Test_popupwin_infopopup_hidden_1.dump @@ -0,0 +1,14 @@ +|t+0&#ffffff0|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|a|w|o|r|d> @43 +|~+0#4040ff13&| @23| +0#0000001#e0e0e08|w|r|d| @4|W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27 +|~| @23| +0#0000001#ffd7ff255|a|n|o|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27 +|~| @23| +0#0000001#ffd7ff255|n|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27 +|~| @23| +0#0000001#ffd7ff255|t|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|-+2#0000000&@1| |U|s|e|r| |d|e|f|i|n|e|d| |c|o|m|p|l|e|t|i|o|n| |(|^|U|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |4| +0#0000000&@26 diff --git a/src/testdir/dumps/Test_popupwin_infopopup_hidden_2.dump b/src/testdir/dumps/Test_popupwin_infopopup_hidden_2.dump new file mode 100644 index 0000000000..d834e579b0 --- /dev/null +++ b/src/testdir/dumps/Test_popupwin_infopopup_hidden_2.dump @@ -0,0 +1,14 @@ +|t+0&#ffffff0|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|a|n|o|t|h|e|r|w|o|r|d> @37 +|~+0#4040ff13&| @23| +0#0000001#ffd7ff255|w|r|d| @4|W| |e|x|t|r|a| |t|e|x|t| | +0&#e0e0e08|i|m@1|e|d|i|a|t|e| |i|n|f|o| |3| | +0#4040ff13#ffffff0@9 +|~| @23| +0#0000001#e0e0e08|a|n|o|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27 +|~| @23| +0#0000001#ffd7ff255|n|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27 +|~| @23| +0#0000001#ffd7ff255|t|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|-+2#0000000&@1| |U|s|e|r| |d|e|f|i|n|e|d| |c|o|m|p|l|e|t|i|o|n| |(|^|U|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |2| |o|f| |4| +0#0000000&@26 diff --git a/src/testdir/dumps/Test_popupwin_infopopup_hidden_3.dump b/src/testdir/dumps/Test_popupwin_infopopup_hidden_3.dump new file mode 100644 index 0000000000..410c393407 --- /dev/null +++ b/src/testdir/dumps/Test_popupwin_infopopup_hidden_3.dump @@ -0,0 +1,14 @@ +|t+0&#ffffff0|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|n|o|i|n|f|o> @42 +|~+0#4040ff13&| @23| +0#0000001#ffd7ff255|w|r|d| @4|W| |e|x|t|r|a| |t|e|x|t| | +0&#e0e0e08|a|s|y|n|c| |i|n|f|o| |4| | +0#4040ff13#ffffff0@13 +|~| @23| +0#0000001#ffd7ff255|a|n|o|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27 +|~| @23| +0#0000001#e0e0e08|n|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27 +|~| @23| +0#0000001#ffd7ff255|t|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|-+2#0000000&@1| |U|s|e|r| |d|e|f|i|n|e|d| |c|o|m|p|l|e|t|i|o|n| |(|^|U|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |3| |o|f| |4| +0#0000000&@26 diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index e84527bf7f..2e2d1df80e 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -2498,6 +2498,41 @@ func Get_popupmenu_lines() let id = popup_findinfo() eval id->popup_setoptions(#{highlight: 'InfoPopup'}) endfunc + + func InfoHidden() + set completepopup=height:4,border:off,align:menu + set completeopt-=popup completeopt+=popuphidden + au CompleteChanged * call HandleChange() + endfunc + + let s:counter = 0 + func HandleChange() + let s:counter += 1 + let selected = complete_info(['selected']).selected + if selected <= 0 + " First time: do nothing, info remains hidden + return + endif + if selected == 1 + " Second time: show info right away + let id = popup_findinfo() + if id + call popup_settext(id, 'immediate info ' .. s:counter) + call popup_show(id) + endif + else + " Third time: show info after a short delay + call timer_start(100, 'ShowInfo') + endif + endfunc + + func ShowInfo(...) + let id = popup_findinfo() + if id + call popup_settext(id, 'async info ' .. s:counter) + call popup_show(id) + endif + endfunc END return lines endfunc @@ -2580,6 +2615,30 @@ func Test_popupmenu_info_align_menu() call delete('XtestInfoPopupNb') endfunc +func Test_popupmenu_info_hidden() + CheckScreendump + + let lines = Get_popupmenu_lines() + call add(lines, 'call InfoHidden()') + call writefile(lines, 'XtestInfoPopupHidden') + + let buf = RunVimInTerminal('-S XtestInfoPopupHidden', #{rows: 14}) + call term_wait(buf, 50) + + call term_sendkeys(buf, "A\\") + call VerifyScreenDump(buf, 'Test_popupwin_infopopup_hidden_1', {}) + + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_popupwin_infopopup_hidden_2', {}) + + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_popupwin_infopopup_hidden_3', {}) + + call term_sendkeys(buf, "\") + call StopVimInTerminal(buf) + call delete('XtestInfoPopupHidden') +endfunc + func Test_popupwin_recycle_bnr() let bufnr = popup_notification('nothing wrong', {})->winbufnr() call popup_clear() diff --git a/src/version.c b/src/version.c index c9c0943e14..76b4c1cf52 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2192, /**/ 2191, /**/ diff --git a/src/vim.h b/src/vim.h index e92352c65c..43eecf0907 100644 --- a/src/vim.h +++ b/src/vim.h @@ -2112,6 +2112,13 @@ typedef enum { FLUSH_INPUT // flush typebuf and inchar() input } flush_buffers_T; +// Argument for prepare_tagpreview() +typedef enum { + USEPOPUP_NONE, + USEPOPUP_NORMAL, // use info popup + USEPOPUP_HIDDEN // use info popup initially hidden +} use_popup_T; + #include "ex_cmds.h" // Ex command defines #include "spell.h" // spell checking stuff From a13961536e5b1e686574826d4ed713e3d5526715 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 20 Oct 2019 18:46:05 +0200 Subject: [PATCH 25/30] patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work Problem: Popup_setoptions(popup_getoptions()) does not work. Solution: Also accept a list with three entries for "moved" and "mousemoved". (closes #5081) --- runtime/doc/popup.txt | 7 +++++++ src/popupwin.c | 24 ++++++++++++++++++++---- src/testdir/test_popupwin.vim | 4 ++++ src/version.c | 2 ++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/runtime/doc/popup.txt b/runtime/doc/popup.txt index a438ce64e9..d1dfd86a16 100644 --- a/runtime/doc/popup.txt +++ b/runtime/doc/popup.txt @@ -474,6 +474,8 @@ popup_notification({what}, {options}) *popup_notification()* popup_show({id}) *popup_show()* If {id} is a hidden popup, show it now. For {id} see `popup_hide()`. + If {id} is the info popup it will be positioned next to the + current popup menu item. popup_setoptions({id}, {options}) *popup_setoptions()* @@ -680,8 +682,13 @@ The second argument of |popup_create()| is a dictionary with options: - "expr": if the cursor moved outside || - [{start}, {end}]: if the cursor moved before column {start} or after {end} + - [{lnum}, {start}, {end}]: if the cursor moved away + from line {lnum}, before column {start} or after + {end} The popup also closes if the cursor moves to another line or to another window. + mousemoved Like "moved" but referring to the mouse pointer + position cursorline non-zero: Highlight the cursor line. Also scrolls the text to show this line (only works properly when 'wrap' is off). diff --git a/src/popupwin.c b/src/popupwin.c index 95435f8fe7..a9579320e8 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -493,12 +493,28 @@ handle_moved_argument(win_T *wp, dictitem_T *di, int mousemoved) } else if (di->di_tv.v_type == VAR_LIST && di->di_tv.vval.v_list != NULL - && di->di_tv.vval.v_list->lv_len == 2) + && (di->di_tv.vval.v_list->lv_len == 2 + || di->di_tv.vval.v_list->lv_len == 3)) { - list_T *l = di->di_tv.vval.v_list; - int mincol = tv_get_number(&l->lv_first->li_tv); - int maxcol = tv_get_number(&l->lv_first->li_next->li_tv); + list_T *l = di->di_tv.vval.v_list; + listitem_T *li = l->lv_first; + int mincol; + int maxcol; + if (di->di_tv.vval.v_list->lv_len == 3) + { + varnumber_T nr = tv_get_number(&l->lv_first->li_tv); + + // Three numbers, might be from popup_getoptions(). + if (mousemoved) + wp->w_popup_mouse_row = nr; + else + wp->w_popup_lnum = nr; + li = li->li_next; + } + + mincol = tv_get_number(&li->li_tv); + maxcol = tv_get_number(&li->li_next->li_tv); if (mousemoved) { wp->w_popup_mouse_mincol = mincol; diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index 2e2d1df80e..dc382d83b5 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -170,6 +170,10 @@ func Test_popup_with_border_and_padding() call assert_equal(['Top', 'Right', 'Bottom', 'Left'], options.borderhighlight) call assert_equal(['1', '^', '2', '>', '3', 'v', '4', '<'], options.borderchars) + " Check that popup_setoptions() takes the output of popup_getoptions() + call popup_setoptions(winid, options) + call assert_equal(options, popup_getoptions(winid)) + let winid = popup_create('hello both', #{line: 3, col: 8, border: [], padding: []}) call assert_equal(#{ \ line: 3, diff --git a/src/version.c b/src/version.c index 76b4c1cf52..6c8a36b219 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2193, /**/ 2192, /**/ From 4b57018ee4e6d608e3a28e0ee4fdd2f057cc0e89 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 20 Oct 2019 19:53:22 +0200 Subject: [PATCH 26/30] patch 8.1.2194: modifyOtherKeys is not enabled by default Problem: ModifyOtherKeys is not enabled by default. Solution: Add t_TI and t_TE to the builtin xterm termcap. --- runtime/doc/map.txt | 32 ++++++++++++++++++++++++++++++-- src/term.c | 2 ++ src/version.c | 2 ++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index bdf5e97554..daa1cf2cc7 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -20,7 +20,8 @@ manual. 1.8 Examples |map-examples| 1.9 Using mappings |map-typing| 1.10 Mapping alt-keys |:map-alt-keys| - 1.11 Mapping an operator |:map-operator| + 1.11 Mapping in modifyOtherKeys mode |modifyOtherKeys| + 1.12 Mapping an operator |:map-operator| 2. Abbreviations |abbreviations| 3. Local mappings and functions |script-local| 4. User-defined commands |user-commands| @@ -777,6 +778,9 @@ In the GUI Vim handles the Alt key itself, thus mapping keys with ALT should always work. But in a terminal Vim gets a sequence of bytes and has to figure out whether ALT was pressed or not. +If the terminal supports the modifyOtherKeys mode and it has been enabled, +then Vim can recognize more key combinations, see |modifyOtherKeys| below. + By default Vim assumes that pressing the ALT key sets the 8th bit of a typed character. Most decent terminals can work that way, such as xterm, aterm and rxvt. If your mappings don't work it might be that the terminal is @@ -814,7 +818,31 @@ on the terminal; that's a good last resource in case you want to send ESC when using other applications but not when inside Vim. -1.11 MAPPING AN OPERATOR *:map-operator* +1.11 MAPPING IN modifyOtherKeys mode *modifyOtherKeys* + +Xterm and a few other terminals can be put in a mode where keys with modifiers +are sent with a special escape code. Vim recognizes these codes and can then +make a difference between CTRL-H and Backspace, even when Backspace sends the +character 8. And many more special keys. + +For xterm modifyOtherKeys is enabled in the builtin termcap entry. If this is +not used you can enable modifyOtherKeys with these lines in your vimrc: > + let &t_TI = "\[>4;2m" + let &t_TE = "\[>4;m" + +In case the modifyOtherKeys mode causes problems you can disable it: > + let &t_TI = "" + let &t_TE = "" +It does not take effect immediately. To have this work without restarting Vim +execute a shell command, e.g.: `!ls` + +A known side effect effect is that in Insert mode the raw escape sequence is +inserted after the CTRL-V key. This can be used to check whether +modifyOtherKeys is enabled: In Insert mode type CTRL-V CTRL-V, if you get +one byte then modifyOtherKeys is off, if you get <1b>27;5;118~ then it is on. + + +1.12 MAPPING AN OPERATOR *:map-operator* An operator is used before a {motion} command. To define your own operator you must create mapping that first sets the 'operatorfunc' option and then diff --git a/src/term.c b/src/term.c index fa4375e4e8..afdd482e38 100644 --- a/src/term.c +++ b/src/term.c @@ -912,6 +912,8 @@ static struct builtin_term builtin_termcaps[] = {(int)KS_TE, IF_EB("\033[2J\033[?47l\0338", ESC_STR "[2J" ESC_STR_nc "[?47l" ESC_STR_nc "8")}, # endif + {(int)KS_CTI, IF_EB("\033[>4;2m", ESC_STR_nc "[>4;2m")}, + {(int)KS_CTE, IF_EB("\033[>4;m", ESC_STR_nc "[>4;m")}, {(int)KS_CIS, IF_EB("\033]1;", ESC_STR "]1;")}, {(int)KS_CIE, "\007"}, {(int)KS_TS, IF_EB("\033]2;", ESC_STR "]2;")}, diff --git a/src/version.c b/src/version.c index 6c8a36b219..38696fa453 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2194, /**/ 2193, /**/ From 4d14bac8e7441368977e81266166f728105a60d4 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 20 Oct 2019 21:15:15 +0200 Subject: [PATCH 27/30] patch 8.1.2195: Vim does not exit when the terminal window is last window Problem: Vim does not exit when closing a terminal window and it is the last window. Solution: Exit Vim if the closed terminal window is the last one. (closes #4539) --- runtime/doc/terminal.txt | 7 +++++++ src/ex_docmd.c | 4 ++-- src/proto/ex_docmd.pro | 9 ++++----- src/terminal.c | 10 ++++++++++ src/testdir/test_terminal.vim | 26 ++++++++++++++++++++++++++ src/version.c | 2 ++ 6 files changed, 51 insertions(+), 7 deletions(-) diff --git a/runtime/doc/terminal.txt b/runtime/doc/terminal.txt index fc5031dd46..6bf04eb830 100644 --- a/runtime/doc/terminal.txt +++ b/runtime/doc/terminal.txt @@ -193,6 +193,7 @@ Command syntax ~ Supported [options] are: ++close The terminal window will close automatically when the job terminates. + |terminal-close| ++noclose The terminal window will NOT close automatically when the job terminates. ++open When the job terminates and no window @@ -267,6 +268,12 @@ hidden, the job keeps running. The `:buffer` command can be used to turn the current window into a terminal window. If there are unsaved changes this fails, use ! to force, as usual. + *terminal-close* +When the terminal window is closed, e.g. when the shell exits and "++close" +argument was used, and this is the last normal Vim window, then Vim will exit. +This is like using |:quit| in a normal window. Help and preview windows are +not counted. + To have a background job run without a window, and open the window when it's done, use options like this: > :term ++hidden ++open make diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 1d0476946d..d9fe7de75e 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -87,7 +87,6 @@ static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep); static char_u *repl_cmdline(exarg_T *eap, char_u *src, int srclen, char_u *repl, char_u **cmdlinep); static void ex_highlight(exarg_T *eap); static void ex_colorscheme(exarg_T *eap); -static void ex_quit(exarg_T *eap); static void ex_cquit(exarg_T *eap); static void ex_quit_all(exarg_T *eap); static void ex_close(exarg_T *eap); @@ -4842,8 +4841,9 @@ before_quit_autocmds(win_T *wp, int quit_all, int forceit) /* * ":quit": quit current window, quit Vim if the last window is closed. * ":{nr}quit": quit window {nr} + * Also used when closing a terminal window that's the last one. */ - static void + void ex_quit(exarg_T *eap) { win_T *wp; diff --git a/src/proto/ex_docmd.pro b/src/proto/ex_docmd.pro index cc64ac8820..f5942f5c1a 100644 --- a/src/proto/ex_docmd.pro +++ b/src/proto/ex_docmd.pro @@ -15,13 +15,14 @@ char_u *skip_range(char_u *cmd, int *ctx); void ex_ni(exarg_T *eap); int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp); void separate_nextcmd(exarg_T *eap); -char_u *skip_cmd_arg( char_u *p, int rembs); +char_u *skip_cmd_arg(char_u *p, int rembs); int get_bad_opt(char_u *p, exarg_T *eap); int ends_excmd(int c); char_u *find_nextcmd(char_u *p); char_u *check_nextcmd(char_u *p); char_u *get_command_name(expand_T *xp, int idx); void not_exiting(void); +void ex_quit(exarg_T *eap); void tabpage_close(int forceit); void tabpage_close_other(tabpage_T *tp, int forceit); void handle_drop(int filec, char_u **filev, int split, void (*callback)(void *), void *cookie); @@ -30,8 +31,8 @@ void ex_splitview(exarg_T *eap); void tabpage_new(void); void do_exedit(exarg_T *eap, win_T *old_curwin); void free_cd_dir(void); -void post_chdir(cdscope_T cdscope); -int changedir_func(char_u *new_dir, int forceit, cdscope_T cdscope); +void post_chdir(cdscope_T scope); +int changedir_func(char_u *new_dir, int forceit, cdscope_T scope); void ex_cd(exarg_T *eap); void do_sleep(long msec); void ex_may_print(exarg_T *eap); @@ -47,8 +48,6 @@ void exec_normal(int was_typed, int use_vpeekc, int may_use_terminal_loop); int find_cmdline_var(char_u *src, int *usedlen); char_u *eval_vars(char_u *src, char_u *srcstart, int *usedlen, linenr_T *lnump, char **errormsg, int *escaped); char_u *expand_sfile(char_u *arg); -int put_eol(FILE *fd); -int put_line(FILE *fd, char *s); void dialog_msg(char_u *buff, char *format, char_u *fname); void set_no_hlsearch(int flag); int is_loclist_cmd(int cmdidx); diff --git a/src/terminal.c b/src/terminal.c index 7b2d43bf25..07b2e973e0 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -3073,6 +3073,16 @@ term_after_channel_closed(term_T *term) aco_save_T aco; int do_set_w_closing = term->tl_buffer->b_nwindows == 0; + // If this is the last normal window: exit Vim. + if (term->tl_buffer->b_nwindows > 0 && only_one_window()) + { + exarg_T ea; + + vim_memset(&ea, 0, sizeof(ea)); + ex_quit(&ea); + return TRUE; + } + // ++close or term_finish == "close" ch_log(NULL, "terminal job finished, closing window"); aucmd_prepbuf(&aco, term->tl_buffer); diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index c4d3e528c6..f506a39f68 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -1051,6 +1051,32 @@ func Test_terminal_qall_prompt() quit endfunc +" Run Vim in a terminal, then start a terminal window with a shell and check +" that Vim exits if it is closed. +func Test_terminal_exit() + CheckRunVimInTerminal + + let lines =<< trim END + let winid = win_getid() + help + term + let termid = win_getid() + call win_gotoid(winid) + close + call win_gotoid(termid) + END + call writefile(lines, 'XtermExit') + let buf = RunVimInTerminal('-S XtermExit', #{rows: 10}) + let job = term_getjob(buf) + call WaitForAssert({-> assert_equal("run", job_status(job))}) + + " quit the shell, it will make Vim exit + call term_sendkeys(buf, "exit\") + call WaitForAssert({-> assert_equal("dead", job_status(job))}) + + call delete('XtermExit') +endfunc + func Test_terminal_open_autocmd() augroup repro au! diff --git a/src/version.c b/src/version.c index 38696fa453..c378c1bba7 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2195, /**/ 2194, /**/ From d53ebfc6246b2f29752adbda13cd2c11acca285a Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 20 Oct 2019 21:47:20 +0200 Subject: [PATCH 28/30] patch 8.1.2196: MS-Windows: running tests with MSVC lacks updates Problem: MS-Windows: running tests with MSVC lacks updates. Solution: Improve running individual tests on MS-Windows. (closes #4922) --- src/Make_mvc.mak | 33 +++++++++++++++++++++++++++------ src/testdir/Make_dos.mak | 11 +++++++++-- src/version.c | 2 ++ 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak index 2a0a1a1dae..11058086be 100644 --- a/src/Make_mvc.mak +++ b/src/Make_mvc.mak @@ -1279,6 +1279,17 @@ MAIN_TARGET = $(GVIM).exe $(VIM).exe $(VIMDLLBASE).dll MAIN_TARGET = $(VIM).exe !endif +# Target to run individual tests. +VIMTESTTARGET = $(VIM).exe + +OLD_TEST_OUTFILES = \ + $(SCRIPTS_FIRST) \ + $(SCRIPTS_ALL) \ + $(SCRIPTS_MORE1) \ + $(SCRIPTS_MORE4) \ + $(SCRIPTS_WIN32) \ + $(SCRIPTS_GUI) + all: $(MAIN_TARGET) \ vimrun.exe \ install.exe \ @@ -1370,7 +1381,7 @@ tags: notags notags: - if exist tags del tags -clean: +clean: testclean - if exist $(OUTDIR)/nul $(DEL_TREE) $(OUTDIR) - if exist *.obj del *.obj - if exist $(VIM).exe del $(VIM).exe @@ -1405,7 +1416,6 @@ clean: cd GvimExt $(MAKE) /NOLOGO -f Makefile clean cd .. - - if exist testdir\*.out del testdir\*.out test: cd testdir @@ -1422,13 +1432,24 @@ testclean: $(MAKE) /NOLOGO -f Make_dos.mak clean cd .. +# Run individual OLD style test. +# These do not depend on the executable, compile it when needed. +$(OLD_TEST_OUTFILES:.out=): + cd testdir + - if exist $@.out del $@.out + $(MAKE) /NOLOGO -f Make_dos.mak VIMPROG=..\$(VIMTESTTARGET) nolog + $(MAKE) /NOLOGO -f Make_dos.mak VIMPROG=..\$(VIMTESTTARGET) $@.out + @ if exist test.log ( type test.log & exit /b 1 ) + cd .. + +# Run individual NEW style test. +# These do not depend on the executable, compile it when needed. $(NEW_TESTS): cd testdir - if exist $@.res del $@.res - $(MAKE) /NOLOGO -f Make_dos.mak nolog - $(MAKE) /NOLOGO -f Make_dos.mak $@.res - $(MAKE) /NOLOGO -f Make_dos.mak report - type messages + $(MAKE) /NOLOGO -f Make_dos.mak VIMPROG=..\$(VIMTESTTARGET) nolog + $(MAKE) /NOLOGO -f Make_dos.mak VIMPROG=..\$(VIMTESTTARGET) $@.res + $(MAKE) /NOLOGO -f Make_dos.mak VIMPROG=..\$(VIMTESTTARGET) report cd .. ########################################################################### diff --git a/src/testdir/Make_dos.mak b/src/testdir/Make_dos.mak index eda1a521cd..7aec010c89 100644 --- a/src/testdir/Make_dos.mak +++ b/src/testdir/Make_dos.mak @@ -69,9 +69,14 @@ $(TEST_OUTFILES): $(DOSTMP)\$(*B).in $(SCRIPTS) $(SCRIPTS_GUI) $(SCRIPTS_WIN32) $(NEW_TESTS_RES): $(SCRIPTS_FIRST) report: - @echo "" + @rem without the +eval feature test_result.log is a copy of test.log + @if exist test.log ( copy /y test.log test_result.log > nul ) \ + else ( echo No failures reported > test_result.log ) + $(VIMPROG) -u NONE $(NO_INITS) -S summarize.vim messages + @echo. @echo Test results: - @if exist test.log ( type test.log & echo TEST FAILURE & exit /b 1 ) \ + @type test_result.log + @if exist test.log ( echo TEST FAILURE & exit /b 1 ) \ else ( echo ALL DONE ) clean: @@ -92,12 +97,14 @@ clean: -for /d %i in (X*) do @rmdir /s/q %i -if exist viminfo del viminfo -if exist test.log del test.log + -if exist test_result.log del test_result.log -if exist messages del messages -if exist benchmark.out del benchmark.out -if exist opt_test.vim del opt_test.vim nolog: -if exist test.log del test.log + -if exist test_result.log del test_result.log -if exist messages del messages benchmark: diff --git a/src/version.c b/src/version.c index c378c1bba7..f2a8d6ca91 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2196, /**/ 2195, /**/ From 34ba06b6e6f94bb46062e6c85dbfdcbb0d255ada Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 20 Oct 2019 22:27:10 +0200 Subject: [PATCH 29/30] patch 8.1.2197: ExitPre autocommand may cause accessing freed memory Problem: ExitPre autocommand may cause accessing freed memory. Solution: Check the window pointer is still valid. (closes #5093) --- src/ex_docmd.c | 13 +++++++------ src/testdir/test_exit.vim | 22 ++++++++++++++++++++++ src/version.c | 2 ++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/ex_docmd.c b/src/ex_docmd.c index d9fe7de75e..385cf3b4ae 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -4817,9 +4817,9 @@ before_quit_autocmds(win_T *wp, int quit_all, int forceit) { apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, wp->w_buffer); - /* Bail out when autocommands closed the window. - * Refuse to quit when the buffer in the last window is being closed (can - * only happen in autocommands). */ + // Bail out when autocommands closed the window. + // Refuse to quit when the buffer in the last window is being closed (can + // only happen in autocommands). if (!win_valid(wp) || curbuf_locked() || (wp->w_buffer->b_nwindows == 1 && wp->w_buffer->b_locked > 0)) @@ -4828,9 +4828,10 @@ before_quit_autocmds(win_T *wp, int quit_all, int forceit) if (quit_all || (check_more(FALSE, forceit) == OK && only_one_window())) { apply_autocmds(EVENT_EXITPRE, NULL, NULL, FALSE, curbuf); - /* Refuse to quit when locked or when the buffer in the last window is - * being closed (can only happen in autocommands). */ - if (curbuf_locked() + // Refuse to quit when locked or when the window was closed or the + // buffer in the last window is being closed (can only happen in + // autocommands). + if (!win_valid(wp) || curbuf_locked() || (curbuf->b_nwindows == 1 && curbuf->b_locked > 0)) return TRUE; } diff --git a/src/testdir/test_exit.vim b/src/testdir/test_exit.vim index 3797626abf..99a401d4a4 100644 --- a/src/testdir/test_exit.vim +++ b/src/testdir/test_exit.vim @@ -40,6 +40,7 @@ func Test_exiting() endif call delete('Xtestout') + " ExitPre autocommand splits the window, so that it's no longer the last one. let after =<< trim [CODE] au QuitPre * call writefile(["QuitPre"], "Xtestout", "a") au ExitPre * call writefile(["ExitPre"], "Xtestout", "a") @@ -58,4 +59,25 @@ func Test_exiting() \ readfile('Xtestout')) endif call delete('Xtestout') + + " ExitPre autocommand splits and closes the window, so that there is still + " one window but it's a different one. + let after =<< trim [CODE] + au QuitPre * call writefile(["QuitPre"], "Xtestout", "a") + au ExitPre * call writefile(["ExitPre"], "Xtestout", "a") + augroup nasty + au ExitPre * split | only + augroup END + quit + augroup nasty + au! ExitPre + augroup END + quit + [CODE] + + if RunVim([], after, '') + call assert_equal(['QuitPre', 'ExitPre', 'QuitPre', 'ExitPre'], + \ readfile('Xtestout')) + endif + call delete('Xtestout') endfunc diff --git a/src/version.c b/src/version.c index f2a8d6ca91..549b7eea7e 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2197, /**/ 2196, /**/ From 396b7c78c0fd9cd07528963b18c27398491df40d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 21 Oct 2019 23:08:59 +0200 Subject: [PATCH 30/30] patch 8.1.2198: crash when using :center in autocommand Problem: Crash when using :center in autocommand. Solution: Bail out early for an empty line. (Dominique pelle, closes #5095) --- src/ex_cmds.c | 13 +++++++++---- src/testdir/test_textformat.vim | 20 ++++++++++++++++++++ src/version.c | 2 ++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/ex_cmds.c b/src/ex_cmds.c index bcff7ee716..e472c8a6fc 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -251,18 +251,23 @@ linelen(int *has_tab) int save; int len; - /* find the first non-blank character */ + // Get the line. If it's empty bail out early (could be the empty string + // for an unloaded buffer). line = ml_get_curline(); + if (*line == NUL) + return 0; + + // find the first non-blank character first = skipwhite(line); - /* find the character after the last non-blank character */ + // find the character after the last non-blank character for (last = first + STRLEN(first); last > first && VIM_ISWHITE(last[-1]); --last) ; save = *last; *last = NUL; - len = linetabsize(line); /* get line length */ - if (has_tab != NULL) /* check for embedded TAB */ + len = linetabsize(line); // get line length + if (has_tab != NULL) // check for embedded TAB *has_tab = (vim_strchr(first, TAB) != NULL); *last = save; diff --git a/src/testdir/test_textformat.vim b/src/testdir/test_textformat.vim index 13fb50b985..3a0552b834 100644 --- a/src/testdir/test_textformat.vim +++ b/src/testdir/test_textformat.vim @@ -1,4 +1,7 @@ " Tests for the various 'formatoptions' settings + +source check.vim + func Test_text_format() enew! @@ -489,3 +492,20 @@ func Test_format_list_auto() bwipe! set fo& ai& bs& endfunc + +func Test_crash_github_issue_5095() + CheckFeature autocmd + + " This used to segfault, see https://github.com/vim/vim/issues/5095 + augroup testing + au BufNew x center + augroup END + + next! x + + bw + augroup testing + au! + augroup END + augroup! testing +endfunc diff --git a/src/version.c b/src/version.c index 549b7eea7e..77e6e35bec 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2198, /**/ 2197, /**/