diff --git a/runtime/doc/testing.txt b/runtime/doc/testing.txt index 6998a6edc2..7e8e8b9cc0 100644 --- a/runtime/doc/testing.txt +++ b/runtime/doc/testing.txt @@ -94,6 +94,7 @@ test_gui_event({event}, {args}) "findrepl" search and replace text. "mouse" mouse button click event. "scrollbar" move or drag the scrollbar. + "sendevent" send a low-level GUI event. "tabline" select a tab page by mouse click. "tabmenu" select a tabline menu entry. @@ -177,6 +178,15 @@ test_gui_event({event}, {args}) dragging: 1 to drag the scrollbar and 0 to click in the scrollbar. + "sendevent": + Send a low-level GUI event (e.g. key-up or down). + Currently only supported on MS-Windows. + The supported items in {args} are: + event: The supported string values are: + keyup generate a keyup event + keydown generate a keydown event + keycode: Keycode to use for a keyup or a keydown event. + "tabline": Inject a mouse click event on the tabline to select a tabpage. The supported items in {args} are: diff --git a/src/auto/configure b/src/auto/configure index 15af311bdf..6abcba1f9c 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -13295,13 +13295,14 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for timer_create" >&5 $as_echo_n "checking for timer_create... " >&6; } -save_LIBS="$LIBS" +if ${vim_cv_timer_create+:} false; then : + $as_echo_n "(cached) " >&6 +else + save_LIBS="$LIBS" LIBS="$LIBS -lrt" if test "$cross_compiling" = yes; then : - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } + as_fn_error $? "cross-compiling: please set 'vim_cv_timer_create'" "$LINENO" 5 + else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -13328,9 +13329,8 @@ main () } _ACEOF if ac_fn_c_try_run "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes; with -lrt" >&5 -$as_echo "yes; with -lrt" >&6; }; $as_echo "#define HAVE_TIMER_CREATE 1" >>confdefs.h - + { $as_echo "$as_me:${as_lineno-$LINENO}: timer_create with -lrt" >&5 +$as_echo "$as_me: timer_create with -lrt" >&6;}; vim_cv_timer_create=yes else LIBS="$save_LIBS" if test "$cross_compiling" = yes; then : @@ -13364,12 +13364,9 @@ main () } _ACEOF if ac_fn_c_try_run "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; }; $as_echo "#define HAVE_TIMER_CREATE 1" >>confdefs.h - + vim_cv_timer_create=yes else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + vim_cv_timer_create=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext @@ -13381,6 +13378,16 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vim_cv_timer_create" >&5 +$as_echo "$vim_cv_timer_create" >&6; } + +if test "x$vim_cv_timer_create" = "xyes" ; then + $as_echo "#define HAVE_TIMER_CREATE 1" >>confdefs.h + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat() ignores a trailing slash" >&5 $as_echo_n "checking whether stat() ignores a trailing slash... " >&6; } if ${vim_cv_stat_ignores_slash+:} false; then : diff --git a/src/autocmd.c b/src/autocmd.c index f5184255d3..3cb91e7f7a 100644 --- a/src/autocmd.c +++ b/src/autocmd.c @@ -2210,9 +2210,13 @@ apply_autocmds_group( ap->last = FALSE; ap->last = TRUE; + // Make sure cursor and topline are valid. The first time the current + // values are saved, restored by reset_lnums(). When nested only the + // values are corrected when needed. if (nesting == 1) - // make sure cursor and topline are valid check_lnums(TRUE); + else + check_lnums_nested(TRUE); save_did_emsg = did_emsg; @@ -2830,7 +2834,7 @@ autocmd_add_or_delete(typval_T *argvars, typval_T *rettv, int delete) } } - group_name = dict_get_string(event_dict, (char_u *)"group", TRUE); + group_name = dict_get_string(event_dict, "group", TRUE); if (group_name == NULL || *group_name == NUL) // if the autocmd group name is not specified, then use the current // autocmd group @@ -2865,7 +2869,7 @@ autocmd_add_or_delete(typval_T *argvars, typval_T *rettv, int delete) { varnumber_T bnum; - bnum = dict_get_number_def(event_dict, (char_u *)"bufnr", -1); + bnum = dict_get_number_def(event_dict, "bufnr", -1); if (bnum == -1) continue; @@ -2905,13 +2909,13 @@ autocmd_add_or_delete(typval_T *argvars, typval_T *rettv, int delete) pat = (char_u *)""; } - once = dict_get_bool(event_dict, (char_u *)"once", FALSE); - nested = dict_get_bool(event_dict, (char_u *)"nested", FALSE); + once = dict_get_bool(event_dict, "once", FALSE); + nested = dict_get_bool(event_dict, "nested", FALSE); // if 'replace' is true, then remove all the commands associated with // this autocmd event/group and add the new command. - replace = dict_get_bool(event_dict, (char_u *)"replace", FALSE); + replace = dict_get_bool(event_dict, "replace", FALSE); - cmd = dict_get_string(event_dict, (char_u *)"cmd", TRUE); + cmd = dict_get_string(event_dict, "cmd", TRUE); if (cmd == NULL) { if (delete) @@ -3073,8 +3077,7 @@ f_autocmd_get(typval_T *argvars, typval_T *rettv) // return only the autocmds in the specified group if (dict_has_key(argvars[0].vval.v_dict, "group")) { - name = dict_get_string(argvars[0].vval.v_dict, - (char_u *)"group", TRUE); + name = dict_get_string(argvars[0].vval.v_dict, "group", TRUE); if (name == NULL) return; @@ -3098,8 +3101,7 @@ f_autocmd_get(typval_T *argvars, typval_T *rettv) { int i; - name = dict_get_string(argvars[0].vval.v_dict, - (char_u *)"event", TRUE); + name = dict_get_string(argvars[0].vval.v_dict, "event", TRUE); if (name == NULL) return; @@ -3124,8 +3126,7 @@ f_autocmd_get(typval_T *argvars, typval_T *rettv) // return only the autocmds for the specified pattern if (dict_has_key(argvars[0].vval.v_dict, "pattern")) { - pat = dict_get_string(argvars[0].vval.v_dict, - (char_u *)"pattern", TRUE); + pat = dict_get_string(argvars[0].vval.v_dict, "pattern", TRUE); if (pat == NULL) return; } diff --git a/src/change.c b/src/change.c index d5280b681a..3a414d8ec7 100644 --- a/src/change.c +++ b/src/change.c @@ -172,9 +172,9 @@ check_recorded_changes( FOR_ALL_LIST_ITEMS(buf->b_recorded_changes, li) { prev_lnum = (linenr_T)dict_get_number( - li->li_tv.vval.v_dict, (char_u *)"lnum"); + li->li_tv.vval.v_dict, "lnum"); prev_lnume = (linenr_T)dict_get_number( - li->li_tv.vval.v_dict, (char_u *)"end"); + li->li_tv.vval.v_dict, "end"); if (prev_lnum >= lnum || prev_lnum > lnume || prev_lnume >= lnum) { // the current change is going to make the line number in @@ -384,13 +384,13 @@ invoke_listeners(buf_T *buf) { varnumber_T lnum; - lnum = dict_get_number(li->li_tv.vval.v_dict, (char_u *)"lnum"); + lnum = dict_get_number(li->li_tv.vval.v_dict, "lnum"); if (start > lnum) start = lnum; - lnum = dict_get_number(li->li_tv.vval.v_dict, (char_u *)"end"); + lnum = dict_get_number(li->li_tv.vval.v_dict, "end"); if (end < lnum) end = lnum; - added += dict_get_number(li->li_tv.vval.v_dict, (char_u *)"added"); + added += dict_get_number(li->li_tv.vval.v_dict, "added"); } argv[1].v_type = VAR_NUMBER; argv[1].vval.v_number = start; diff --git a/src/configure.ac b/src/configure.ac index 24e2ace9d9..d45e94ac87 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -4004,7 +4004,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM( dnl Check for timer_create. It probably requires the 'rt' library. dnl Run the program to find out if timer_create(CLOCK_MONOTONIC) actually dnl works, on Solaris timer_create() exists but fails at runtime. -AC_MSG_CHECKING([for timer_create]) +AC_CACHE_CHECK([for timer_create], [vim_cv_timer_create], save_LIBS="$LIBS" LIBS="$LIBS -lrt" AC_RUN_IFELSE([AC_LANG_PROGRAM([ @@ -4021,7 +4021,7 @@ static void set_flag(union sigval sv) {} if (timer_create(CLOCK_MONOTONIC, &action, &timer_id) < 0) exit(1); // cannot create a monotonic timer ])], - AC_MSG_RESULT(yes; with -lrt); AC_DEFINE(HAVE_TIMER_CREATE), + AC_MSG_NOTICE(timer_create with -lrt); vim_cv_timer_create=yes, LIBS="$save_LIBS" AC_RUN_IFELSE([AC_LANG_PROGRAM([ #include @@ -4037,8 +4037,16 @@ static void set_flag(union sigval sv) {} if (timer_create(CLOCK_MONOTONIC, &action, &timer_id) < 0) exit(1); // cannot create a monotonic timer ])], - AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIMER_CREATE), - AC_MSG_RESULT(no))) + vim_cv_timer_create=yes, + vim_cv_timer_create=no), + AC_MSG_ERROR(cross-compiling: please set 'vim_cv_timer_create') + ) +) + +if test "x$vim_cv_timer_create" = "xyes" ; then + AC_DEFINE(HAVE_TIMER_CREATE) +fi + AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash], [ diff --git a/src/dict.c b/src/dict.c index d2819578a7..29608bd88c 100644 --- a/src/dict.c +++ b/src/dict.c @@ -662,11 +662,11 @@ dict_has_key(dict_T *d, char *key) * Returns FAIL if the entry doesn't exist or out of memory. */ int -dict_get_tv(dict_T *d, char_u *key, typval_T *rettv) +dict_get_tv(dict_T *d, char *key, typval_T *rettv) { dictitem_T *di; - di = dict_find(d, key, -1); + di = dict_find(d, (char_u *)key, -1); if (di == NULL) return FAIL; copy_tv(&di->di_tv, rettv); @@ -680,12 +680,12 @@ dict_get_tv(dict_T *d, char_u *key, typval_T *rettv) * Returns NULL if the entry doesn't exist or out of memory. */ char_u * -dict_get_string(dict_T *d, char_u *key, int save) +dict_get_string(dict_T *d, char *key, int save) { dictitem_T *di; char_u *s; - di = dict_find(d, key, -1); + di = dict_find(d, (char_u *)key, -1); if (di == NULL) return NULL; s = tv_get_string(&di->di_tv); @@ -699,7 +699,7 @@ dict_get_string(dict_T *d, char_u *key, int save) * Returns 0 if the entry doesn't exist. */ varnumber_T -dict_get_number(dict_T *d, char_u *key) +dict_get_number(dict_T *d, char *key) { return dict_get_number_def(d, key, 0); } @@ -709,11 +709,11 @@ dict_get_number(dict_T *d, char_u *key) * Returns "def" if the entry doesn't exist. */ varnumber_T -dict_get_number_def(dict_T *d, char_u *key, int def) +dict_get_number_def(dict_T *d, char *key, int def) { dictitem_T *di; - di = dict_find(d, key, -1); + di = dict_find(d, (char_u *)key, -1); if (di == NULL) return def; return tv_get_number(&di->di_tv); @@ -745,11 +745,11 @@ dict_get_number_check(dict_T *d, char_u *key) * Returns "def" if the entry doesn't exist. */ varnumber_T -dict_get_bool(dict_T *d, char_u *key, int def) +dict_get_bool(dict_T *d, char *key, int def) { dictitem_T *di; - di = dict_find(d, key, -1); + di = dict_find(d, (char_u *)key, -1); if (di == NULL) return def; return tv_get_bool(&di->di_tv); diff --git a/src/errors.h b/src/errors.h index 9d4c93d6c8..5e78dc98eb 100644 --- a/src/errors.h +++ b/src/errors.h @@ -3308,4 +3308,10 @@ EXTERN char e_could_not_check_for_pending_sigalrm_str[] #ifdef FEAT_EVAL EXTERN char e_substitute_nesting_too_deep[] INIT(= N_("E1290: substitute nesting too deep")); +EXTERN char e_invalid_argument_nr[] + INIT(= N_("E1291: Invalid argument: %ld")); +#endif +#ifdef FEAT_CMDWIN +EXTERN char e_cmdline_window_already_open[] + INIT(= N_("E1292: Command-line window is already open")); #endif diff --git a/src/evalbuffer.c b/src/evalbuffer.c index 0808c7e6a2..fe41f08487 100644 --- a/src/evalbuffer.c +++ b/src/evalbuffer.c @@ -695,9 +695,9 @@ f_getbufinfo(typval_T *argvars, typval_T *rettv) if (sel_d != NULL) { filtered = TRUE; - sel_buflisted = dict_get_bool(sel_d, (char_u *)"buflisted", FALSE); - sel_bufloaded = dict_get_bool(sel_d, (char_u *)"bufloaded", FALSE); - sel_bufmodified = dict_get_bool(sel_d, (char_u *)"bufmodified", + sel_buflisted = dict_get_bool(sel_d, "buflisted", FALSE); + sel_bufloaded = dict_get_bool(sel_d, "bufloaded", FALSE); + sel_bufmodified = dict_get_bool(sel_d, "bufmodified", FALSE); } } diff --git a/src/evalfunc.c b/src/evalfunc.c index c87c36ba22..daee5c423f 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -4217,8 +4217,7 @@ f_expandcmd(typval_T *argvars, typval_T *rettv) return; if (argvars[1].v_type == VAR_DICT - && dict_get_bool(argvars[1].vval.v_dict, (char_u *)"errmsg", - VVAL_FALSE)) + && dict_get_bool(argvars[1].vval.v_dict, "errmsg", VVAL_FALSE)) emsgoff = FALSE; rettv->v_type = VAR_STRING; @@ -9207,7 +9206,7 @@ f_setcharsearch(typval_T *argvars, typval_T *rettv UNUSED) if ((d = argvars[0].vval.v_dict) != NULL) { - csearch = dict_get_string(d, (char_u *)"char", FALSE); + csearch = dict_get_string(d, "char", FALSE); if (csearch != NULL) { if (enc_utf8) @@ -9403,7 +9402,7 @@ f_setreg(typval_T *argvars, typval_T *rettv) if (di != NULL) regcontents = &di->di_tv; - stropt = dict_get_string(d, (char_u *)"regtype", FALSE); + stropt = dict_get_string(d, "regtype", FALSE); if (stropt != NULL) { int ret = get_yank_type(&stropt, &yank_type, &block_len); @@ -9417,14 +9416,14 @@ f_setreg(typval_T *argvars, typval_T *rettv) if (regname == '"') { - stropt = dict_get_string(d, (char_u *)"points_to", FALSE); + stropt = dict_get_string(d, "points_to", FALSE); if (stropt != NULL) { pointreg = *stropt; regname = pointreg; } } - else if (dict_get_bool(d, (char_u *)"isunnamed", -1) > 0) + else if (dict_get_bool(d, "isunnamed", -1) > 0) pointreg = regname; } else diff --git a/src/evalwindow.c b/src/evalwindow.c index 00d63cd365..d507ab3677 100644 --- a/src/evalwindow.c +++ b/src/evalwindow.c @@ -1016,11 +1016,11 @@ f_win_splitmove(typval_T *argvars, typval_T *rettv) } d = argvars[2].vval.v_dict; - if (dict_get_bool(d, (char_u *)"vertical", FALSE)) + if (dict_get_bool(d, "vertical", FALSE)) flags |= WSP_VERT; if ((di = dict_find(d, (char_u *)"rightbelow", -1)) != NULL) flags |= tv_get_bool(&di->di_tv) ? WSP_BELOW : WSP_ABOVE; - size = (int)dict_get_number(d, (char_u *)"size"); + size = (int)dict_get_number(d, "size"); } win_move_into_split(wp, targetwin, size, flags); @@ -1236,27 +1236,27 @@ f_winrestview(typval_T *argvars, typval_T *rettv UNUSED) else { if (dict_has_key(dict, "lnum")) - curwin->w_cursor.lnum = (linenr_T)dict_get_number(dict, (char_u *)"lnum"); + curwin->w_cursor.lnum = (linenr_T)dict_get_number(dict, "lnum"); if (dict_has_key(dict, "col")) - curwin->w_cursor.col = (colnr_T)dict_get_number(dict, (char_u *)"col"); + curwin->w_cursor.col = (colnr_T)dict_get_number(dict, "col"); if (dict_has_key(dict, "coladd")) - curwin->w_cursor.coladd = (colnr_T)dict_get_number(dict, (char_u *)"coladd"); + curwin->w_cursor.coladd = (colnr_T)dict_get_number(dict, "coladd"); if (dict_has_key(dict, "curswant")) { - curwin->w_curswant = (colnr_T)dict_get_number(dict, (char_u *)"curswant"); + curwin->w_curswant = (colnr_T)dict_get_number(dict, "curswant"); curwin->w_set_curswant = FALSE; } if (dict_has_key(dict, "topline")) - set_topline(curwin, (linenr_T)dict_get_number(dict, (char_u *)"topline")); + set_topline(curwin, (linenr_T)dict_get_number(dict, "topline")); #ifdef FEAT_DIFF if (dict_has_key(dict, "topfill")) - curwin->w_topfill = (int)dict_get_number(dict, (char_u *)"topfill"); + curwin->w_topfill = (int)dict_get_number(dict, "topfill"); #endif if (dict_has_key(dict, "leftcol")) - curwin->w_leftcol = (colnr_T)dict_get_number(dict, (char_u *)"leftcol"); + curwin->w_leftcol = (colnr_T)dict_get_number(dict, "leftcol"); if (dict_has_key(dict, "skipcol")) - curwin->w_skipcol = (colnr_T)dict_get_number(dict, (char_u *)"skipcol"); + curwin->w_skipcol = (colnr_T)dict_get_number(dict, "skipcol"); check_cursor(); win_new_height(curwin, curwin->w_height); diff --git a/src/fileio.c b/src/fileio.c index 12b4699cb9..2b6adbdb5a 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -4787,8 +4787,8 @@ compare_readdirex_item(const void *p1, const void *p2) { char_u *name1, *name2; - name1 = dict_get_string(*(dict_T**)p1, (char_u*)"name", FALSE); - name2 = dict_get_string(*(dict_T**)p2, (char_u*)"name", FALSE); + name1 = dict_get_string(*(dict_T**)p1, "name", FALSE); + name2 = dict_get_string(*(dict_T**)p2, "name", FALSE); if (readdirex_sort == READDIR_SORT_BYTE) return STRCMP(name1, name2); else if (readdirex_sort == READDIR_SORT_IC) diff --git a/src/filepath.c b/src/filepath.c index 6bca4c252b..f3c9418979 100644 --- a/src/filepath.c +++ b/src/filepath.c @@ -1619,7 +1619,7 @@ readdirex_dict_arg(typval_T *tv, int *cmp) } if (dict_has_key(tv->vval.v_dict, "sort")) - compare = dict_get_string(tv->vval.v_dict, (char_u *)"sort", FALSE); + compare = dict_get_string(tv->vval.v_dict, "sort", FALSE); else { semsg(_(e_dictionary_key_str_required), "sort"); diff --git a/src/getchar.c b/src/getchar.c index 00ca85b88f..ccf80df2c8 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -2449,7 +2449,7 @@ handle_mapping( int local_State = get_real_state(); int is_plug_map = FALSE; - // If typehead starts with then remap, even for a "noremap" mapping. + // If typeahead starts with then remap, even for a "noremap" mapping. if (typebuf.tb_len >= 3 && typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL && typebuf.tb_buf[typebuf.tb_off + 1] == KS_EXTRA diff --git a/src/gui_w32.c b/src/gui_w32.c index f53318d677..472cebf733 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -8541,3 +8541,42 @@ netbeans_draw_multisign_indicator(int row) SetPixel(s_hdc, x+2, y, gui.currFgColor); } #endif + +#if defined(FEAT_EVAL) || defined(PROTO) + int +test_gui_w32_sendevent(dict_T *args) +{ + char_u *event; + INPUT inputs[1]; + + event = dict_get_string(args, "event", TRUE); + if (event == NULL) + return FALSE; + + ZeroMemory(inputs, sizeof(inputs)); + + if (STRICMP(event, "keydown") == 0 || STRICMP(event, "keyup") == 0) + { + WORD vkCode; + + vkCode = dict_get_number_def(args, "keycode", 0); + if (vkCode <= 0 || vkCode >= 0xFF) + { + semsg(_(e_invalid_argument_nr), (long)vkCode); + return FALSE; + } + + inputs[0].type = INPUT_KEYBOARD; + inputs[0].ki.wVk = vkCode; + if (STRICMP(event, "keyup") == 0) + inputs[0].ki.dwFlags = KEYEVENTF_KEYUP; + SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT)); + } + else + semsg(_(e_invalid_argument_str), event); + + vim_free(event); + + return TRUE; +} +#endif diff --git a/src/highlight.c b/src/highlight.c index cf74a96515..5d6a5bb2d7 100644 --- a/src/highlight.c +++ b/src/highlight.c @@ -4317,8 +4317,7 @@ hldict_attr_to_str( p = attr_str; for (i = 0; i < (int)ARRAY_LENGTH(hl_name_table); i++) { - if (dict_get_bool(attrdict, (char_u *)hl_name_table[i], - VVAL_FALSE) == VVAL_TRUE) + if (dict_get_bool(attrdict, hl_name_table[i], VVAL_FALSE) == VVAL_TRUE) { if (p != attr_str && (size_t)(p - attr_str + 2) < len) STRCPY(p, (char_u *)","); @@ -4398,10 +4397,10 @@ hlg_add_or_update(dict_T *dict) if (name == NULL || *name == NUL || error) return FALSE; - if (dict_get_bool(dict, (char_u *)"force", VVAL_FALSE) == VVAL_TRUE) + if (dict_get_bool(dict, "force", VVAL_FALSE) == VVAL_TRUE) forceit = TRUE; - if (dict_get_bool(dict, (char_u *)"default", VVAL_FALSE) == VVAL_TRUE) + if (dict_get_bool(dict, "default", VVAL_FALSE) == VVAL_TRUE) dodefault = TRUE; if (dict_has_key(dict, "cleared")) @@ -4409,7 +4408,7 @@ hlg_add_or_update(dict_T *dict) varnumber_T cleared; // clear a highlight group - cleared = dict_get_bool(dict, (char_u *)"cleared", FALSE); + cleared = dict_get_bool(dict, "cleared", FALSE); if (cleared == TRUE) { vim_snprintf((char *)hlsetBuf, HLSETBUFSZ, "clear %s", name); diff --git a/src/insexpand.c b/src/insexpand.c index a7c0a183d1..c05f66c2d7 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -642,6 +642,7 @@ ins_compl_infercase_gettext( // growarray. Add the character in the next round. if (ga_grow(&gap, IOSIZE) == FAIL) return (char_u *)"[failed]"; + *p = NUL; STRCPY(gap.ga_data, IObuff); gap.ga_len = (int)STRLEN(IObuff); } @@ -2770,25 +2771,21 @@ ins_compl_add_tv(typval_T *tv, int dir, int fast) user_data.v_type = VAR_UNKNOWN; if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL) { - word = dict_get_string(tv->vval.v_dict, (char_u *)"word", FALSE); - cptext[CPT_ABBR] = dict_get_string(tv->vval.v_dict, - (char_u *)"abbr", FALSE); - cptext[CPT_MENU] = dict_get_string(tv->vval.v_dict, - (char_u *)"menu", FALSE); - cptext[CPT_KIND] = dict_get_string(tv->vval.v_dict, - (char_u *)"kind", FALSE); - cptext[CPT_INFO] = dict_get_string(tv->vval.v_dict, - (char_u *)"info", FALSE); - dict_get_tv(tv->vval.v_dict, (char_u *)"user_data", &user_data); - if (dict_get_string(tv->vval.v_dict, (char_u *)"icase", FALSE) != NULL - && dict_get_number(tv->vval.v_dict, (char_u *)"icase")) + word = dict_get_string(tv->vval.v_dict, "word", FALSE); + cptext[CPT_ABBR] = dict_get_string(tv->vval.v_dict, "abbr", FALSE); + cptext[CPT_MENU] = dict_get_string(tv->vval.v_dict, "menu", FALSE); + cptext[CPT_KIND] = dict_get_string(tv->vval.v_dict, "kind", FALSE); + cptext[CPT_INFO] = dict_get_string(tv->vval.v_dict, "info", FALSE); + dict_get_tv(tv->vval.v_dict, "user_data", &user_data); + if (dict_get_string(tv->vval.v_dict, "icase", FALSE) != NULL + && dict_get_number(tv->vval.v_dict, "icase")) flags |= CP_ICASE; - if (dict_get_string(tv->vval.v_dict, (char_u *)"dup", FALSE) != NULL) - dup = dict_get_number(tv->vval.v_dict, (char_u *)"dup"); - if (dict_get_string(tv->vval.v_dict, (char_u *)"empty", FALSE) != NULL) - empty = dict_get_number(tv->vval.v_dict, (char_u *)"empty"); - if (dict_get_string(tv->vval.v_dict, (char_u *)"equal", FALSE) != NULL - && dict_get_number(tv->vval.v_dict, (char_u *)"equal")) + if (dict_get_string(tv->vval.v_dict, "dup", FALSE) != NULL) + dup = dict_get_number(tv->vval.v_dict, "dup"); + if (dict_get_string(tv->vval.v_dict, "empty", FALSE) != NULL) + empty = dict_get_number(tv->vval.v_dict, "empty"); + if (dict_get_string(tv->vval.v_dict, "equal", FALSE) != NULL + && dict_get_number(tv->vval.v_dict, "equal")) flags |= CP_EQUAL; } else diff --git a/src/map.c b/src/map.c index ddc6412ee6..148b823858 100644 --- a/src/map.c +++ b/src/map.c @@ -2621,8 +2621,8 @@ f_mapset(typval_T *argvars, typval_T *rettv UNUSED) if (dict_only) { d = argvars[0].vval.v_dict; - which = dict_get_string(d, (char_u *)"mode", FALSE); - is_abbr = dict_get_bool(d, (char_u *)"abbr", -1); + which = dict_get_string(d, "mode", FALSE); + is_abbr = dict_get_bool(d, "abbr", -1); if (which == NULL || is_abbr < 0) { emsg(_(e_entries_missing_in_mapset_dict_argument)); @@ -2652,10 +2652,10 @@ f_mapset(typval_T *argvars, typval_T *rettv UNUSED) // Get the values in the same order as above in get_maparg(). - lhs = dict_get_string(d, (char_u *)"lhs", FALSE); - lhsraw = dict_get_string(d, (char_u *)"lhsraw", FALSE); - lhsrawalt = dict_get_string(d, (char_u *)"lhsrawalt", FALSE); - rhs = dict_get_string(d, (char_u *)"rhs", FALSE); + lhs = dict_get_string(d, "lhs", FALSE); + lhsraw = dict_get_string(d, "lhsraw", FALSE); + lhsrawalt = dict_get_string(d, "lhsrawalt", FALSE); + rhs = dict_get_string(d, "rhs", FALSE); if (lhs == NULL || lhsraw == NULL || rhs == NULL) { emsg(_(e_entries_missing_in_mapset_dict_argument)); @@ -2665,16 +2665,16 @@ f_mapset(typval_T *argvars, typval_T *rettv UNUSED) rhs = replace_termcodes(rhs, &arg_buf, REPTERM_DO_LT | REPTERM_SPECIAL, NULL); - noremap = dict_get_number(d, (char_u *)"noremap") ? REMAP_NONE: 0; - if (dict_get_number(d, (char_u *)"script") != 0) + noremap = dict_get_number(d, "noremap") ? REMAP_NONE: 0; + if (dict_get_number(d, "script") != 0) noremap = REMAP_SCRIPT; - expr = dict_get_number(d, (char_u *)"expr") != 0; - silent = dict_get_number(d, (char_u *)"silent") != 0; - sid = dict_get_number(d, (char_u *)"sid"); - scriptversion = dict_get_number(d, (char_u *)"scriptversion"); - lnum = dict_get_number(d, (char_u *)"lnum"); - buffer = dict_get_number(d, (char_u *)"buffer"); - nowait = dict_get_number(d, (char_u *)"nowait") != 0; + expr = dict_get_number(d, "expr") != 0; + silent = dict_get_number(d, "silent") != 0; + sid = dict_get_number(d, "sid"); + scriptversion = dict_get_number(d, "scriptversion"); + lnum = dict_get_number(d, "lnum"); + buffer = dict_get_number(d, "buffer"); + nowait = dict_get_number(d, "nowait") != 0; // mode from the dict is not used if (buffer) diff --git a/src/match.c b/src/match.c index c9231876bc..e58ad013cb 100644 --- a/src/match.c +++ b/src/match.c @@ -961,8 +961,7 @@ matchadd_dict_arg(typval_T *tv, char_u **conceal_char, win_T **win) } if (dict_has_key(tv->vval.v_dict, "conceal")) - *conceal_char = dict_get_string(tv->vval.v_dict, - (char_u *)"conceal", FALSE); + *conceal_char = dict_get_string(tv->vval.v_dict, "conceal", FALSE); if ((di = dict_find(tv->vval.v_dict, (char_u *)"window", -1)) != NULL) { @@ -1161,16 +1160,16 @@ f_setmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED) } } - group = dict_get_string(d, (char_u *)"group", TRUE); - priority = (int)dict_get_number(d, (char_u *)"priority"); - id = (int)dict_get_number(d, (char_u *)"id"); + group = dict_get_string(d, "group", TRUE); + priority = (int)dict_get_number(d, "priority"); + id = (int)dict_get_number(d, "id"); conceal = dict_has_key(d, "conceal") - ? dict_get_string(d, (char_u *)"conceal", TRUE) + ? dict_get_string(d, "conceal", TRUE) : NULL; if (i == 0) { match_add(win, group, - dict_get_string(d, (char_u *)"pattern", FALSE), + dict_get_string(d, "pattern", FALSE), priority, id, NULL, conceal); } else diff --git a/src/normal.c b/src/normal.c index b5c5603f7e..cc160bf7ca 100644 --- a/src/normal.c +++ b/src/normal.c @@ -7159,6 +7159,11 @@ nv_record(cmdarg_T *cap) #ifdef FEAT_CMDWIN if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?') { + if (cmdwin_type != 0) + { + emsg(_(e_cmdline_window_already_open)); + return; + } stuffcharReadbuff(cap->nchar); stuffcharReadbuff(K_CMDWIN); } diff --git a/src/popupwin.c b/src/popupwin.c index dd87705504..78833400df 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -433,7 +433,7 @@ popup_add_timeout(win_T *wp, int time) static poppos_T get_pos_entry(dict_T *d, int give_error) { - char_u *str = dict_get_string(d, (char_u *)"pos", FALSE); + char_u *str = dict_get_string(d, "pos", FALSE); int nr; if (str == NULL) @@ -458,13 +458,13 @@ apply_move_options(win_T *wp, dict_T *d) char_u *str; dictitem_T *di; - if ((nr = dict_get_number_def(d, (char_u *)"minwidth", -1)) >= 0) + if ((nr = dict_get_number_def(d, "minwidth", -1)) >= 0) wp->w_minwidth = nr; - if ((nr = dict_get_number_def(d, (char_u *)"minheight", -1)) >= 0) + if ((nr = dict_get_number_def(d, "minheight", -1)) >= 0) wp->w_minheight = nr; - if ((nr = dict_get_number_def(d, (char_u *)"maxwidth", -1)) >= 0) + if ((nr = dict_get_number_def(d, "maxwidth", -1)) >= 0) wp->w_maxwidth = nr; - if ((nr = dict_get_number_def(d, (char_u *)"maxheight", -1)) >= 0) + if ((nr = dict_get_number_def(d, "maxheight", -1)) >= 0) wp->w_maxheight = nr; nr = popup_options_one(d, (char_u *)"line"); @@ -475,7 +475,7 @@ apply_move_options(win_T *wp, dict_T *d) wp->w_wantcol = nr; - nr = dict_get_bool(d, (char_u *)"fixed", -1); + nr = dict_get_bool(d, "fixed", -1); if (nr != -1) wp->w_popup_fixed = nr != 0; @@ -486,7 +486,7 @@ apply_move_options(win_T *wp, dict_T *d) wp->w_popup_pos = ppt; } - str = dict_get_string(d, (char_u *)"textprop", FALSE); + str = dict_get_string(d, "textprop", FALSE); if (str != NULL) { wp->w_popup_prop_type = 0; @@ -513,7 +513,7 @@ apply_move_options(win_T *wp, dict_T *d) di = dict_find(d, (char_u *)"textpropid", -1); if (di != NULL) - wp->w_popup_prop_id = dict_get_number(d, (char_u *)"textpropid"); + wp->w_popup_prop_id = dict_get_number(d, "textpropid"); } /* @@ -696,27 +696,27 @@ apply_general_options(win_T *wp, dict_T *dict) di = dict_find(dict, (char_u *)"firstline", -1); if (di != NULL) { - wp->w_firstline = dict_get_number(dict, (char_u *)"firstline"); + wp->w_firstline = dict_get_number(dict, "firstline"); if (wp->w_firstline < 0) wp->w_firstline = -1; } - nr = dict_get_bool(dict, (char_u *)"scrollbar", -1); + nr = dict_get_bool(dict, "scrollbar", -1); if (nr != -1) wp->w_want_scrollbar = nr; - str = dict_get_string(dict, (char_u *)"title", FALSE); + str = dict_get_string(dict, "title", FALSE); if (str != NULL) { vim_free(wp->w_popup_title); wp->w_popup_title = vim_strsave(str); } - nr = dict_get_bool(dict, (char_u *)"wrap", -1); + nr = dict_get_bool(dict, "wrap", -1); if (nr != -1) wp->w_p_wrap = nr != 0; - nr = dict_get_bool(dict, (char_u *)"drag", -1); + nr = dict_get_bool(dict, "drag", -1); if (nr != -1) { if (nr) @@ -724,7 +724,7 @@ apply_general_options(win_T *wp, dict_T *dict) else wp->w_popup_flags &= ~POPF_DRAG; } - nr = dict_get_bool(dict, (char_u *)"dragall", -1); + nr = dict_get_bool(dict, "dragall", -1); if (nr != -1) { if (nr) @@ -733,7 +733,7 @@ apply_general_options(win_T *wp, dict_T *dict) wp->w_popup_flags &= ~POPF_DRAGALL; } - nr = dict_get_bool(dict, (char_u *)"posinvert", -1); + nr = dict_get_bool(dict, "posinvert", -1); if (nr != -1) { if (nr) @@ -742,7 +742,7 @@ apply_general_options(win_T *wp, dict_T *dict) wp->w_popup_flags &= ~POPF_POSINVERT; } - nr = dict_get_bool(dict, (char_u *)"resize", -1); + nr = dict_get_bool(dict, "resize", -1); if (nr != -1) { if (nr) @@ -775,7 +775,7 @@ apply_general_options(win_T *wp, dict_T *dict) semsg(_(e_invalid_value_for_argument_str_str), "close", tv_get_string(&di->di_tv)); } - str = dict_get_string(dict, (char_u *)"highlight", FALSE); + str = dict_get_string(dict, "highlight", FALSE); if (str != NULL) { set_string_option_direct_in_win(wp, (char_u *)"wincolor", -1, @@ -861,7 +861,7 @@ apply_general_options(win_T *wp, dict_T *dict) di = dict_find(dict, (char_u *)"zindex", -1); if (di != NULL) { - wp->w_zindex = dict_get_number(dict, (char_u *)"zindex"); + wp->w_zindex = dict_get_number(dict, "zindex"); if (wp->w_zindex < 1) wp->w_zindex = POPUPWIN_DEFAULT_ZINDEX; if (wp->w_zindex > 32000) @@ -903,7 +903,7 @@ apply_general_options(win_T *wp, dict_T *dict) #if defined(FEAT_TIMERS) // Add timer to close the popup after some time. - nr = dict_get_number(dict, (char_u *)"time"); + nr = dict_get_number(dict, "time"); if (nr > 0) popup_add_timeout(wp, nr); #endif @@ -922,7 +922,7 @@ apply_general_options(win_T *wp, dict_T *dict) handle_moved_argument(wp, di, TRUE); } - nr = dict_get_bool(dict, (char_u *)"cursorline", -1); + nr = dict_get_bool(dict, "cursorline", -1); if (nr != -1) { if (nr != 0) @@ -942,7 +942,7 @@ apply_general_options(win_T *wp, dict_T *dict) set_callback(&wp->w_filter_cb, &callback); } } - nr = dict_get_bool(dict, (char_u *)"mapping", -1); + nr = dict_get_bool(dict, "mapping", -1); if (nr != -1) { if (nr) @@ -951,7 +951,7 @@ apply_general_options(win_T *wp, dict_T *dict) wp->w_popup_flags &= ~POPF_MAPPING; } - str = dict_get_string(dict, (char_u *)"filtermode", FALSE); + str = dict_get_string(dict, "filtermode", FALSE); if (str != NULL) { if (STRCMP(str, "a") == 0) @@ -990,7 +990,7 @@ apply_options(win_T *wp, dict_T *dict, int create) apply_general_options(wp, dict); - nr = dict_get_bool(dict, (char_u *)"hidden", FALSE); + nr = dict_get_bool(dict, "hidden", FALSE); if (nr > 0) wp->w_popup_flags |= POPF_HIDDEN | POPF_HIDDEN_FORCE; @@ -1051,8 +1051,7 @@ add_popup_dicts(buf_T *buf, list_T *l) return; } dict = li->li_tv.vval.v_dict; - p = dict == NULL ? NULL - : dict_get_string(dict, (char_u *)"text", FALSE); + p = dict == NULL ? NULL : dict_get_string(dict, "text", FALSE); ml_append_buf(buf, lnum++, p == NULL ? (char_u *)"" : p, (colnr_T)0, TRUE); } @@ -1086,7 +1085,7 @@ add_popup_dicts(buf_T *buf, list_T *l) dict = pli->li_tv.vval.v_dict; if (dict != NULL) { - int col = dict_get_number(dict, (char_u *)"col"); + int col = dict_get_number(dict, "col"); prop_add_common( lnum, col, dict, buf, NULL); } @@ -1975,7 +1974,7 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type) if (d != NULL) { if (dict_has_key(d, "tabpage")) - tabnr = (int)dict_get_number(d, (char_u *)"tabpage"); + tabnr = (int)dict_get_number(d, "tabpage"); else if (type == TYPE_NOTIFICATION) tabnr = -1; // notifications are global by default else diff --git a/src/proto/dict.pro b/src/proto/dict.pro index 30a3055841..a4442ccb9a 100644 --- a/src/proto/dict.pro +++ b/src/proto/dict.pro @@ -28,12 +28,12 @@ int dict_add_dict(dict_T *d, char *key, dict_T *dict); long dict_len(dict_T *d); dictitem_T *dict_find(dict_T *d, char_u *key, int len); int dict_has_key(dict_T *d, char *key); -int dict_get_tv(dict_T *d, char_u *key, typval_T *rettv); -char_u *dict_get_string(dict_T *d, char_u *key, int save); -varnumber_T dict_get_number(dict_T *d, char_u *key); -varnumber_T dict_get_number_def(dict_T *d, char_u *key, int def); +int dict_get_tv(dict_T *d, char *key, typval_T *rettv); +char_u *dict_get_string(dict_T *d, char *key, int save); +varnumber_T dict_get_number(dict_T *d, char *key); +varnumber_T dict_get_number_def(dict_T *d, char *key, int def); varnumber_T dict_get_number_check(dict_T *d, char_u *key); -varnumber_T dict_get_bool(dict_T *d, char_u *key, int def); +varnumber_T dict_get_bool(dict_T *d, char *key, int def); char_u *dict2string(typval_T *tv, int copyID, int restore_copyID); char_u *get_literal_key(char_u **arg); int eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal); diff --git a/src/proto/gui_w32.pro b/src/proto/gui_w32.pro index 43484ad802..cab3343249 100644 --- a/src/proto/gui_w32.pro +++ b/src/proto/gui_w32.pro @@ -96,4 +96,5 @@ void gui_mch_post_balloon(BalloonEval *beval, char_u *mesg); BalloonEval *gui_mch_create_beval_area(void *target, char_u *mesg, void (*mesgCB)(BalloonEval *, int), void *clientData); void gui_mch_destroy_beval_area(BalloonEval *beval); void netbeans_draw_multisign_indicator(int row); +int test_gui_w32_sendevent(dict_T *args); /* vim: set ft=c : */ diff --git a/src/proto/window.pro b/src/proto/window.pro index 9625942fea..8fa8661685 100644 --- a/src/proto/window.pro +++ b/src/proto/window.pro @@ -77,6 +77,7 @@ int tabline_height(void); int min_rows(void); int only_one_window(void); void check_lnums(int do_curwin); +void check_lnums_nested(int do_curwin); void reset_lnums(void); void make_snapshot(int idx); void restore_snapshot(int idx, int close_curwin); diff --git a/src/quickfix.c b/src/quickfix.c index c37caa50d4..49484e0602 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -7209,18 +7209,18 @@ qf_add_entry_from_dict( if (first_entry) did_bufnr_emsg = FALSE; - filename = dict_get_string(d, (char_u *)"filename", TRUE); - module = dict_get_string(d, (char_u *)"module", TRUE); - bufnum = (int)dict_get_number(d, (char_u *)"bufnr"); - lnum = (int)dict_get_number(d, (char_u *)"lnum"); - end_lnum = (int)dict_get_number(d, (char_u *)"end_lnum"); - col = (int)dict_get_number(d, (char_u *)"col"); - end_col = (int)dict_get_number(d, (char_u *)"end_col"); - vcol = (int)dict_get_number(d, (char_u *)"vcol"); - nr = (int)dict_get_number(d, (char_u *)"nr"); - type = dict_get_string(d, (char_u *)"type", TRUE); - pattern = dict_get_string(d, (char_u *)"pattern", TRUE); - text = dict_get_string(d, (char_u *)"text", TRUE); + filename = dict_get_string(d, "filename", TRUE); + module = dict_get_string(d, "module", TRUE); + bufnum = (int)dict_get_number(d, "bufnr"); + lnum = (int)dict_get_number(d, "lnum"); + end_lnum = (int)dict_get_number(d, "end_lnum"); + col = (int)dict_get_number(d, "col"); + end_col = (int)dict_get_number(d, "end_col"); + vcol = (int)dict_get_number(d, "vcol"); + nr = (int)dict_get_number(d, "nr"); + type = dict_get_string(d, "type", TRUE); + pattern = dict_get_string(d, "pattern", TRUE); + text = dict_get_string(d, "text", TRUE); if (text == NULL) text = vim_strsave((char_u *)""); @@ -7243,7 +7243,7 @@ qf_add_entry_from_dict( // If the 'valid' field is present it overrules the detected value. if (dict_has_key(d, "valid")) - valid = (int)dict_get_bool(d, (char_u *)"valid", FALSE); + valid = (int)dict_get_bool(d, "valid", FALSE); status = qf_add_entry(qfl, NULL, // dir @@ -7419,7 +7419,7 @@ qf_setprop_title(qf_info_T *qi, int qf_idx, dict_T *what, dictitem_T *di) return FAIL; vim_free(qfl->qf_title); - qfl->qf_title = dict_get_string(what, (char_u *)"title", TRUE); + qfl->qf_title = dict_get_string(what, "title", TRUE); if (qf_idx == qi->qf_curlist) qf_update_win_titlevar(qi); diff --git a/src/search.c b/src/search.c index 5a8122ad3e..961b659ee2 100644 --- a/src/search.c +++ b/src/search.c @@ -4130,7 +4130,7 @@ f_searchcount(typval_T *argvars, typval_T *rettv) if (error) return; } - recompute = dict_get_bool(dict, (char_u *)"recompute", recompute); + recompute = dict_get_bool(dict, "recompute", recompute); di = dict_find(dict, (char_u *)"pattern", -1); if (di != NULL) { @@ -4660,7 +4660,8 @@ fuzzy_match_in_list( // For a dict, either use the specified key to lookup the string or // use the specified callback function to get the string. if (key != NULL) - itemstr = dict_get_string(li->li_tv.vval.v_dict, key, FALSE); + itemstr = dict_get_string(li->li_tv.vval.v_dict, + (char *)key, FALSE); else { typval_T argv[2]; diff --git a/src/sign.c b/src/sign.c index ee36d33543..d870d6e702 100644 --- a/src/sign.c +++ b/src/sign.c @@ -2267,7 +2267,7 @@ sign_define_from_dict(char_u *name_arg, dict_T *dict) { if (dict == NULL) return -1; - name = dict_get_string(dict, (char_u *)"name", TRUE); + name = dict_get_string(dict, "name", TRUE); } else name = vim_strsave(name_arg); @@ -2275,12 +2275,12 @@ sign_define_from_dict(char_u *name_arg, dict_T *dict) goto cleanup; if (dict != NULL) { - icon = dict_get_string(dict, (char_u *)"icon", TRUE); - linehl = dict_get_string(dict, (char_u *)"linehl", TRUE); - text = dict_get_string(dict, (char_u *)"text", TRUE); - texthl = dict_get_string(dict, (char_u *)"texthl", TRUE); - culhl = dict_get_string(dict, (char_u *)"culhl", TRUE); - numhl = dict_get_string(dict, (char_u *)"numhl", TRUE); + icon = dict_get_string(dict, "icon", TRUE); + linehl = dict_get_string(dict, "linehl", TRUE); + text = dict_get_string(dict, "text", TRUE); + texthl = dict_get_string(dict, "texthl", TRUE); + culhl = dict_get_string(dict, "culhl", TRUE); + numhl = dict_get_string(dict, "numhl", TRUE); } if (sign_define_by_name(name, icon, linehl, text, texthl, culhl, numhl) == OK) @@ -2765,7 +2765,7 @@ sign_unplace_from_dict(typval_T *group_tv, dict_T *dict) if (group_tv != NULL) group = tv_get_string(group_tv); else - group = dict_get_string(dict, (char_u *)"group", FALSE); + group = dict_get_string(dict, "group", FALSE); if (group != NULL) { if (group[0] == '\0') // global sign group @@ -2788,7 +2788,7 @@ sign_unplace_from_dict(typval_T *group_tv, dict_T *dict) } if (dict_has_key(dict, "id")) { - sign_id = dict_get_number(dict, (char_u *)"id"); + sign_id = dict_get_number(dict, "id"); if (sign_id <= 0) { emsg(_(e_invalid_argument)); diff --git a/src/tag.c b/src/tag.c index 1fe2eefdbd..f89d057dd8 100644 --- a/src/tag.c +++ b/src/tag.c @@ -4589,17 +4589,16 @@ tagstack_push_items(win_T *wp, list_T *l) continue; if (list2fpos(&di->di_tv, &mark, &fnum, NULL, FALSE) != OK) continue; - if ((tagname = - dict_get_string(itemdict, (char_u *)"tagname", TRUE)) == NULL) + if ((tagname = dict_get_string(itemdict, "tagname", TRUE)) == NULL) continue; if (mark.col > 0) mark.col--; tagstack_push_item(wp, tagname, - (int)dict_get_number(itemdict, (char_u *)"bufnr"), - (int)dict_get_number(itemdict, (char_u *)"matchnr") - 1, + (int)dict_get_number(itemdict, "bufnr"), + (int)dict_get_number(itemdict, "matchnr") - 1, mark, fnum, - dict_get_string(itemdict, (char_u *)"user_data", TRUE)); + dict_get_string(itemdict, "user_data", TRUE)); } } diff --git a/src/terminal.c b/src/terminal.c index bee37a638d..cd03d06fc7 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -4343,9 +4343,9 @@ handle_drop_command(listitem_T *item) dict_T *dict = opt_item->li_tv.vval.v_dict; char_u *p; - p = dict_get_string(dict, (char_u *)"ff", FALSE); + p = dict_get_string(dict, "ff", FALSE); if (p == NULL) - p = dict_get_string(dict, (char_u *)"fileformat", FALSE); + p = dict_get_string(dict, "fileformat", FALSE); if (p != NULL) { if (check_ff_value(p) == FAIL) @@ -4353,9 +4353,9 @@ handle_drop_command(listitem_T *item) else ea.force_ff = *p; } - p = dict_get_string(dict, (char_u *)"enc", FALSE); + p = dict_get_string(dict, "enc", FALSE); if (p == NULL) - p = dict_get_string(dict, (char_u *)"encoding", FALSE); + p = dict_get_string(dict, "encoding", FALSE); if (p != NULL) { ea.cmd = alloc(STRLEN(p) + 12); @@ -4367,7 +4367,7 @@ handle_drop_command(listitem_T *item) } } - p = dict_get_string(dict, (char_u *)"bad", FALSE); + p = dict_get_string(dict, "bad", FALSE); if (p != NULL) get_bad_opt(p, &ea); @@ -5000,8 +5000,8 @@ f_term_dumpwrite(typval_T *argvars, typval_T *rettv UNUSED) d = argvars[2].vval.v_dict; if (d != NULL) { - max_height = dict_get_number(d, (char_u *)"rows"); - max_width = dict_get_number(d, (char_u *)"columns"); + max_height = dict_get_number(d, "rows"); + max_width = dict_get_number(d, "columns"); } } diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index 0f86eae3d8..48d9491ae9 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -125,7 +125,6 @@ NEW_TESTS = \ test_expand_func \ test_expr \ test_expr_utf8 \ - test_feedkeys \ test_file_perm \ test_file_size \ test_filechanged \ @@ -164,6 +163,7 @@ NEW_TESTS = \ test_increment \ test_increment_dbcs \ test_indent \ + test_input \ test_ins_complete \ test_ins_complete_no_halt \ test_interrupt \ @@ -409,6 +409,7 @@ NEW_TESTS_RES = \ test_increment.res \ test_increment_dbcs.res \ test_indent.res \ + test_input.res \ test_ins_complete.res \ test_ins_complete_no_halt.res \ test_interrupt.res \ diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim index 845c117f65..46af3449b9 100644 --- a/src/testdir/test_alot.vim +++ b/src/testdir/test_alot.vim @@ -11,7 +11,6 @@ source test_ex_mode.vim source test_expand.vim source test_expand_dllpath.vim source test_expand_func.vim -source test_feedkeys.vim source test_file_perm.vim source test_fnamemodify.vim source test_ga.vim diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index cb07c7a38f..aa5171ce8c 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -2301,6 +2301,25 @@ func Test_autocmd_nested() call assert_fails('au WinNew * nested nested echo bad', 'E983:') endfunc +func Test_autocmd_nested_cursor_invalid() + set laststatus=0 + copen + cclose + call setline(1, ['foo', 'bar', 'baz']) + 3 + augroup nested_inv + autocmd User foo ++nested copen + autocmd BufAdd * let &laststatus = 2 - &laststatus + augroup END + doautocmd User foo + + augroup nested_inv + au! + augroup END + set laststatus& + bwipe! +endfunc + func Test_autocmd_once() " Without ++once WinNew triggers twice let g:did_split = 0 diff --git a/src/testdir/test_cmdwin.vim b/src/testdir/test_cmdwin.vim index 45ecdd11c6..d641b29230 100644 --- a/src/testdir/test_cmdwin.vim +++ b/src/testdir/test_cmdwin.vim @@ -356,5 +356,14 @@ func Test_cmdwin_ctrl_bsl() call assert_equal('', getcmdwintype()) endfunc +func Test_cant_open_cmdwin_in_cmdwin() + try + call feedkeys("q:q::q\", "x!") + catch + let caught = v:exception + endtry + call assert_match('E1292:', caught) +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim index 47ba120222..fb3f1744a7 100644 --- a/src/testdir/test_gui.vim +++ b/src/testdir/test_gui.vim @@ -1618,4 +1618,88 @@ func Test_gui_dialog_file() call delete('Xlines') endfunc +" Test for sending low level key presses +func SendKeys(keylist) + for k in a:keylist + call test_gui_event("sendevent", #{event: "keydown", keycode: k}) + endfor + for k in reverse(a:keylist) + call test_gui_event("sendevent", #{event: "keyup", keycode: k}) + endfor +endfunc + +func Test_gui_lowlevel_keyevent() + CheckMSWindows + new + + " Test for to keys + for kc in range(65, 90) + call SendKeys([0x11, kc]) + let ch = getcharstr() + call assert_equal(nr2char(kc - 64), ch) + endfor + + " Test for the various Ctrl and Shift key combinations. + let keytests = [ + \ [[0x10, 0x21], "\", 2], + \ [[0x11, 0x21], "\", 4], + \ [[0x10, 0x22], "\", 2], + \ [[0x11, 0x22], "\", 4], + \ [[0x10, 0x23], "\", 0], + \ [[0x11, 0x23], "\", 0], + \ [[0x10, 0x24], "\", 0], + \ [[0x11, 0x24], "\", 0], + \ [[0x10, 0x25], "\", 0], + \ [[0x11, 0x25], "\", 0], + \ [[0x10, 0x26], "\", 0], + \ [[0x11, 0x26], "\", 4], + \ [[0x10, 0x27], "\", 0], + \ [[0x11, 0x27], "\", 0], + \ [[0x10, 0x28], "\", 0], + \ [[0x11, 0x28], "\", 4], + \ [[0x11, 0x30], "\", 4], + \ [[0x11, 0x31], "\", 4], + \ [[0x11, 0x32], "\", 4], + \ [[0x11, 0x33], "\", 4], + \ [[0x11, 0x34], "\", 4], + \ [[0x11, 0x35], "\", 4], + \ [[0x11, 0x36], "\", 0], + \ [[0x11, 0x37], "\", 4], + \ [[0x11, 0x38], "\", 4], + \ [[0x11, 0x39], "\", 4], + \ [[0x11, 0x60], "\", 4], + \ [[0x11, 0x61], "\", 4], + \ [[0x11, 0x62], "\", 4], + \ [[0x11, 0x63], "\", 4], + \ [[0x11, 0x64], "\", 4], + \ [[0x11, 0x65], "\", 4], + \ [[0x11, 0x66], "\", 4], + \ [[0x11, 0x67], "\", 4], + \ [[0x11, 0x68], "\", 4], + \ [[0x11, 0x69], "\", 4], + \ [[0x11, 0x6A], "\", 4], + \ [[0x11, 0x6B], "\", 4], + \ [[0x11, 0x6D], "\", 4], + \ [[0x11, 0x70], "\", 4], + \ [[0x11, 0x71], "\", 4], + \ [[0x11, 0x72], "\", 4], + \ [[0x11, 0x73], "\", 4], + \ [[0x11, 0x74], "\", 4], + \ [[0x11, 0x75], "\", 4], + \ [[0x11, 0x76], "\", 4], + \ [[0x11, 0x77], "\", 4], + \ [[0x11, 0x78], "\", 4], + \ ] + + for [kcodes, kstr, kmod] in keytests + call SendKeys(kcodes) + let ch = getcharstr() + let mod = getcharmod() + call assert_equal(kstr, ch, $"key = {kstr}") + call assert_equal(kmod, mod) + endfor + + bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_feedkeys.vim b/src/testdir/test_input.vim similarity index 57% rename from src/testdir/test_feedkeys.vim rename to src/testdir/test_input.vim index fb64711863..3b1e2eb2df 100644 --- a/src/testdir/test_feedkeys.vim +++ b/src/testdir/test_input.vim @@ -1,4 +1,4 @@ -" Test feedkeys() function. +" Tests for character input and feedkeys() function. func Test_feedkeys_x_with_empty_string() new @@ -34,4 +34,28 @@ func Test_feedkeys_escape_special() nunmap … endfunc +func Test_input_simplify_ctrl_at() + new + " feeding unsimplified CTRL-@ should still trigger i_CTRL-@ + call feedkeys("ifoo\A\<*C-@>x", 'xt') + call assert_equal('foofo', getline(1)) + bw! +endfunc + +func Test_input_simplify_noremap() + call feedkeys("i\<*C-M>", 'nx') + call assert_equal('', getline(1)) + call assert_equal([0, 2, 1, 0, 1], getcurpos()) + bw! +endfunc + +func Test_input_simplify_timedout() + inoremap a b + call feedkeys("i\<*C-M>", 'xt') + call assert_equal('', getline(1)) + call assert_equal([0, 2, 1, 0, 1], getcurpos()) + iunmap a + bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim index 2be6d06020..7bebc5d8a9 100644 --- a/src/testdir/test_ins_complete.vim +++ b/src/testdir/test_ins_complete.vim @@ -2108,6 +2108,13 @@ func Test_infercase_very_long_line() exe "normal 2Go\\\" call assert_equal(longLine, getline(3)) + " check that the too long text is NUL terminated + %del + norm o + norm 1987ax + exec "norm ox\\" + call assert_equal(repeat('x', 1987), getline(3)) + bwipe! set noic noinfercase endfunc diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim index 3c5b77e0f0..551f777cfd 100644 --- a/src/testdir/test_options.vim +++ b/src/testdir/test_options.vim @@ -65,7 +65,9 @@ func Test_pastetoggle() let &pastetoggle = str call assert_equal(str, &pastetoggle) call assert_equal("\n pastetoggle=" .. strtrans(str), execute('set pastetoggle?')) + unlet str + set pastetoggle& endfunc func Test_wildchar() @@ -904,7 +906,6 @@ endfunc func Test_rightleftcmd() CheckFeature rightleft set rightleft - set rightleftcmd let g:l = [] func AddPos() @@ -913,6 +914,13 @@ func Test_rightleftcmd() endfunc cmap AddPos() + set rightleftcmd= + call feedkeys("/\abc\\\\\" .. + \ "\\\", 'xt') + call assert_equal([2, 5, 3, 4], g:l) + + let g:l = [] + set rightleftcmd=search call feedkeys("/\abc\\\\\" .. \ "\\\", 'xt') call assert_equal([&co - 1, &co - 4, &co - 2, &co - 3], g:l) diff --git a/src/testdir/test_statusline.vim b/src/testdir/test_statusline.vim index 7c75f61a87..e60140fe2c 100644 --- a/src/testdir/test_statusline.vim +++ b/src/testdir/test_statusline.vim @@ -7,6 +7,14 @@ source view_util.vim source check.vim source screendump.vim +func SetUp() + set laststatus=2 +endfunc + +func TearDown() + set laststatus& +endfunc + func s:get_statusline() return ScreenLines(&lines - 1, &columns)[0] endfunc @@ -35,7 +43,6 @@ endfunc func Test_caught_error_in_statusline() let s:func_in_statusline_called = 0 - set laststatus=2 let statusline = '%{StatuslineWithCaughtError()}' let &statusline = statusline redrawstatus @@ -46,7 +53,6 @@ endfunc func Test_statusline_will_be_disabled_with_error() let s:func_in_statusline_called = 0 - set laststatus=2 let statusline = '%{StatuslineWithError()}' try let &statusline = statusline @@ -73,7 +79,6 @@ func Test_statusline() call assert_match('^ ((2) of 2)\s*$', s:get_statusline()) only - set laststatus=2 set splitbelow call setline(1, range(1, 10000)) @@ -432,7 +437,6 @@ func Test_statusline() %bw! call delete('Xstatusline') set statusline& - set laststatus& set splitbelow& endfunc @@ -518,7 +522,6 @@ endfunc " with a custom 'statusline' func Test_statusline_mbyte_fillchar() only - set laststatus=2 set fillchars=vert:\|,fold:-,stl:━,stlnc:═ set statusline=a%=b call assert_match('^a\+━\+b$', s:get_statusline()) @@ -526,7 +529,7 @@ func Test_statusline_mbyte_fillchar() call assert_match('^a\+━\+b━a\+═\+b$', s:get_statusline()) wincmd w call assert_match('^a\+═\+b═a\+━\+b$', s:get_statusline()) - set statusline& fillchars& laststatus& + set statusline& fillchars& %bw! endfunc diff --git a/src/testdir/test_termcodes.vim b/src/testdir/test_termcodes.vim index 87c04745a1..6e4bbd19ca 100644 --- a/src/testdir/test_termcodes.vim +++ b/src/testdir/test_termcodes.vim @@ -2437,28 +2437,5 @@ func Test_terminal_builtin_without_gui() call assert_notequal(-1, index(output, 'builtin_dumb')) endfunc -func Test_simplify_ctrl_at() - " feeding unsimplified CTRL-@ should still trigger i_CTRL-@ - call feedkeys("ifoo\A\<*C-@>x", 'xt') - call assert_equal('foofo', getline(1)) - bw! -endfunc - -func Test_simplify_noremap() - call feedkeys("i\<*C-M>", 'nx') - call assert_equal('', getline(1)) - call assert_equal([0, 2, 1, 0, 1], getcurpos()) - bw! -endfunc - -func Test_simplify_timedout() - inoremap a b - call feedkeys("i\<*C-M>", 'xt') - call assert_equal('', getline(1)) - call assert_equal([0, 2, 1, 0, 1], getcurpos()) - iunmap a - bw! -endfunc - " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_timers.vim b/src/testdir/test_timers.vim index 7a5cc29f5a..338be10ff6 100644 --- a/src/testdir/test_timers.vim +++ b/src/testdir/test_timers.vim @@ -369,7 +369,7 @@ endfunc " Test that the garbage collector isn't triggered if a timer callback invokes " vgetc(). -func Test_timer_nocatch_garbage_collect() +func Test_nocatch_timer_garbage_collect() " 'uptimetime. must be bigger than the timer timeout set ut=200 call test_garbagecollect_soon() diff --git a/src/testing.c b/src/testing.c index 66a3281d8f..f2355f5dac 100644 --- a/src/testing.c +++ b/src/testing.c @@ -1295,10 +1295,10 @@ test_gui_drop_files(dict_T *args UNUSED) || !dict_has_key(args, "modifiers")) return FALSE; - (void)dict_get_tv(args, (char_u *)"files", &t); - row = (int)dict_get_number(args, (char_u *)"row"); - col = (int)dict_get_number(args, (char_u *)"col"); - mods = (int)dict_get_number(args, (char_u *)"modifiers"); + (void)dict_get_tv(args, "files", &t); + row = (int)dict_get_number(args, "row"); + col = (int)dict_get_number(args, "col"); + mods = (int)dict_get_number(args, "modifiers"); if (t.v_type != VAR_LIST || list_len(t.vval.v_list) == 0) return FALSE; @@ -1351,10 +1351,10 @@ test_gui_find_repl(dict_T *args) || !dict_has_key(args, "forward")) return FALSE; - find_text = dict_get_string(args, (char_u *)"find_text", TRUE); - repl_text = dict_get_string(args, (char_u *)"repl_text", TRUE); - flags = (int)dict_get_number(args, (char_u *)"flags"); - forward = (int)dict_get_number(args, (char_u *)"forward"); + find_text = dict_get_string(args, "find_text", TRUE); + repl_text = dict_get_string(args, "repl_text", TRUE); + flags = (int)dict_get_number(args, "flags"); + forward = (int)dict_get_number(args, "forward"); retval = gui_do_findrepl(flags, find_text, repl_text, forward); vim_free(find_text); @@ -1379,19 +1379,19 @@ test_gui_mouse_event(dict_T *args) return FALSE; // Note: "move" is optional, requires fewer arguments - move = (int)dict_get_bool(args, (char_u *)"move", FALSE); + move = (int)dict_get_bool(args, "move", FALSE); if (!move && (!dict_has_key(args, "button") || !dict_has_key(args, "multiclick") || !dict_has_key(args, "modifiers"))) return FALSE; - row = (int)dict_get_number(args, (char_u *)"row"); - col = (int)dict_get_number(args, (char_u *)"col"); + row = (int)dict_get_number(args, "row"); + col = (int)dict_get_number(args, "col"); if (move) { - if (dict_get_bool(args, (char_u *)"cell", FALSE)) + if (dict_get_bool(args, "cell", FALSE)) { // click in the middle of the character cell row = row * gui.char_height + gui.char_height / 2; @@ -1401,9 +1401,9 @@ test_gui_mouse_event(dict_T *args) } else { - button = (int)dict_get_number(args, (char_u *)"button"); - repeated_click = (int)dict_get_number(args, (char_u *)"multiclick"); - mods = (int)dict_get_number(args, (char_u *)"modifiers"); + button = (int)dict_get_number(args, "button"); + repeated_click = (int)dict_get_number(args, "multiclick"); + mods = (int)dict_get_number(args, "modifiers"); // Reset the scroll values to known values. // XXX: Remove this when/if the scroll step is made configurable. @@ -1430,9 +1430,9 @@ test_gui_scrollbar(dict_T *args) || !dict_has_key(args, "dragging")) return FALSE; - which = dict_get_string(args, (char_u *)"which", FALSE); - value = (long)dict_get_number(args, (char_u *)"value"); - dragging = (int)dict_get_number(args, (char_u *)"dragging"); + which = dict_get_string(args, "which", FALSE); + value = (long)dict_get_number(args, "value"); + dragging = (int)dict_get_number(args, "dragging"); if (STRCMP(which, "left") == 0) sb = &curwin->w_scrollbars[SBAR_LEFT]; @@ -1463,7 +1463,7 @@ test_gui_tabline_event(dict_T *args UNUSED) if (!dict_has_key(args, "tabnr")) return FALSE; - tabnr = (int)dict_get_number(args, (char_u *)"tabnr"); + tabnr = (int)dict_get_number(args, "tabnr"); return send_tabline_event(tabnr); # else @@ -1482,8 +1482,8 @@ test_gui_tabmenu_event(dict_T *args UNUSED) || !dict_has_key(args, "item")) return FALSE; - tabnr = (int)dict_get_number(args, (char_u *)"tabnr"); - item = (int)dict_get_number(args, (char_u *)"item"); + tabnr = (int)dict_get_number(args, "tabnr"); + item = (int)dict_get_number(args, "item"); send_tabline_menu_event(tabnr, item); # endif @@ -1500,6 +1500,12 @@ f_test_gui_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED) rettv->v_type = VAR_BOOL; rettv->vval.v_number = FALSE; + if (sandbox != 0) + { + emsg(_(e_not_allowed_in_sandbox)); + return; + } + if (check_for_string_arg(argvars, 0) == FAIL || check_for_dict_arg(argvars, 1) == FAIL || argvars[1].vval.v_dict == NULL) @@ -1520,6 +1526,10 @@ f_test_gui_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED) rettv->vval.v_number = test_gui_tabline_event(argvars[1].vval.v_dict); else if (STRCMP(event, "tabmenu") == 0) rettv->vval.v_number = test_gui_tabmenu_event(argvars[1].vval.v_dict); +# ifdef FEAT_GUI_MSWIN + else if (STRCMP(event, "sendevent") == 0) + rettv->vval.v_number = test_gui_w32_sendevent(argvars[1].vval.v_dict); +# endif else { semsg(_(e_invalid_argument_str), event); diff --git a/src/textprop.c b/src/textprop.c index 2924192a4d..5c07195f4f 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -336,10 +336,10 @@ f_prop_add_list(typval_T *argvars, typval_T *rettv UNUSED) emsg(_(e_missing_property_type_name)); return; } - type_name = dict_get_string(dict, (char_u *)"type", FALSE); + type_name = dict_get_string(dict, "type", FALSE); if (dict_has_key(dict, "id")) - id = dict_get_number(dict, (char_u *)"id"); + id = dict_get_number(dict, "id"); if (get_bufnr_from_arg(&argvars[0], &buf) == FAIL) return; @@ -399,11 +399,11 @@ prop_add_common( emsg(_(e_missing_property_type_name)); return; } - type_name = dict_get_string(dict, (char_u *)"type", FALSE); + type_name = dict_get_string(dict, "type", FALSE); if (dict_has_key(dict, "end_lnum")) { - end_lnum = dict_get_number(dict, (char_u *)"end_lnum"); + end_lnum = dict_get_number(dict, "end_lnum"); if (end_lnum < start_lnum) { semsg(_(e_invalid_value_for_argument_str), "end_lnum"); @@ -415,7 +415,7 @@ prop_add_common( if (dict_has_key(dict, "length")) { - long length = dict_get_number(dict, (char_u *)"length"); + long length = dict_get_number(dict, "length"); if (length < 0 || end_lnum > start_lnum) { @@ -426,7 +426,7 @@ prop_add_common( } else if (dict_has_key(dict, "end_col")) { - end_col = dict_get_number(dict, (char_u *)"end_col"); + end_col = dict_get_number(dict, "end_col"); if (end_col <= 0) { semsg(_(e_invalid_value_for_argument_str), "end_col"); @@ -439,7 +439,7 @@ prop_add_common( end_col = 1; if (dict_has_key(dict, "id")) - id = dict_get_number(dict, (char_u *)"id"); + id = dict_get_number(dict, "id"); if (dict_arg != NULL && get_bufnr_from_arg(dict_arg, &buf) == FAIL) return; @@ -784,23 +784,23 @@ f_prop_find(typval_T *argvars, typval_T *rettv) return; } - skipstart = dict_get_bool(dict, (char_u *)"skipstart", 0); + skipstart = dict_get_bool(dict, "skipstart", 0); if (dict_has_key(dict, "id")) { - id = dict_get_number(dict, (char_u *)"id"); + id = dict_get_number(dict, "id"); id_found = TRUE; } if (dict_has_key(dict, "type")) { - char_u *name = dict_get_string(dict, (char_u *)"type", FALSE); + char_u *name = dict_get_string(dict, "type", FALSE); proptype_T *type = lookup_prop_type(name, buf); if (type == NULL) return; type_id = type->pt_id; } - both = dict_get_bool(dict, (char_u *)"both", FALSE); + both = dict_get_bool(dict, "both", FALSE); if (!id_found && type_id == -1) { emsg(_(e_need_at_least_one_of_id_or_type)); @@ -1213,20 +1213,20 @@ f_prop_remove(typval_T *argvars, typval_T *rettv) if (buf->b_ml.ml_mfp == NULL) return; - do_all = dict_get_bool(dict, (char_u *)"all", FALSE); + do_all = dict_get_bool(dict, "all", FALSE); if (dict_has_key(dict, "id")) - id = dict_get_number(dict, (char_u *)"id"); + id = dict_get_number(dict, "id"); if (dict_has_key(dict, "type")) { - char_u *name = dict_get_string(dict, (char_u *)"type", FALSE); + char_u *name = dict_get_string(dict, "type", FALSE); proptype_T *type = lookup_prop_type(name, buf); if (type == NULL) return; type_id = type->pt_id; } - both = dict_get_bool(dict, (char_u *)"both", FALSE); + both = dict_get_bool(dict, "both", FALSE); if (id == -1 && type_id == -1) { @@ -1383,7 +1383,7 @@ prop_type_set(typval_T *argvars, int add) char_u *highlight; int hl_id = 0; - highlight = dict_get_string(dict, (char_u *)"highlight", FALSE); + highlight = dict_get_string(dict, "highlight", FALSE); if (highlight != NULL && *highlight != NUL) hl_id = syn_name2id(highlight); if (hl_id <= 0) diff --git a/src/time.c b/src/time.c index 4adcce59fb..dc8594a2cd 100644 --- a/src/time.c +++ b/src/time.c @@ -863,7 +863,7 @@ f_timer_start(typval_T *argvars, typval_T *rettv) return; } if (dict_has_key(dict, "repeat")) - repeat = dict_get_number(dict, (char_u *)"repeat"); + repeat = dict_get_number(dict, "repeat"); } callback = get_callback(&argvars[1]); diff --git a/src/version.c b/src/version.c index b13dd05d9b..0f7418522c 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,22 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 65, +/**/ + 64, +/**/ + 63, +/**/ + 62, +/**/ + 61, +/**/ + 60, +/**/ + 59, +/**/ + 58, /**/ 57, /**/ diff --git a/src/vim.h b/src/vim.h index 1d53e45b60..e3f46c42fd 100644 --- a/src/vim.h +++ b/src/vim.h @@ -2830,7 +2830,7 @@ long elapsed(DWORD start_tick); #define UC_BUFFER 1 // -buffer: local to current buffer #define UC_VIM9 2 // {} argument: Vim9 syntax. -// flags used by vim_strsave_escaped() +// flags used by vim_strsave_fnameescape() #define VSE_NONE 0 #define VSE_SHELL 1 // escape for a shell command #define VSE_BUFFER 2 // escape for a ":buffer" command diff --git a/src/window.c b/src/window.c index 6c713bae18..cb2df2fe43 100644 --- a/src/window.c +++ b/src/window.c @@ -6783,12 +6783,10 @@ only_one_window(void) } /* - * Correct the cursor line number in other windows. Used after changing the - * current buffer, and before applying autocommands. - * When "do_curwin" is TRUE, also check current window. + * Implementation of check_lnums() and check_lnums_nested(). */ - void -check_lnums(int do_curwin) + static void +check_lnums_both(int do_curwin, int nested) { win_T *wp; tabpage_T *tp; @@ -6796,21 +6794,44 @@ check_lnums(int do_curwin) FOR_ALL_TAB_WINDOWS(tp, wp) if ((do_curwin || wp != curwin) && wp->w_buffer == curbuf) { - // save the original cursor position and topline - wp->w_save_cursor.w_cursor_save = wp->w_cursor; - wp->w_save_cursor.w_topline_save = wp->w_topline; + if (!nested) + { + // save the original cursor position and topline + wp->w_save_cursor.w_cursor_save = wp->w_cursor; + wp->w_save_cursor.w_topline_save = wp->w_topline; + } if (wp->w_cursor.lnum > curbuf->b_ml.ml_line_count) wp->w_cursor.lnum = curbuf->b_ml.ml_line_count; if (wp->w_topline > curbuf->b_ml.ml_line_count) wp->w_topline = curbuf->b_ml.ml_line_count; - // save the corrected cursor position and topline + // save the (corrected) cursor position and topline wp->w_save_cursor.w_cursor_corr = wp->w_cursor; wp->w_save_cursor.w_topline_corr = wp->w_topline; } } +/* + * Correct the cursor line number in other windows. Used after changing the + * current buffer, and before applying autocommands. + * When "do_curwin" is TRUE, also check current window. + */ + void +check_lnums(int do_curwin) +{ + check_lnums_both(do_curwin, FALSE); +} + +/* + * Like check_lnums() but for when check_lnums() was already called. + */ + void +check_lnums_nested(int do_curwin) +{ + check_lnums_both(do_curwin, TRUE); +} + /* * Reset cursor and topline to its stored values from check_lnums(). * check_lnums() must have been called first!