diff --git a/runtime/autoload/dist/script.vim b/runtime/autoload/dist/script.vim index b926f31566..86070a0af9 100644 --- a/runtime/autoload/dist/script.vim +++ b/runtime/autoload/dist/script.vim @@ -189,6 +189,10 @@ def DetectFromHashBang(firstline: string) elseif name =~ 'gforth\>' set ft=forth + # Icon + elseif name =~ 'icon\>' + set ft=icon + endif enddef diff --git a/src/channel.c b/src/channel.c index 9a34575d40..30a6b53cc0 100644 --- a/src/channel.c +++ b/src/channel.c @@ -5338,7 +5338,7 @@ f_ch_info(typval_T *argvars, typval_T *rettv UNUSED) return; channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0); - if (channel != NULL && rettv_dict_alloc(rettv) != FAIL) + if (channel != NULL && rettv_dict_alloc(rettv) == OK) channel_info(channel, rettv->vval.v_dict); } diff --git a/src/cmdexpand.c b/src/cmdexpand.c index 13ba741f0e..8a079419dd 100644 --- a/src/cmdexpand.c +++ b/src/cmdexpand.c @@ -3766,7 +3766,7 @@ f_getcompletion(typval_T *argvars, typval_T *rettv) else pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context); - if ((rettv_list_alloc(rettv) != FAIL) && (pat != NULL)) + if (rettv_list_alloc(rettv) == OK && pat != NULL) { int i; diff --git a/src/digraph.c b/src/digraph.c index c33fc30251..f37292fcd1 100644 --- a/src/digraph.c +++ b/src/digraph.c @@ -2567,7 +2567,7 @@ ex_loadkeymap(exarg_T *eap) vim_snprintf((char *)buf, sizeof(buf), " %s %s", ((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].from, ((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].to); - (void)do_map(2, buf, MODE_LANGMAP, FALSE); + (void)do_map(MAPTYPE_NOREMAP, buf, MODE_LANGMAP, FALSE); } p_cpo = save_cpo; @@ -2598,7 +2598,7 @@ keymap_unload(void) for (i = 0; i < curbuf->b_kmap_ga.ga_len; ++i) { vim_snprintf((char *)buf, sizeof(buf), " %s", kp[i].from); - (void)do_map(1, buf, MODE_LANGMAP, FALSE); + (void)do_map(MAPTYPE_UNMAP, buf, MODE_LANGMAP, FALSE); } keymap_clear(&curbuf->b_kmap_ga); diff --git a/src/evalbuffer.c b/src/evalbuffer.c index 7de7271770..0808c7e6a2 100644 --- a/src/evalbuffer.c +++ b/src/evalbuffer.c @@ -680,7 +680,7 @@ f_getbufinfo(typval_T *argvars, typval_T *rettv) int sel_bufloaded = FALSE; int sel_bufmodified = FALSE; - if (rettv_list_alloc(rettv) != OK) + if (rettv_list_alloc(rettv) == FAIL) return; if (in_vim9script() diff --git a/src/evalfunc.c b/src/evalfunc.c index c27087f683..7251a4d692 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -3732,7 +3732,7 @@ f_environ(typval_T *argvars UNUSED, typval_T *rettv) extern char **environ; # endif - if (rettv_dict_alloc(rettv) != OK) + if (rettv_dict_alloc(rettv) == FAIL) return; # ifdef MSWIN @@ -4159,7 +4159,7 @@ f_expand(typval_T *argvars, typval_T *rettv) emsg(errormsg); if (rettv->v_type == VAR_LIST) { - if (rettv_list_alloc(rettv) != FAIL && result != NULL) + if (rettv_list_alloc(rettv) == OK && result != NULL) list_append_string(rettv->vval.v_list, result, -1); vim_free(result); } @@ -4182,7 +4182,7 @@ f_expand(typval_T *argvars, typval_T *rettv) if (rettv->v_type == VAR_STRING) rettv->vval.v_string = ExpandOne(&xpc, s, NULL, options, WILD_ALL); - else if (rettv_list_alloc(rettv) != FAIL) + else if (rettv_list_alloc(rettv) == OK) { int i; @@ -4784,7 +4784,7 @@ f_getchangelist(typval_T *argvars, typval_T *rettv) dict_T *d; int changelistindex; - if (rettv_list_alloc(rettv) != OK) + if (rettv_list_alloc(rettv) == FAIL) return; if (in_vim9script() && check_for_opt_buffer_arg(argvars, 0) == FAIL) @@ -4929,7 +4929,7 @@ f_getcharpos(typval_T *argvars UNUSED, typval_T *rettv) static void f_getcharsearch(typval_T *argvars UNUSED, typval_T *rettv) { - if (rettv_dict_alloc(rettv) != FAIL) + if (rettv_dict_alloc(rettv) == OK) { dict_T *dict = rettv->vval.v_dict; @@ -5016,7 +5016,7 @@ f_getjumplist(typval_T *argvars, typval_T *rettv) list_T *l; dict_T *d; - if (rettv_list_alloc(rettv) != OK) + if (rettv_list_alloc(rettv) == FAIL) return; if (in_vim9script() @@ -5221,7 +5221,7 @@ f_gettagstack(typval_T *argvars, typval_T *rettv) { win_T *wp = curwin; // default is current window - if (rettv_dict_alloc(rettv) != OK) + if (rettv_dict_alloc(rettv) == FAIL) return; if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL) @@ -7879,7 +7879,7 @@ f_printf(typval_T *argvars, typval_T *rettv) static void f_pum_getpos(typval_T *argvars UNUSED, typval_T *rettv UNUSED) { - if (rettv_dict_alloc(rettv) != OK) + if (rettv_dict_alloc(rettv) == FAIL) return; pum_set_event_info(rettv->vval.v_dict); } @@ -8168,7 +8168,7 @@ f_range(typval_T *argvars, typval_T *rettv) varnumber_T stride = 1; int error = FALSE; - if (rettv_list_alloc(rettv) != OK) + if (rettv_list_alloc(rettv) == FAIL) return; if (in_vim9script() @@ -9010,6 +9010,10 @@ do_searchpair( if (skip != NULL) use_skip = eval_expr_valid_arg(skip); +#ifdef FEAT_RELTIME + if (time_limit > 0) + init_regexp_timeout(time_limit); +#endif save_cursor = curwin->w_cursor; pos = curwin->w_cursor; CLEAR_POS(&firstpos); @@ -9021,9 +9025,6 @@ do_searchpair( CLEAR_FIELD(sia); sia.sa_stop_lnum = lnum_stop; -#ifdef FEAT_RELTIME - sia.sa_tm = time_limit; -#endif n = searchit(curwin, curbuf, &pos, NULL, dir, pat, 1L, options, RE_SEARCH, &sia); if (n == FAIL || (firstpos.lnum != 0 && EQUAL_POS(pos, firstpos))) @@ -9109,6 +9110,9 @@ do_searchpair( curwin->w_cursor = save_cursor; theend: +#ifdef FEAT_RELTIME + disable_regexp_timeout(); +#endif vim_free(pat2); vim_free(pat3); if (p_cpo == empty_option) @@ -10232,7 +10236,7 @@ f_synconcealed(typval_T *argvars UNUSED, typval_T *rettv) CLEAR_FIELD(str); - if (rettv_list_alloc(rettv) != FAIL) + if (rettv_list_alloc(rettv) == OK) { if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count && col >= 0 && col <= (long)STRLEN(ml_get(lnum)) @@ -10293,7 +10297,7 @@ f_synstack(typval_T *argvars UNUSED, typval_T *rettv) if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count && col >= 0 && col <= (long)STRLEN(ml_get(lnum)) - && rettv_list_alloc(rettv) != FAIL) + && rettv_list_alloc(rettv) == OK) { (void)syn_get_id(curwin, lnum, col, FALSE, NULL, TRUE); for (i = 0; ; ++i) @@ -10328,7 +10332,7 @@ f_tabpagebuflist(typval_T *argvars UNUSED, typval_T *rettv UNUSED) if (tp != NULL) wp = (tp == curtab) ? firstwin : tp->tp_firstwin; } - if (wp != NULL && rettv_list_alloc(rettv) != FAIL) + if (wp != NULL && rettv_list_alloc(rettv) == OK) { for (; wp != NULL; wp = wp->w_next) if (list_append_number(rettv->vval.v_list, diff --git a/src/evalwindow.c b/src/evalwindow.c index 20ac66f533..00d63cd365 100644 --- a/src/evalwindow.c +++ b/src/evalwindow.c @@ -471,7 +471,7 @@ f_gettabinfo(typval_T *argvars, typval_T *rettv) dict_T *d; int tpnr = 0; - if (rettv_list_alloc(rettv) != OK) + if (rettv_list_alloc(rettv) == FAIL) return; if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL) @@ -510,7 +510,7 @@ f_getwininfo(typval_T *argvars, typval_T *rettv) dict_T *d; short tabnr = 0, winnr; - if (rettv_list_alloc(rettv) != OK) + if (rettv_list_alloc(rettv) == FAIL) return; if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL) @@ -779,7 +779,7 @@ f_win_findbuf(typval_T *argvars, typval_T *rettv) if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL) return; - if (rettv_list_alloc(rettv) != FAIL) + if (rettv_list_alloc(rettv) == OK) win_findbuf(argvars, rettv->vval.v_list); } @@ -847,7 +847,7 @@ f_win_id2tabwin(typval_T *argvars, typval_T *rettv) if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL) return; - if (rettv_list_alloc(rettv) != FAIL) + if (rettv_list_alloc(rettv) == OK) win_id2tabwin(argvars, rettv->vval.v_list); } @@ -1143,7 +1143,7 @@ f_winlayout(typval_T *argvars, typval_T *rettv) { tabpage_T *tp; - if (rettv_list_alloc(rettv) != OK) + if (rettv_list_alloc(rettv) == FAIL) return; if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL) diff --git a/src/ex_getln.c b/src/ex_getln.c index f02029fc2d..4d47dcbf4d 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -4475,8 +4475,8 @@ open_cmdwin(void) { if (p_wc == TAB) { - add_map((char_u *)" ", MODE_INSERT); - add_map((char_u *)" a", MODE_NORMAL); + add_map((char_u *)" ", MODE_INSERT, TRUE); + add_map((char_u *)" a", MODE_NORMAL, TRUE); } set_option_value_give_err((char_u *)"ft", 0L, (char_u *)"vim", OPT_LOCAL); diff --git a/src/gui.c b/src/gui.c index a7ccd808ff..712e5709ef 100644 --- a/src/gui.c +++ b/src/gui.c @@ -226,6 +226,11 @@ gui_do_fork(void) int exit_status; pid_t pid = -1; +#if defined(FEAT_RELTIME) && defined(HAVE_TIMER_CREATE) + // a timer is not carried forward + delete_timer(); +#endif + // Setup a pipe between the child and the parent, so that the parent // knows when the child has done the setsid() call and is allowed to // exit. diff --git a/src/indent.c b/src/indent.c index 73eb12c49b..794fa2c343 100644 --- a/src/indent.c +++ b/src/indent.c @@ -1612,6 +1612,20 @@ copy_indent(int size, char_u *src) return TRUE; } +/* + * Give a "resulting text too long" error and maybe set got_int. + */ + static void +emsg_text_too_long(void) +{ + emsg(_(e_resulting_text_too_long)); +#ifdef FEAT_EVAL + // when not inside a try/catch set got_int to break out of any loop + if (trylevel == 0) +#endif + got_int = TRUE; +} + /* * ":retab". */ @@ -1749,7 +1763,7 @@ ex_retab(exarg_T *eap) new_len = old_len - col + start_col + len + 1; if (new_len <= 0 || new_len >= MAXCOL) { - emsg(_(e_resulting_text_too_long)); + emsg_text_too_long(); break; } new_line = alloc(new_len); @@ -1780,13 +1794,7 @@ ex_retab(exarg_T *eap) vcol += chartabsize(ptr + col, (colnr_T)vcol); if (vcol >= MAXCOL) { - emsg(_(e_resulting_text_too_long)); - // when not inside a try/catch set got_int to break out of any - // loop -#ifdef FEAT_EVAL - if (trylevel == 0) -#endif - got_int = TRUE; + emsg_text_too_long(); break; } if (has_mbyte) diff --git a/src/insexpand.c b/src/insexpand.c index 2e7db6b4b2..9d5a2cb21b 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -3093,7 +3093,7 @@ f_complete_info(typval_T *argvars, typval_T *rettv) { list_T *what_list = NULL; - if (rettv_dict_alloc(rettv) != OK) + if (rettv_dict_alloc(rettv) == FAIL) return; if (in_vim9script() && check_for_opt_list_arg(argvars, 0) == FAIL) diff --git a/src/job.c b/src/job.c index a29f9f0204..b3c6a49768 100644 --- a/src/job.c +++ b/src/job.c @@ -1905,7 +1905,7 @@ f_job_info(typval_T *argvars, typval_T *rettv) job_T *job; job = get_job_arg(&argvars[0]); - if (job != NULL && rettv_dict_alloc(rettv) != FAIL) + if (job != NULL && rettv_dict_alloc(rettv) == OK) job_info(job, rettv->vval.v_dict); } else if (rettv_list_alloc(rettv) == OK) diff --git a/src/list.c b/src/list.c index b9a347836b..10a7aacd35 100644 --- a/src/list.c +++ b/src/list.c @@ -1762,7 +1762,7 @@ list_remove(typval_T *argvars, typval_T *rettv, char_u *arg_errmsg) } vimlist_remove(l, item, item2); - if (rettv_list_alloc(rettv) != OK) + if (rettv_list_alloc(rettv) == FAIL) return; rl = rettv->vval.v_list; diff --git a/src/main.c b/src/main.c index e6a5e96bb7..b98c1db3fc 100644 --- a/src/main.c +++ b/src/main.c @@ -1489,7 +1489,7 @@ main_loop( update_screen(0); mch_enable_flush(); } - else if (redraw_cmdline || clear_cmdline) + else if (redraw_cmdline || clear_cmdline || redraw_mode) showmode(); redraw_statuslines(); if (need_maketitle) diff --git a/src/map.c b/src/map.c index 594ccbceda..fe77b711de 100644 --- a/src/map.c +++ b/src/map.c @@ -293,7 +293,9 @@ map_add( * noreabbr {lhs} {rhs} : same, but no remapping for {rhs} * unabbr {lhs} : remove abbreviation for {lhs} * - * maptype: 0 for :map, 1 for :unmap, 2 for noremap. + * maptype: MAPTYPE_MAP for :map + * MAPTYPE_UNMAP for :unmap + * MAPTYPE_NOREMAP for noremap * * arg is pointer to any arguments. Note: arg cannot be a read-only string, * it will be modified. @@ -360,7 +362,7 @@ do_map( abbr_table = &first_abbr; // For ":noremap" don't remap, otherwise do remap. - if (maptype == 2) + if (maptype == MAPTYPE_NOREMAP) noremap = REMAP_NONE; else noremap = REMAP_YES; @@ -436,7 +438,7 @@ do_map( // with :unmap white space is included in the keys, no argument possible. p = keys; do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); - while (*p && (maptype == 1 || !VIM_ISWHITE(*p))) + while (*p && (maptype == MAPTYPE_UNMAP || !VIM_ISWHITE(*p))) { if ((p[0] == Ctrl_V || (do_backslash && p[0] == '\\')) && p[1] != NUL) @@ -450,10 +452,10 @@ do_map( rhs = p; hasarg = (*rhs != NUL); haskey = (*keys != NUL); - do_print = !haskey || (maptype != 1 && !hasarg); + do_print = !haskey || (maptype != MAPTYPE_UNMAP && !hasarg); // check for :unmap without argument - if (maptype == 1 && !haskey) + if (maptype == MAPTYPE_UNMAP && !haskey) { retval = 1; goto theend; @@ -524,7 +526,7 @@ do_map( goto theend; } - if (abbrev && maptype != 1) + if (abbrev && maptype != MAPTYPE_UNMAP) { // If an abbreviation ends in a keyword character, the // rest must be all keyword-char or all non-keyword-char. @@ -580,7 +582,7 @@ do_map( // Check if a new local mapping wasn't already defined globally. if (unique && map_table == curbuf->b_maphash - && haskey && hasarg && maptype != 1) + && haskey && hasarg && maptype != MAPTYPE_UNMAP) { // need to loop over all global hash lists for (hash = 0; hash < 256 && !got_int; ++hash) @@ -615,7 +617,8 @@ do_map( } // When listing global mappings, also list buffer-local ones here. - if (map_table != curbuf->b_maphash && !hasarg && maptype != 1) + if (map_table != curbuf->b_maphash && !hasarg + && maptype != MAPTYPE_UNMAP) { // need to loop over all global hash lists for (hash = 0; hash < 256 && !got_int; ++hash) @@ -659,7 +662,7 @@ do_map( // an entry with a matching 'to' part. This was done to allow // ":ab foo bar" to be unmapped by typing ":unab foo", where "foo" will // be replaced by "bar" because of the abbreviation. - for (round = 0; (round == 0 || maptype == 1) && round <= 1 + for (round = 0; (round == 0 || maptype == MAPTYPE_UNMAP) && round <= 1 && !did_it && !got_int; ++round) { // need to loop over all hash lists @@ -704,7 +707,7 @@ do_map( } if (STRNCMP(p, keys, (size_t)(n < len ? n : len)) == 0) { - if (maptype == 1) + if (maptype == MAPTYPE_UNMAP) { // Delete entry. // Only accept a full match. For abbreviations @@ -805,7 +808,7 @@ do_map( } } - if (maptype == 1) + if (maptype == MAPTYPE_UNMAP) { // delete entry if (!did_it) @@ -2376,7 +2379,7 @@ get_maparg(typval_T *argvars, typval_T *rettv, int exact) } } - else if (rettv_dict_alloc(rettv) != FAIL && rhs != NULL) + else if (rettv_dict_alloc(rettv) == OK && rhs != NULL) mapblock2dict(mp, rettv->vval.v_dict, did_simplify ? keys_simplified : NULL, buffer_local, abbr); @@ -2406,7 +2409,7 @@ f_maplist(typval_T *argvars UNUSED, typval_T *rettv) if (argvars[0].v_type != VAR_UNKNOWN) abbr = tv_get_bool(&argvars[0]); - if (rettv_list_alloc(rettv) != OK) + if (rettv_list_alloc(rettv) == FAIL) return; validate_maphash(); @@ -2661,7 +2664,7 @@ f_mapset(typval_T *argvars, typval_T *rettv UNUSED) if (arg == NULL) return; } - do_map(1, arg, mode, is_abbr); + do_map(MAPTYPE_UNMAP, arg, mode, is_abbr); vim_free(arg); (void)map_add(map_table, abbr_table, lhsraw, rhs, orig_rhs, noremap, @@ -2769,12 +2772,12 @@ init_mappings(void) # endif { for (i = 0; i < (int)ARRAY_LENGTH(cinitmappings); ++i) - add_map(cinitmappings[i].arg, cinitmappings[i].mode); + add_map(cinitmappings[i].arg, cinitmappings[i].mode, FALSE); } # endif # if defined(FEAT_GUI_MSWIN) || defined(MACOS_X) for (i = 0; i < (int)ARRAY_LENGTH(initmappings); ++i) - add_map(initmappings[i].arg, initmappings[i].mode); + add_map(initmappings[i].arg, initmappings[i].mode, FALSE); # endif #endif } @@ -2783,10 +2786,11 @@ init_mappings(void) || defined(PROTO) /* * Add a mapping "map" for mode "mode". + * When "nore" is TRUE use MAPTYPE_NOREMAP. * Need to put string in allocated memory, because do_map() will modify it. */ void -add_map(char_u *map, int mode) +add_map(char_u *map, int mode, int nore) { char_u *s; char_u *cpo_save = p_cpo; @@ -2795,7 +2799,7 @@ add_map(char_u *map, int mode) s = vim_strsave(map); if (s != NULL) { - (void)do_map(0, s, mode, FALSE); + (void)do_map(nore ? MAPTYPE_NOREMAP : MAPTYPE_MAP, s, mode, FALSE); vim_free(s); } p_cpo = cpo_save; @@ -3002,7 +3006,8 @@ do_exmap(exarg_T *eap, int isabbrev) cmdp = eap->cmd; mode = get_map_mode(&cmdp, eap->forceit || isabbrev); - switch (do_map((*cmdp == 'n') ? 2 : (*cmdp == 'u'), + switch (do_map(*cmdp == 'n' ? MAPTYPE_NOREMAP + : *cmdp == 'u' ? MAPTYPE_UNMAP : MAPTYPE_MAP, eap->arg, mode, isabbrev)) { case 1: emsg(_(e_invalid_argument)); diff --git a/src/menu.c b/src/menu.c index 2d3c2e6ad4..e884a5321b 100644 --- a/src/menu.c +++ b/src/menu.c @@ -3327,7 +3327,7 @@ f_menu_info(typval_T *argvars, typval_T *rettv) vimmenu_T *menu; dict_T *retdict; - if (rettv_dict_alloc(rettv) != OK) + if (rettv_dict_alloc(rettv) == FAIL) return; retdict = rettv->vval.v_dict; diff --git a/src/mouse.c b/src/mouse.c index 4f463c0b4e..ef1f9e6445 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -3136,7 +3136,7 @@ f_getmousepos(typval_T *argvars UNUSED, typval_T *rettv) linenr_T lnum = 0; varnumber_T column = 0; - if (rettv_dict_alloc(rettv) != OK) + if (rettv_dict_alloc(rettv) == FAIL) return; d = rettv->vval.v_dict; diff --git a/src/move.c b/src/move.c index 5c78d6ce05..5865af8a5c 100644 --- a/src/move.c +++ b/src/move.c @@ -1298,7 +1298,7 @@ f_screenpos(typval_T *argvars UNUSED, typval_T *rettv) int row = 0; int scol = 0, ccol = 0, ecol = 0; - if (rettv_dict_alloc(rettv) != OK) + if (rettv_dict_alloc(rettv) == FAIL) return; dict = rettv->vval.v_dict; diff --git a/src/netbeans.c b/src/netbeans.c index c085f300af..dbe98e151c 100644 --- a/src/netbeans.c +++ b/src/netbeans.c @@ -2323,7 +2323,7 @@ special_keys(char_u *args) strcpy(&keybuf[i], tok); vim_snprintf(cmdbuf, sizeof(cmdbuf), "<%s> :nbkey %s", keybuf, keybuf); - do_map(0, (char_u *)cmdbuf, MODE_NORMAL, FALSE); + do_map(MAPTYPE_MAP, (char_u *)cmdbuf, MODE_NORMAL, FALSE); } tok = strtok(NULL, " "); } diff --git a/src/normal.c b/src/normal.c index 9bbf856a77..ce7721d8d7 100644 --- a/src/normal.c +++ b/src/normal.c @@ -6800,6 +6800,9 @@ nv_esc(cmdarg_T *cap) msg(_("Type :qa and press to exit Vim")); } + if (restart_edit != 0) + redraw_mode = TRUE; // remove "-- (insert) --" + // Don't reset "restart_edit" when 'insertmode' is set, it won't be // set again below when halfway a mapping. if (!p_im) diff --git a/src/os_unix.c b/src/os_unix.c index 91ed48ad2b..30525e6d59 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -8269,7 +8269,7 @@ xsmp_close(void) #endif // USE_XSMP #if defined(FEAT_RELTIME) || defined(PROTO) -# if defined(HAVE_TIMER_CREATE) +# if defined(HAVE_TIMER_CREATE) || defined(PROTO) /* * Implement timeout with timer_create() and timer_settime(). */ @@ -8353,6 +8353,19 @@ start_timeout(long msec) return &timeout_flag; } +/* + * To be used before fork/exec: delete any created timer. + */ + void +delete_timer(void) +{ + if (timer_created) + { + timer_delete(timer_id); + timer_created = FALSE; + } +} + # else /* diff --git a/src/proto/map.pro b/src/proto/map.pro index f92339f7da..5caa859214 100644 --- a/src/proto/map.pro +++ b/src/proto/map.pro @@ -22,7 +22,7 @@ void f_maparg(typval_T *argvars, typval_T *rettv); void f_mapcheck(typval_T *argvars, typval_T *rettv); void f_mapset(typval_T *argvars, typval_T *rettv); void init_mappings(void); -void add_map(char_u *map, int mode); +void add_map(char_u *map, int mode, int nore); int langmap_adjust_mb(int c); void langmap_init(void); void langmap_set(void); diff --git a/src/proto/os_unix.pro b/src/proto/os_unix.pro index 91024b104c..268f3bfb65 100644 --- a/src/proto/os_unix.pro +++ b/src/proto/os_unix.pro @@ -88,4 +88,5 @@ void xsmp_init(void); void xsmp_close(void); void stop_timeout(void); const int *start_timeout(long msec); +void delete_timer(void); /* vim: set ft=c : */ diff --git a/src/search.c b/src/search.c index e33e79c0e4..f274323c20 100644 --- a/src/search.c +++ b/src/search.c @@ -683,10 +683,10 @@ searchit( stop_lnum = extra_arg->sa_stop_lnum; #ifdef FEAT_RELTIME if (extra_arg->sa_tm > 0) - { init_regexp_timeout(extra_arg->sa_tm); - timed_out = &extra_arg->sa_timed_out; - } + // Also set the pointer when sa_tm is zero, the caller may have set the + // timeout. + timed_out = &extra_arg->sa_timed_out; #endif } @@ -1114,9 +1114,10 @@ searchit( } while (--count > 0 && found); // stop after count matches or no match -# ifdef FEAT_RELTIME - disable_regexp_timeout(); -# endif +#ifdef FEAT_RELTIME + if (extra_arg != NULL && extra_arg->sa_tm > 0) + disable_regexp_timeout(); +#endif vim_regfree(regmatch.regprog); if (!found) // did not find it @@ -4874,7 +4875,7 @@ do_fuzzymatch(typval_T *argvars, typval_T *rettv, int retmatchpos) // get the fuzzy matches ret = rettv_list_alloc(rettv); - if (ret != OK) + if (ret == FAIL) goto done; if (retmatchpos) { diff --git a/src/sign.c b/src/sign.c index 673d902751..ee36d33543 100644 --- a/src/sign.c +++ b/src/sign.c @@ -2335,7 +2335,7 @@ f_sign_define(typval_T *argvars, typval_T *rettv) if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_UNKNOWN) { // Define multiple signs - if (rettv_list_alloc(rettv) != OK) + if (rettv_list_alloc(rettv) == FAIL) return; sign_define_multiple(argvars[0].vval.v_list, rettv->vval.v_list); @@ -2367,7 +2367,7 @@ f_sign_getdefined(typval_T *argvars, typval_T *rettv) { char_u *name = NULL; - if (rettv_list_alloc_id(rettv, aid_sign_getdefined) != OK) + if (rettv_list_alloc_id(rettv, aid_sign_getdefined) == FAIL) return; if (in_vim9script() && check_for_opt_string_arg(argvars, 0) == FAIL) @@ -2393,7 +2393,7 @@ f_sign_getplaced(typval_T *argvars, typval_T *rettv) char_u *group = NULL; int notanum = FALSE; - if (rettv_list_alloc_id(rettv, aid_sign_getplaced) != OK) + if (rettv_list_alloc_id(rettv, aid_sign_getplaced) == FAIL) return; if (in_vim9script() @@ -2661,7 +2661,7 @@ f_sign_placelist(typval_T *argvars, typval_T *rettv) listitem_T *li; int sign_id; - if (rettv_list_alloc(rettv) != OK) + if (rettv_list_alloc(rettv) == FAIL) return; if (in_vim9script() && check_for_list_arg(argvars, 0) == FAIL) @@ -2721,7 +2721,7 @@ f_sign_undefine(typval_T *argvars, typval_T *rettv) if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_UNKNOWN) { // Undefine multiple signs - if (rettv_list_alloc(rettv) != OK) + if (rettv_list_alloc(rettv) == FAIL) return; sign_undefine_multiple(argvars[0].vval.v_list, rettv->vval.v_list); @@ -2892,7 +2892,7 @@ f_sign_unplacelist(typval_T *argvars, typval_T *rettv) listitem_T *li; int retval; - if (rettv_list_alloc(rettv) != OK) + if (rettv_list_alloc(rettv) == FAIL) return; if (in_vim9script() && check_for_list_arg(argvars, 0) == FAIL) diff --git a/src/term.c b/src/term.c index b5f7c28e0e..75351bcf2c 100644 --- a/src/term.c +++ b/src/term.c @@ -1476,7 +1476,7 @@ f_terminalprops(typval_T *argvars UNUSED, typval_T *rettv) int i; # endif - if (rettv_dict_alloc(rettv) != OK) + if (rettv_dict_alloc(rettv) == FAIL) return; # ifdef FEAT_TERMRESPONSE for (i = 0; i < TPR_COUNT; ++i) diff --git a/src/testdir/dumps/Test_mode_updated_1.dump b/src/testdir/dumps/Test_mode_updated_1.dump new file mode 100644 index 0000000000..6bbded42d1 --- /dev/null +++ b/src/testdir/dumps/Test_mode_updated_1.dump @@ -0,0 +1,5 @@ +> +0&#ffffff0@74 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +| +0#0000000&@56|0|,|0|-|1| @8|A|l@1| diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim index 5f10aacac4..6c2343b1e2 100644 --- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -718,6 +718,7 @@ let s:script_checks = { \ 'routeros': [['#!/path/rsc']], \ 'fish': [['#!/path/fish']], \ 'forth': [['#!/path/gforth']], + \ 'icon': [['#!/path/icon']], \ } " Various forms of "env" optional arguments. diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim index 75b684c393..b926a5b414 100644 --- a/src/testdir/test_gui.vim +++ b/src/testdir/test_gui.vim @@ -118,9 +118,8 @@ func Test_quoteplus() let test_call = 'Can you hear me?' let test_response = 'Yes, I can.' - let vim_exe = GetVimCommand() - let testee = 'VIMRUNTIME=' . $VIMRUNTIME . '; export VIMRUNTIME;' - \ . vim_exe . ' --noplugin --not-a-term -c ''%s''' + let testee = 'VIMRUNTIME=' .. $VIMRUNTIME .. '; export VIMRUNTIME;' + \ .. GetVimCommand() .. ' --noplugin --not-a-term -c ''%s''' " Ignore the "failed to create input context" error. let cmd = 'call test_ignore_error("E285") | ' \ . 'gui -f | ' @@ -1595,4 +1594,25 @@ func Test_gui_CTRL_SHIFT_V() unlet g:str endfunc +func Test_gui_dialog_file() + let lines =<< trim END + file Xfile + normal axxx + confirm qa + END + call writefile(lines, 'Xlines') + let prefix = '!' + if has('win32') + let prefix = '!start ' + endif + execute prefix .. GetVimCommand() .. ' -g -f --clean --gui-dialog-file Xdialog -S Xlines' + + call WaitForAssert({-> assert_true(filereadable('Xdialog'))}) + call assert_match('Question: Save changes to "Xfile"?', readfile('Xdialog')->join('')) + + call delete('Xdialog') + call delete('Xfile') + call delete('Xlines') +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim index ec2f9bc39c..50c0d5d274 100644 --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -4,6 +4,7 @@ source shared.vim source check.vim source view_util.vim import './vim9.vim' as v9 +source screendump.vim func Setup_NewWindow() 10new @@ -2458,9 +2459,9 @@ func Test_normal33_g_cmd2() call assert_equal(2, line('.')) call assert_fails(':norm! g;', 'E662:') call assert_fails(':norm! g,', 'E663:') - let &ul=&ul + let &ul = &ul call append('$', ['a', 'b', 'c', 'd']) - let &ul=&ul + let &ul = &ul call append('$', ['Z', 'Y', 'X', 'W']) let a = execute(':changes') call assert_match('2\s\+0\s\+2', a) @@ -3266,6 +3267,20 @@ func Test_message_when_using_ctrl_c() bwipe! endfunc +func Test_mode_updated_after_ctrl_c() + CheckScreendump + + let buf = RunVimInTerminal('', {'rows': 5}) + call term_sendkeys(buf, "i") + call term_sendkeys(buf, "\") + " wait a moment so that the "-- (insert) --" message is displayed + call TermWait(buf, 50) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_mode_updated_1', {}) + + call StopVimInTerminal(buf) +endfunc + " Test for '[m', ']m', '[M' and ']M' " Jumping to beginning and end of methods in Java-like languages func Test_java_motion() diff --git a/src/testdir/test_retab.vim b/src/testdir/test_retab.vim index 4253e77487..a4f95053c0 100644 --- a/src/testdir/test_retab.vim +++ b/src/testdir/test_retab.vim @@ -92,7 +92,7 @@ func RetabLoop() endfunc func Test_retab_endless() - " inside try/catch we catch the error message + " inside try/catch we can catch the error message call setline(1, "\t0\t") let caught = 'no' try @@ -106,13 +106,7 @@ func Test_retab_endless() endfunc func Test_nocatch_retab_endless() - " FIXME: why does this hang on MS-Windows? Is got_int reset somewhere? - if has('win32') - let g:skipped_reason = "does not work on MS-Windows" - return - endif - - " not inside try/catch an interrupt is generated to get out of loops + " when not inside try/catch an interrupt is generated to get out of loops call setline(1, "\t0\t") call assert_fails('call RetabLoop()', ['E1240:', 'Interrupted']) diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim index b354a2f4f8..caeddc567a 100644 --- a/src/testdir/test_search.vim +++ b/src/testdir/test_search.vim @@ -328,7 +328,31 @@ func Test_searchpair() call assert_equal(3, searchpair('\', '\', '\', 'W')) call assert_equal([0, 3, 3, 0], getpos('.')) - q! + bwipe! +endfunc + +func Test_searchpair_timeout() + CheckFeature reltime + + func Waitabit() + sleep 20m + return 1 " skip match + endfunc + + new + call setline(1, range(100)) + call setline(1, "(start here") + call setline(100, "end here)") + let starttime = reltime() + + " A timeout of 100 msec should happen after about five times of 20 msec wait + " in Waitabit(). When the timeout applies to each search the elapsed time + " will be much longer. + call assert_equal(0, searchpair('(', '\d', ')', '', "Waitabit()", 0, 100)) + let elapsed = reltime(starttime)->reltimefloat() + call assert_inrange(0.09, 0.300, elapsed) + + bwipe! endfunc func Test_searchpairpos() diff --git a/src/textprop.c b/src/textprop.c index 9d3487fde2..9198665b7c 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -1076,7 +1076,7 @@ f_prop_list(typval_T *argvars, typval_T *rettv) || check_for_opt_dict_arg(argvars, 1) == FAIL)) return; - if (rettv_list_alloc(rettv) != OK) + if (rettv_list_alloc(rettv) == FAIL) return; // default: get text properties on current line diff --git a/src/time.c b/src/time.c index d76874243c..4adcce59fb 100644 --- a/src/time.c +++ b/src/time.c @@ -172,7 +172,7 @@ f_reltime(typval_T *argvars UNUSED, typval_T *rettv UNUSED) proftime_T start; long n1, n2; - if (rettv_list_alloc(rettv) != OK) + if (rettv_list_alloc(rettv) == FAIL) return; if (in_vim9script() @@ -787,7 +787,7 @@ f_timer_info(typval_T *argvars, typval_T *rettv) { timer_T *timer = NULL; - if (rettv_list_alloc(rettv) != OK) + if (rettv_list_alloc(rettv) == FAIL) return; if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL) diff --git a/src/version.c b/src/version.c index c7a799d4c9..a21569293a 100644 --- a/src/version.c +++ b/src/version.c @@ -749,6 +749,24 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 5114, +/**/ + 5113, +/**/ + 5112, +/**/ + 5111, +/**/ + 5110, +/**/ + 5109, +/**/ + 5108, +/**/ + 5107, +/**/ + 5106, /**/ 5105, /**/ diff --git a/src/vim.h b/src/vim.h index baf9a554fb..aa7052505a 100644 --- a/src/vim.h +++ b/src/vim.h @@ -17,7 +17,7 @@ # define MSWIN #endif -#ifdef MSWIN +#if defined(MSWIN) && !defined(PROTO) # include #endif @@ -379,7 +379,7 @@ typedef long long_i; * We assume that when fseeko() is available then ftello() is too. * Note that Windows has different function names. */ -#ifdef MSWIN +#if defined(MSWIN) && !defined(PROTO) typedef __int64 off_T; # ifdef __MINGW32__ # define vim_lseek lseek64 @@ -975,6 +975,11 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring); #define KEY_OPEN_BACK 0x102 #define KEY_COMPLETE 0x103 // end of completion +// Used for the first argument of do_map() +#define MAPTYPE_MAP 0 +#define MAPTYPE_UNMAP 1 +#define MAPTYPE_NOREMAP 2 + // Values for "noremap" argument of ins_typebuf(). Also used for // map->m_noremap and menu->noremap[]. #define REMAP_YES 0 // allow remapping