From 32884ad753ffb462d27998beb50678888209075f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 7 Jan 2022 12:45:29 +0000 Subject: [PATCH 01/28] patch 8.2.4024: confusing error message if imported name is used directly Problem: Confusing error message if imported name is used directly. Solution: Give a better error message. --- src/eval.c | 11 +++++++++-- src/evalvars.c | 7 ++++--- src/proto/eval.pro | 2 +- src/testdir/test_vim9_script.vim | 24 ++++++++++++++++++++++-- src/userfunc.c | 2 +- src/version.c | 2 ++ 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/eval.c b/src/eval.c index fe4dbd10bb..7fed2867d1 100644 --- a/src/eval.c +++ b/src/eval.c @@ -3481,6 +3481,7 @@ eval7( && (evalarg->eval_flags & EVAL_EVALUATE); int len; char_u *s; + char_u *name_start = NULL; char_u *start_leader, *end_leader; int ret = OK; char_u *alias; @@ -3713,8 +3714,11 @@ eval7( ret = OK; } else + { + name_start = s; ret = eval_variable(s, len, 0, rettv, NULL, EVAL_VAR_VERBOSE + EVAL_VAR_IMPORT); + } } else { @@ -3729,7 +3733,7 @@ eval7( // Handle following '[', '(' and '.' for expr[expr], expr.name, // expr(expr), expr->name(expr) if (ret == OK) - ret = handle_subscript(arg, rettv, evalarg, TRUE); + ret = handle_subscript(arg, name_start, rettv, evalarg, TRUE); /* * Apply logical NOT and unary '-', from right to left, ignore '+'. @@ -5891,10 +5895,12 @@ eval_isdictc(int c) * - method call: var->method() * * Can all be combined in any order: dict.func(expr)[idx]['func'](expr)->len() + * "name_start" points to a variable before the subscript or is NULL. */ int handle_subscript( char_u **arg, + char_u *name_start, typval_T *rettv, evalarg_T *evalarg, int verbose) // give error messages @@ -5936,7 +5942,8 @@ handle_subscript( if (**arg != '.') { if (verbose) - semsg(_(e_expected_str_but_got_str), "'.'", *arg); + semsg(_(e_expected_dot_after_name_str), + name_start != NULL ? name_start: *arg); ret = FAIL; break; } diff --git a/src/evalvars.c b/src/evalvars.c index 2de6f224b7..730c7d1228 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -1239,8 +1239,8 @@ list_arg_vars(exarg_T *eap, char_u *arg, int *first) { // handle d.key, l[idx], f(expr) arg_subsc = arg; - if (handle_subscript(&arg, &tv, &EVALARG_EVALUATE, TRUE) - == FAIL) + if (handle_subscript(&arg, name_start, &tv, + &EVALARG_EVALUATE, TRUE) == FAIL) error = TRUE; else { @@ -3955,7 +3955,8 @@ var_exists(char_u *var) { // handle d.key, l[idx], f(expr) arg = skipwhite(arg); - n = (handle_subscript(&arg, &tv, &EVALARG_EVALUATE, FALSE) == OK); + n = (handle_subscript(&arg, name, &tv, &EVALARG_EVALUATE, + FALSE) == OK); if (n) clear_tv(&tv); } diff --git a/src/proto/eval.pro b/src/proto/eval.pro index f7fa647375..ac4a51cd93 100644 --- a/src/proto/eval.pro +++ b/src/proto/eval.pro @@ -70,7 +70,7 @@ char_u *find_name_end(char_u *arg, char_u **expr_start, char_u **expr_end, int f int eval_isnamec(int c); int eval_isnamec1(int c); int eval_isdictc(int c); -int handle_subscript(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int verbose); +int handle_subscript(char_u **arg, char_u *name_start, typval_T *rettv, evalarg_T *evalarg, int verbose); int item_copy(typval_T *from, typval_T *to, int deep, int copyID); void echo_one(typval_T *rettv, int with_space, int *atstart, int *needclr); void ex_echo(exarg_T *eap); diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 4c5d9e9a0d..19eee76c78 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -1265,6 +1265,26 @@ def Test_vim9_import_export() unlet g:imported_func delete('Ximport_lbr.vim') + var line_break_before_dot =<< trim END + vim9script + import './Xexport.vim' as expo + g:exported = expo + .exported + END + writefile(line_break_before_dot, 'Ximport_lbr_before_dot.vim') + assert_fails('source Ximport_lbr_before_dot.vim', 'E1060:', '', 3) + delete('Ximport_lbr_before_dot.vim') + + var line_break_after_dot =<< trim END + vim9script + import './Xexport.vim' as expo + g:exported = expo. + exported + END + writefile(line_break_after_dot, 'Ximport_lbr_after_dot.vim') + assert_fails('source Ximport_lbr_after_dot.vim', 'E1074:', '', 3) + delete('Ximport_lbr_after_dot.vim') + var import_star_as_lines =<< trim END vim9script import './Xexport.vim' as Export @@ -1333,7 +1353,7 @@ def Test_vim9_import_export() g:imported_script = Export exported END writefile(import_star_as_lines_script_no_dot, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E1029:') + assert_fails('source Ximport.vim', 'E1060: Expected dot after name: Export exported') var import_star_as_lines_script_space_after_dot =<< trim END vim9script @@ -1519,7 +1539,7 @@ def Test_import_star_fails() import './Xfoo.vim' as foo var that = foo END - CheckScriptFailure(lines, 'E1029: Expected ''.''') + CheckScriptFailure(lines, 'E1060: Expected dot after name: foo') lines =<< trim END vim9script diff --git a/src/userfunc.c b/src/userfunc.c index f9bf5e3316..7446d6ec93 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -5170,7 +5170,7 @@ ex_call(exarg_T *eap) dbg_check_breakpoint(eap); // Handle a function returning a Funcref, Dictionary or List. - if (handle_subscript(&arg, &rettv, + if (handle_subscript(&arg, NULL, &rettv, eap->skip ? NULL : &EVALARG_EVALUATE, TRUE) == FAIL) { failed = TRUE; diff --git a/src/version.c b/src/version.c index cb331fa12c..d8fe3528fd 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4024, /**/ 4023, /**/ From 834d41853e12b9022f60b08c32480928c2a9e48f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 7 Jan 2022 13:38:24 +0000 Subject: [PATCH 02/28] patch 8.2.4025: error for import not ending in .vim does not work for .vimrc Problem: Error for import not ending in .vim does not work for .vimrc. Solution: Check that .vim is the end. (closes #9484) --- src/errors.h | 6 ++++-- src/testdir/test_vim9_script.vim | 31 +++++++++++++++++++++++++++++-- src/version.c | 2 ++ src/vim9script.c | 10 +++++++--- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/errors.h b/src/errors.h index 5aaaeacd8d..9facb82c4a 100644 --- a/src/errors.h +++ b/src/errors.h @@ -2881,11 +2881,13 @@ EXTERN char e_cmd_mapping_must_end_with_cr[] INIT(= N_("E1255: mapping must end with ")); EXTERN char e_string_or_function_required_for_argument_nr[] INIT(= N_("E1256: String or function required for argument %d")); -EXTERN char e_imported_script_must_end_in_dot_vim_str[] - INIT(= N_("E1257: Imported script must end in .vim: %s")); +EXTERN char e_imported_script_must_use_as_or_end_in_dot_vim_str[] + INIT(= N_("E1257: Imported script must use \"as\" or end in .vim: %s")); EXTERN char e_no_dot_after_imported_name_str[] INIT(= N_("E1258: No '.' after imported name: %s")); EXTERN char e_missing_name_after_imported_name_str[] INIT(= N_("E1259: Missing name after imported name: %s")); EXTERN char e_cannot_unlet_imported_item_str[] INIT(= N_("E1260: Cannot unlet an imported item: %s")); +EXTERN char e_cannot_import_dot_vim_without_using_as[] + INIT(= N_("E1261: Cannot import .vim without using \"as\"")); diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 19eee76c78..f4d59fde82 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -1527,7 +1527,7 @@ def Test_import_funcref() delete('Xlib.vim') enddef -def Test_import_star_fails() +def Test_import_fails() writefile([], 'Xfoo.vim') var lines =<< trim END import './Xfoo.vim' as foo @@ -1572,7 +1572,34 @@ def Test_import_star_fails() That() END CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use That itself']) - delete('Xthat.vim') + + mkdir('Xdir') + + writefile(['vim9script'], 'Xdir/.vim') + lines =<< trim END + vim9script + import './Xdir/.vim' + END + CheckScriptFailure(lines, 'E1261: Cannot import .vim without using "as"') + lines =<< trim END + vim9script + import './Xdir/.vim' as vim + END + CheckScriptSuccess(lines) + + writefile(['vim9script'], 'Xdir/.vimrc') + lines =<< trim END + vim9script + import './Xdir/.vimrc' + END + CheckScriptFailure(lines, 'E1257: Imported script must use "as" or end in .vim') + lines =<< trim END + vim9script + import './Xdir/.vimrc' as vimrc + END + CheckScriptSuccess(lines) + + delete('Xdir', 'rf') enddef func g:Trigger() diff --git a/src/version.c b/src/version.c index d8fe3528fd..b0bfc29192 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4025, /**/ 4024, /**/ diff --git a/src/vim9script.c b/src/vim9script.c index 81f396759c..4d16a2a7a5 100644 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -474,10 +474,14 @@ handle_import( semsg(_(e_trailing_characters_str), expr_end); goto erret; } - - if (end == NULL) + if (end == NULL || end[4] != NUL) { - semsg(_(e_imported_script_must_end_in_dot_vim_str), p); + semsg(_(e_imported_script_must_use_as_or_end_in_dot_vim_str), p); + goto erret; + } + if (end == p) + { + semsg(_(e_cannot_import_dot_vim_without_using_as), p); goto erret; } as_name = vim_strnsave(p, end - p); From e664a327014f4aa8baf8549a34a4caab2f3116a3 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 7 Jan 2022 14:08:03 +0000 Subject: [PATCH 03/28] patch 8.2.4026: ml_get error with specific win_execute() command Problem: ml_get error with specific win_execute() command. (Sean Dewar) Solution: Check cursor and Visual area are OK. --- src/evalwindow.c | 6 ++++++ src/testdir/test_execute_func.vim | 15 +++++++++++++++ src/version.c | 2 ++ 3 files changed, 23 insertions(+) diff --git a/src/evalwindow.c b/src/evalwindow.c index d29f3e4baa..2a97adcf26 100644 --- a/src/evalwindow.c +++ b/src/evalwindow.c @@ -743,6 +743,12 @@ f_win_execute(typval_T *argvars, typval_T *rettv) // Update the status line if the cursor moved. if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor)) wp->w_redr_status = TRUE; + + // In case the command moved the cursor or changed the Visual area, + // check it is valid. + check_cursor(); + if (VIsual_active) + check_pos(curbuf, &VIsual); } } diff --git a/src/testdir/test_execute_func.vim b/src/testdir/test_execute_func.vim index 0ca31cb6c6..8cd5e7d270 100644 --- a/src/testdir/test_execute_func.vim +++ b/src/testdir/test_execute_func.vim @@ -153,8 +153,23 @@ func Test_win_execute_visual_redraw() call setline(1, ['a', 'b', 'c']) new wincmd p + " start Visual in current window, redraw in other window with fewer lines call feedkeys("G\", 'txn') call win_execute(winnr('#')->win_getid(), 'redraw') + call feedkeys("\", 'txn') + bwipe! + bwipe! + + enew + new + call setline(1, ['a', 'b', 'c']) + let winid = win_getid() + wincmd p + " start Visual in current window, extend it in other window with more lines + call feedkeys("\", 'txn') + call win_execute(winid, 'call feedkeys("G\", ''txn'')') + redraw + bwipe! bwipe! endfunc diff --git a/src/version.c b/src/version.c index b0bfc29192..40c83bfb4a 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4026, /**/ 4025, /**/ From 2b04d5f1ef0dfaac1706e413947a7297285fa7b9 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 7 Jan 2022 14:39:56 +0000 Subject: [PATCH 04/28] patch 8.2.4027: import test fails on MS-Windows Problem: Import test fails on MS-Windows. Solution: Use a different directory name. --- src/testdir/test_vim9_script.vim | 16 ++++++++-------- src/version.c | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index f4d59fde82..faa26719df 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -1573,33 +1573,33 @@ def Test_import_fails() END CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use That itself']) - mkdir('Xdir') + mkdir('Ximport') - writefile(['vim9script'], 'Xdir/.vim') + writefile(['vim9script'], 'Ximport/.vim') lines =<< trim END vim9script - import './Xdir/.vim' + import './Ximport/.vim' END CheckScriptFailure(lines, 'E1261: Cannot import .vim without using "as"') lines =<< trim END vim9script - import './Xdir/.vim' as vim + import './Ximport/.vim' as vim END CheckScriptSuccess(lines) - writefile(['vim9script'], 'Xdir/.vimrc') + writefile(['vim9script'], 'Ximport/.vimrc') lines =<< trim END vim9script - import './Xdir/.vimrc' + import './Ximport/.vimrc' END CheckScriptFailure(lines, 'E1257: Imported script must use "as" or end in .vim') lines =<< trim END vim9script - import './Xdir/.vimrc' as vimrc + import './Ximport/.vimrc' as vimrc END CheckScriptSuccess(lines) - delete('Xdir', 'rf') + delete('Ximport', 'rf') enddef func g:Trigger() diff --git a/src/version.c b/src/version.c index 40c83bfb4a..731f8cef1d 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4027, /**/ 4026, /**/ From cb1956d6f2aece8ad93e19e5d4c7e0b5e405f056 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 7 Jan 2022 15:45:18 +0000 Subject: [PATCH 05/28] patch 8.2.4028: ml_get error with :doautoall and Visual area Problem: ml_get error with :doautoall and Visual area. (Sean Dewar) Solution: Disable Visual mode while executing autocommands. --- src/autocmd.c | 11 +++++++++-- src/structs.h | 1 + src/testdir/test_autocmd.vim | 10 ++++++++++ src/version.c | 2 ++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/autocmd.c b/src/autocmd.c index 862370fc6e..37f2480a88 100644 --- a/src/autocmd.c +++ b/src/autocmd.c @@ -1424,8 +1424,6 @@ ex_doautoall(exarg_T *eap) if (call_do_modelines && did_aucmd) do_modelines(0); } - - check_cursor(); // just in case lines got deleted } /* @@ -1532,6 +1530,10 @@ aucmd_prepbuf( curbuf = buf; aco->new_curwin_id = curwin->w_id; set_bufref(&aco->new_curbuf, curbuf); + + // disable the Visual area, the position may be invalid in another buffer + aco->save_VIsual_active = VIsual_active; + VIsual_active = FALSE; } /* @@ -1656,6 +1658,11 @@ win_found: check_cursor(); } } + + check_cursor(); // just in case lines got deleted + VIsual_active = aco->save_VIsual_active; + if (VIsual_active) + check_pos(curbuf, &VIsual); } static int autocmd_nested = FALSE; diff --git a/src/structs.h b/src/structs.h index 197df720c5..9d5768175f 100644 --- a/src/structs.h +++ b/src/structs.h @@ -4031,6 +4031,7 @@ typedef struct int save_prevwin_id; // ID of saved prevwin bufref_T new_curbuf; // new curbuf char_u *globaldir; // saved value of globaldir + int save_VIsual_active; // saved VIsual_active } aco_save_T; /* diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index b6f621dbff..1fc960f537 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -2812,6 +2812,16 @@ func Test_close_autocmd_tab() %bwipe! endfunc +func Test_Visual_doautoall_redraw() + call setline(1, ['a', 'b']) + new + wincmd p + call feedkeys("G\", 'txn') + autocmd User Explode ++once redraw + doautoall User Explode + %bwipe! +endfunc + " This was using freed memory. func Test_BufNew_arglocal() arglocal diff --git a/src/version.c b/src/version.c index 731f8cef1d..53202e5159 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4028, /**/ 4027, /**/ From b2d85e3784ac89f5209489844c1ee0f54d117abb Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 7 Jan 2022 16:55:32 +0000 Subject: [PATCH 06/28] patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong Problem: Debugging NFA regexp my crash, cached indent may be wrong. Solution: Fix some debug warnings in the NFA regexp code. Make sure log_fd is set when used. Fix breakindent and indent caching. (Christian Brabandt, closes #9482) --- src/indent.c | 55 ++++++++++++++++++++++++++++++------------------ src/optionstr.c | 11 ++++++++++ src/regexp_nfa.c | 53 +++++++++++++++++++++++++--------------------- src/version.c | 2 ++ 4 files changed, 76 insertions(+), 45 deletions(-) diff --git a/src/indent.c b/src/indent.c index 4a8b367259..b74bae6e69 100644 --- a/src/indent.c +++ b/src/indent.c @@ -915,13 +915,15 @@ get_breakindent_win( win_T *wp, char_u *line) // start of the line { - static int prev_indent = 0; // cached indent value - static long prev_ts = 0L; // cached tabstop value - static char_u *prev_line = NULL; // cached pointer to line + static int prev_indent = 0; // cached indent value + static long prev_ts = 0L; // cached tabstop value + static char_u *prev_line = NULL; // cached pointer to line static varnumber_T prev_tick = 0; // changedtick of cached value # ifdef FEAT_VARTABS - static int *prev_vts = NULL; // cached vartabs values + static int *prev_vts = NULL; // cached vartabs values # endif + static int prev_list = 0; // cached list value + static int prev_listopt = 0; // cached w_p_briopt_list value int bri = 0; // window width minus window margin space, i.e. what rests for text const int eff_wwidth = wp->w_width @@ -929,9 +931,10 @@ get_breakindent_win( && (vim_strchr(p_cpo, CPO_NUMCOL) == NULL) ? number_width(wp) + 1 : 0); - // used cached indent, unless pointer or 'tabstop' changed + // used cached indent, unless line, 'tabstop' or briopt_list changed if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts || prev_tick != CHANGEDTICK(wp->w_buffer) + || prev_listopt != wp->w_briopt_list # ifdef FEAT_VARTABS || prev_vts != wp->w_buffer->b_p_vts_array # endif @@ -949,6 +952,28 @@ get_breakindent_win( prev_indent = get_indent_str(line, (int)wp->w_buffer->b_p_ts, wp->w_p_list); # endif + prev_listopt = wp->w_briopt_list; + // add additional indent for numbered lists + if (wp->w_briopt_list != 0) + { + regmatch_T regmatch; + + regmatch.regprog = vim_regcomp(curbuf->b_p_flp, + RE_MAGIC + RE_STRING + RE_AUTO + RE_STRICT); + + if (regmatch.regprog != NULL) + { + regmatch.rm_ic = FALSE; + if (vim_regexec(®match, line, 0)) + { + if (wp->w_briopt_list > 0) + prev_list = wp->w_briopt_list; + else + prev_list = (*regmatch.endp - *regmatch.startp); + } + vim_regfree(regmatch.regprog); + } + } } bri = prev_indent + wp->w_briopt_shift; @@ -958,22 +983,10 @@ get_breakindent_win( // add additional indent for numbered lists if (wp->w_briopt_list != 0) { - regmatch_T regmatch; - - regmatch.regprog = vim_regcomp(curbuf->b_p_flp, - RE_MAGIC + RE_STRING + RE_AUTO + RE_STRICT); - if (regmatch.regprog != NULL) - { - regmatch.rm_ic = FALSE; - if (vim_regexec(®match, line, 0)) - { - if (wp->w_briopt_list > 0) - bri += wp->w_briopt_list; - else - bri = (*regmatch.endp - *regmatch.startp); - } - vim_regfree(regmatch.regprog); - } + if (wp->w_briopt_list > 0) + bri += prev_list; + else + bri = prev_list; } // indent minus the length of the showbreak string diff --git a/src/optionstr.c b/src/optionstr.c index 243d10fc8e..6cc4cf584f 100644 --- a/src/optionstr.c +++ b/src/optionstr.c @@ -756,6 +756,9 @@ did_set_string_option( { if (briopt_check(curwin) == FAIL) errmsg = e_invalid_argument; + // list setting requires a redraw + if (curwin->w_briopt_list) + redraw_all_later(NOT_VALID); } #endif @@ -2610,6 +2613,14 @@ ambw_end: update_package_paths_in_lua(); #endif +#if defined(FEAT_LINEBREAK) + // Changing Formatlistpattern when briopt includes the list setting: + // redraw + if ((varp == &p_flp || varp == &(curbuf->b_p_flp)) + && curwin->w_briopt_list) + redraw_all_later(NOT_VALID); +#endif + if (curwin->w_curswant != MAXCOL && (get_option_flags(opt_idx) & (P_CURSWANT | P_RALL)) != 0) curwin->w_set_curswant = TRUE; diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 9e4520c34c..39f7f8ba88 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -2885,7 +2885,7 @@ nfa_print_state2(FILE *debugf, nfa_state_T *state, garray_T *indent) char_u save[2]; STRNCPY(save, &p[last], 2); - STRNCPY(&p[last], "+-", 2); + memcpy(&p[last], "+-", 2); fprintf(debugf, " %s", p); STRNCPY(&p[last], save, 2); } @@ -4291,6 +4291,23 @@ sub_equal(regsub_T *sub1, regsub_T *sub2) } #ifdef ENABLE_LOG + static void +open_debug_log(int result) +{ + log_fd = fopen(NFA_REGEXP_RUN_LOG, "a"); + if (log_fd == NULL) + { + emsg(_(e_log_open_failed)); + log_fd = stderr; + } + + fprintf(log_fd, "****************************\n"); + fprintf(log_fd, "FINISHED RUNNING nfa_regmatch() recursively\n"); + fprintf(log_fd, "MATCH = %s\n", result == TRUE ? "OK" : result == MAYBE + ? "MAYBE" : "FALSE"); + fprintf(log_fd, "****************************\n"); +} + static void report_state(char *action, regsub_T *sub, @@ -4307,6 +4324,9 @@ report_state(char *action, else col = (int)(sub->list.line[0].start - rex.line); nfa_set_code(state->c); + if (log_fd == NULL) + open_debug_log(MAYBE); + fprintf(log_fd, "> %s state %d to list %d. char %d: %s (start col %d)%s\n", action, abs(state->id), lid, state->c, code, col, pim_info(pim)); @@ -5430,19 +5450,7 @@ recursive_regmatch( nfa_endp = save_nfa_endp; #ifdef ENABLE_LOG - log_fd = fopen(NFA_REGEXP_RUN_LOG, "a"); - if (log_fd != NULL) - { - fprintf(log_fd, "****************************\n"); - fprintf(log_fd, "FINISHED RUNNING nfa_regmatch() recursively\n"); - fprintf(log_fd, "MATCH = %s\n", result == TRUE ? "OK" : "FALSE"); - fprintf(log_fd, "****************************\n"); - } - else - { - emsg(_(e_log_open_failed)); - log_fd = stderr; - } + open_debug_log(result); #endif return result; @@ -5775,19 +5783,16 @@ nfa_regmatch( #ifdef ENABLE_LOG log_fd = fopen(NFA_REGEXP_RUN_LOG, "a"); - if (log_fd != NULL) - { - fprintf(log_fd, "**********************************\n"); - nfa_set_code(start->c); - fprintf(log_fd, " RUNNING nfa_regmatch() starting with state %d, code %s\n", - abs(start->id), code); - fprintf(log_fd, "**********************************\n"); - } - else + if (log_fd == NULL) { emsg(_(e_log_open_failed)); log_fd = stderr; } + fprintf(log_fd, "**********************************\n"); + nfa_set_code(start->c); + fprintf(log_fd, " RUNNING nfa_regmatch() starting with state %d, code %s\n", + abs(start->id), code); + fprintf(log_fd, "**********************************\n"); #endif thislist = &list[0]; @@ -6919,7 +6924,7 @@ nfa_regmatch( #ifdef DEBUG if (c < 0) - siemsg("INTERNAL: Negative state char: %ld", c); + siemsg("INTERNAL: Negative state char: %ld", (long)c); #endif result = (c == curc); diff --git a/src/version.c b/src/version.c index 53202e5159..5bd5f836d2 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4029, /**/ 4028, /**/ From 71f21938bc9f4f6c0e52c178f51cb19be9804690 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 7 Jan 2022 18:20:55 +0000 Subject: [PATCH 07/28] patch 8.2.4030: a script local funcref is not found from a mapping Problem: A script local funcref is not found from a mapping. Solution: When looking for a function, also find a script-local funcref. (closes #9485) --- src/evalvars.c | 31 ++++++++++++++++++- src/proto/evalvars.pro | 1 + src/testdir/test_vim9_script.vim | 51 ++++++++++++++++---------------- src/userfunc.c | 2 +- src/version.c | 2 ++ 5 files changed, 59 insertions(+), 28 deletions(-) diff --git a/src/evalvars.c b/src/evalvars.c index 730c7d1228..965b2048e4 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -2690,7 +2690,7 @@ eval_variable( { if ((flags & EVAL_VAR_IMPORT) == 0) { - if (sid != 0 && SCRIPT_ID_VALID(sid)) + if (SCRIPT_ID_VALID(sid)) { ht = &SCRIPT_VARS(sid); if (ht != NULL) @@ -2877,6 +2877,35 @@ find_var(char_u *name, hashtab_T **htp, int no_autoload) return NULL; } +/* + * Like find_var() but if the name starts with 99_ then look in the + * referenced script (used for a funcref). + */ + dictitem_T * +find_var_also_in_script(char_u *name, hashtab_T **htp, int no_autoload) +{ + if (STRNCMP(name, "", 5) == 0 && isdigit(name[5])) + { + char_u *p = name + 5; + int sid = getdigits(&p); + + if (SCRIPT_ID_VALID(sid) && *p == '_') + { + hashtab_T *ht = &SCRIPT_VARS(sid); + + if (ht != NULL) + { + dictitem_T *di = find_var_in_ht(ht, 0, p + 1, no_autoload); + + if (di != NULL) + return di; + } + } + } + + return find_var(name, htp, no_autoload); +} + /* * Find variable "varname" in hashtab "ht" with name "htname". * When "varname" is empty returns curwin/curtab/etc vars dictionary. diff --git a/src/proto/evalvars.pro b/src/proto/evalvars.pro index de1f7a1f3d..487f88b61d 100644 --- a/src/proto/evalvars.pro +++ b/src/proto/evalvars.pro @@ -60,6 +60,7 @@ char_u *set_cmdarg(exarg_T *eap, char_u *oldarg); int eval_variable(char_u *name, int len, scid_T sid, typval_T *rettv, dictitem_T **dip, int flags); void check_vars(char_u *name, int len); dictitem_T *find_var(char_u *name, hashtab_T **htp, int no_autoload); +dictitem_T *find_var_also_in_script(char_u *name, hashtab_T **htp, int no_autoload); dictitem_T *find_var_in_ht(hashtab_T *ht, int htname, char_u *varname, int no_autoload); hashtab_T *get_script_local_ht(void); int lookup_scriptitem(char_u *name, size_t len, int cmd, cctx_T *dummy); diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index faa26719df..b6dcf36212 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -1662,32 +1662,31 @@ def Test_import_in_filetype() &rtp = save_rtp enddef -" FIXME -"def Test_use_import_in_mapping() -" var lines =<< trim END -" vim9script -" export def Funcx() -" g:result = 42 -" enddef -" END -" writefile(lines, 'XsomeExport.vim') -" lines =<< trim END -" vim9script -" import './XsomeExport.vim' as some -" var Funcy = some.Funcx -" nnoremap :call Funcy() -" END -" writefile(lines, 'Xmapscript.vim') -" -" source Xmapscript.vim -" feedkeys("\", "xt") -" assert_equal(42, g:result) -" -" unlet g:result -" delete('XsomeExport.vim') -" delete('Xmapscript.vim') -" nunmap -"enddef +def Test_use_import_in_mapping() + var lines =<< trim END + vim9script + export def Funcx() + g:result = 42 + enddef + END + writefile(lines, 'XsomeExport.vim') + lines =<< trim END + vim9script + import './XsomeExport.vim' as some + var Funcy = some.Funcx + nnoremap :call Funcy() + END + writefile(lines, 'Xmapscript.vim') + + source Xmapscript.vim + feedkeys("\", "xt") + assert_equal(42, g:result) + + unlet g:result + delete('XsomeExport.vim') + delete('Xmapscript.vim') + nunmap +enddef def Test_vim9script_mix() var lines =<< trim END diff --git a/src/userfunc.c b/src/userfunc.c index 7446d6ec93..6821569b68 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -1589,7 +1589,7 @@ deref_func_name( cc = name[*lenp]; name[*lenp] = NUL; - v = find_var(name, &ht, no_autoload); + v = find_var_also_in_script(name, &ht, no_autoload); name[*lenp] = cc; if (v != NULL) { diff --git a/src/version.c b/src/version.c index 5bd5f836d2..5658467464 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4030, /**/ 4029, /**/ From d1f34e64f0e1a9ddaed76623bc40e669f2d09260 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 7 Jan 2022 19:24:20 +0000 Subject: [PATCH 08/28] patch 8.2.4031: crash in xterm with only two lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Crash in xterm with only two lines. (Dominique PellĂ©) Solution: Only perform xterm compatibility test if possible. (closes #9488) --- src/term.c | 2 +- src/testdir/test_startup.vim | 11 +++++++++++ src/version.c | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/term.c b/src/term.c index 85f6229342..853d93fefa 100644 --- a/src/term.c +++ b/src/term.c @@ -3801,7 +3801,7 @@ check_terminal_behavior(void) line_was_clobbered(1); } - if (xcc_status.tr_progress == STATUS_GET) + if (xcc_status.tr_progress == STATUS_GET && Rows > 2) { // 2. Check compatibility with xterm. // We move the cursor to (2, 0), print a test sequence and then query diff --git a/src/testdir/test_startup.vim b/src/testdir/test_startup.vim index d67bfb7777..1c1e1c0f3f 100644 --- a/src/testdir/test_startup.vim +++ b/src/testdir/test_startup.vim @@ -821,6 +821,17 @@ func Test_start_with_tabs() call StopVimInTerminal(buf) endfunc +func Test_start_in_minimal_window() + CheckRunVimInTerminal + + let buf = RunVimInTerminal('-c "set nomore"', {'cols': 12, 'rows': 2, 'keep_t_u7': 1}) + call term_sendkeys(buf, "ahello\") + call WaitForAssert({-> assert_match('^hello', term_getline(buf, 1))}) + + " clean up + call StopVimInTerminal(buf) +endfunc + func Test_v_argv() " Can't catch the output of gvim. CheckNotGui diff --git a/src/version.c b/src/version.c index 5658467464..cc9d81ea2b 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4031, /**/ 4030, /**/ From e12406526a24768e6121450112eb2f9f92445ac5 Mon Sep 17 00:00:00 2001 From: ichizok Date: Fri, 7 Jan 2022 20:01:07 +0000 Subject: [PATCH 09/28] patch 8.2.4032: ATTRIBUTE_NORETURN is not needed Problem: ATTRIBUTE_NORETURN is not needed. Solution: Use NORETURN(). (Ozaki Kiichi, closes #9487) --- src/if_ruby.c | 6 +++++- src/version.c | 2 ++ src/vim.h | 8 +++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/if_ruby.c b/src/if_ruby.c index fcbbf336e7..c58c3c5f13 100644 --- a/src/if_ruby.c +++ b/src/if_ruby.c @@ -502,7 +502,11 @@ static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...); # endif # endif # if RUBY_VERSION >= 31 -static void (*dll_rb_unexpected_type) (VALUE, int) ATTRIBUTE_NORETURN; +# ifdef _MSC_VER +static void (*dll_rb_unexpected_type) (VALUE, int); +# else +NORETURN(static void (*dll_rb_unexpected_type) (VALUE, int)); +# endif # endif # if RUBY_VERSION >= 18 static char * (*dll_rb_string_value_ptr) (volatile VALUE*); diff --git a/src/version.c b/src/version.c index cc9d81ea2b..78f1f2dec7 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4032, /**/ 4031, /**/ diff --git a/src/vim.h b/src/vim.h index 87fdbb1730..5d8f32e499 100644 --- a/src/vim.h +++ b/src/vim.h @@ -2178,15 +2178,13 @@ typedef struct stat stat_T; #endif #if defined(__GNUC__) || defined(__clang__) -# define likely(x) __builtin_expect((x), 1) -# define unlikely(x) __builtin_expect((x), 0) -# define ATTRIBUTE_COLD __attribute__((cold)) -# define ATTRIBUTE_NORETURN __attribute__((noreturn)) +# define likely(x) __builtin_expect((x), 1) +# define unlikely(x) __builtin_expect((x), 0) +# define ATTRIBUTE_COLD __attribute__((cold)) #else # define unlikely(x) (x) # define likely(x) (x) # define ATTRIBUTE_COLD -# define ATTRIBUTE_NORETURN #endif typedef enum { From a4c96252b12c9ebc0ba563694c064e500d707b06 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 7 Jan 2022 20:07:46 +0000 Subject: [PATCH 10/28] patch 8.2.4033: running filetype tests leaves directory behind Problem: Running filetype tests leaves directory behind. Solution: Delete the top directory. (closes #9483) --- src/testdir/test_filetype.vim | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim index d8a2d79f6e..b86f33dfd5 100644 --- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -1067,7 +1067,7 @@ func Test_dep3patch_file() call assert_notequal('dep3patch', &filetype) bwipe! - call delete('debian/patches', 'rf') + call delete('debian', 'rf') endfunc func Test_patch_file() diff --git a/src/version.c b/src/version.c index 78f1f2dec7..7f01ebe9f3 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4033, /**/ 4032, /**/ From 62a099cc6dbfc31c0ced3f6d895711208bf10518 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 7 Jan 2022 20:18:16 +0000 Subject: [PATCH 11/28] patch 8.2.4034: Coverity warns for possibly using a NULL pointer Problem: Coverity warns for possibly using a NULL pointer. Solution: Check v_partial is not NULL. --- src/version.c | 2 ++ src/vim9type.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/version.c b/src/version.c index 7f01ebe9f3..e2b5023e35 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4034, /**/ 4033, /**/ diff --git a/src/vim9type.c b/src/vim9type.c index f28b88f236..6671f5e3d4 100644 --- a/src/vim9type.c +++ b/src/vim9type.c @@ -375,7 +375,7 @@ typval2type_int(typval_T *tv, int copyID, garray_T *type_gap, int flags) set_function_type(ufunc); if (ufunc->uf_func_type != NULL) { - if (tv->v_type == VAR_PARTIAL + if (tv->v_type == VAR_PARTIAL && tv->vval.v_partial != NULL && tv->vval.v_partial->pt_argc > 0) { type = get_type_ptr(type_gap); From 48d0ac775cb2da3b5aa9d46711ff17c50ce0f707 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 7 Jan 2022 20:40:08 +0000 Subject: [PATCH 12/28] patch 8.2.4035: timer triggered at the debug prompt may cause trouble Problem: Timer triggered at the debug prompt may cause trouble. Solution: Do not trigger any timer at the debug prompt. (closes #9481) --- src/time.c | 5 +++-- src/version.c | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/time.c b/src/time.c index 001f2d8121..75e7b2546f 100644 --- a/src/time.c +++ b/src/time.c @@ -501,8 +501,9 @@ check_due_timer(void) int need_update_screen = FALSE; long current_id = last_timer_id; - // Don't run any timers while exiting or dealing with an error. - if (exiting || aborting()) + // Don't run any timers while exiting, dealing with an error or at the + // debug prompt. + if (exiting || aborting() || debug_mode) return next_due; profile_start(&now); diff --git a/src/version.c b/src/version.c index e2b5023e35..44d849ef5b 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4035, /**/ 4034, /**/ From d844862bcec5db210116847a67de93578ba781d7 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 7 Jan 2022 21:39:52 +0000 Subject: [PATCH 13/28] patch 8.2.4036: Vim9: script test file is getting too long Problem: Vim9: script test file is getting too long. Solution: Split the import/export functionality to a separate file. --- src/testdir/Make_all.mak | 2 + src/testdir/test_vim9_import.vim | 1069 ++++++++++++++++++++++++++++++ src/testdir/test_vim9_script.vim | 1060 +---------------------------- src/version.c | 2 + 4 files changed, 1074 insertions(+), 1059 deletions(-) create mode 100644 src/testdir/test_vim9_import.vim diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index 3c54087a6d..ec12b6b401 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -37,6 +37,7 @@ TEST_VIM9 = \ test_vim9_expr \ test_vim9_fails \ test_vim9_func \ + test_vim9_import \ test_vim9_script TEST_VIM9_RES = \ @@ -47,6 +48,7 @@ TEST_VIM9_RES = \ test_vim9_expr.res \ test_vim9_fails.res \ test_vim9_func.res \ + test_vim9_import.res \ test_vim9_script.res # Benchmark scripts. diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim new file mode 100644 index 0000000000..9d09c63f6e --- /dev/null +++ b/src/testdir/test_vim9_import.vim @@ -0,0 +1,1069 @@ +" Test import/export of the Vim9 script language. + +source check.vim +source term_util.vim +source vim9.vim + +let s:export_script_lines =<< trim END + vim9script + var name: string = 'bob' + def Concat(arg: string): string + return name .. arg + enddef + g:result = Concat('bie') + g:localname = name + + export const CONST = 1234 + export var exported = 9876 + export var exp_name = 'John' + export def Exported(): string + return 'Exported' + enddef + export def ExportedValue(): number + return exported + enddef + export def ExportedInc() + exported += 5 + enddef + export final theList = [1] +END + +def Undo_export_script_lines() + unlet g:result + unlet g:localname +enddef + +def Test_vim9_import_export() + writefile(s:export_script_lines, 'Xexport.vim') + var import_script_lines =<< trim END + vim9script + var dir = './' + var ext = ".vim" + import dir .. 'Xexport' .. ext as expo + + g:exported1 = expo.exported + expo.exported += 3 + g:exported2 = expo.exported + g:exported3 = expo.ExportedValue() + + expo.ExportedInc() + g:exported_i1 = expo.exported + g:exported_i2 = expo.ExportedValue() + + expo.exported = 11 + g:exported_s1 = expo.exported + g:exported_s2 = expo.ExportedValue() + + g:imported_func = expo.Exported() + + def GetExported(): string + var local_dict = {ref: expo.Exported} + return local_dict.ref() + enddef + g:funcref_result = GetExported() + + g:imported_name = expo.exp_name + expo.exp_name ..= ' Doe' + g:imported_name_appended = expo.exp_name + g:exported_later = expo.exported + + expo.theList->add(2) + assert_equal([1, 2], expo.theList) + END + writefile(import_script_lines, 'Ximport.vim') + source Ximport.vim + + assert_equal('bobbie', g:result) + assert_equal('bob', g:localname) + assert_equal(9876, g:exported1) + assert_equal(9879, g:exported2) + assert_equal(9879, g:exported3) + + assert_equal(9884, g:exported_i1) + assert_equal(9884, g:exported_i2) + + assert_equal(11, g:exported_s1) + assert_equal(11, g:exported_s2) + assert_equal(11, g:exported_later) + + assert_equal('Exported', g:imported_func) + assert_equal('Exported', g:funcref_result) + assert_equal('John', g:imported_name) + assert_equal('John Doe', g:imported_name_appended) + assert_false(exists('g:name')) + + Undo_export_script_lines() + unlet g:exported1 + unlet g:exported2 + unlet g:exported3 + unlet g:exported_i1 + unlet g:exported_i2 + unlet g:exported_later + unlet g:imported_func + unlet g:imported_name g:imported_name_appended + delete('Ximport.vim') + + # similar, with line breaks + var import_line_break_script_lines =<< trim END + vim9script + import './Xexport.vim' + as expo + g:exported = expo.exported + expo.exported += 7 + g:exported_added = expo.exported + g:imported_func = expo.Exported() + END + writefile(import_line_break_script_lines, 'Ximport_lbr.vim') + source Ximport_lbr.vim + + assert_equal(11, g:exported) + assert_equal(18, g:exported_added) + assert_equal('Exported', g:imported_func) + + # exported script not sourced again + assert_false(exists('g:result')) + unlet g:exported + unlet g:exported_added + unlet g:imported_func + delete('Ximport_lbr.vim') + + var line_break_before_dot =<< trim END + vim9script + import './Xexport.vim' as expo + g:exported = expo + .exported + END + writefile(line_break_before_dot, 'Ximport_lbr_before_dot.vim') + assert_fails('source Ximport_lbr_before_dot.vim', 'E1060:', '', 3) + delete('Ximport_lbr_before_dot.vim') + + var line_break_after_dot =<< trim END + vim9script + import './Xexport.vim' as expo + g:exported = expo. + exported + END + writefile(line_break_after_dot, 'Ximport_lbr_after_dot.vim') + assert_fails('source Ximport_lbr_after_dot.vim', 'E1074:', '', 3) + delete('Ximport_lbr_after_dot.vim') + + var import_star_as_lines =<< trim END + vim9script + import './Xexport.vim' as Export + def UseExport() + g:exported_def = Export.exported + enddef + g:exported_script = Export.exported + assert_equal(1, exists('Export.exported')) + assert_equal(0, exists('Export.notexported')) + UseExport() + END + writefile(import_star_as_lines, 'Ximport.vim') + source Ximport.vim + + assert_equal(18, g:exported_def) + assert_equal(18, g:exported_script) + unlet g:exported_def + unlet g:exported_script + + var import_star_as_lines_no_dot =<< trim END + vim9script + import './Xexport.vim' as Export + def Func() + var dummy = 1 + var imported = Export + dummy + enddef + defcompile + END + writefile(import_star_as_lines_no_dot, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E1060:', '', 2, 'Func') + + var import_star_as_lines_dot_space =<< trim END + vim9script + import './Xexport.vim' as Export + def Func() + var imported = Export . exported + enddef + defcompile + END + writefile(import_star_as_lines_dot_space, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E1074:', '', 1, 'Func') + + var import_func_duplicated =<< trim END + vim9script + import './Xexport.vim' as expo + import './Xexport.vim' as expo + + ExportedInc() + END + writefile(import_func_duplicated, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E1073:', '', 3, 'Ximport.vim') + + var import_star_as_duplicated =<< trim END + vim9script + import './Xexport.vim' as Export + var some = 'other' + import './Xexport.vim' as Export + defcompile + END + writefile(import_star_as_duplicated, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E1073:', '', 4, 'Ximport.vim') + + var import_star_as_lines_script_no_dot =<< trim END + vim9script + import './Xexport.vim' as Export + g:imported_script = Export exported + END + writefile(import_star_as_lines_script_no_dot, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E1060: Expected dot after name: Export exported') + + var import_star_as_lines_script_space_after_dot =<< trim END + vim9script + import './Xexport.vim' as Export + g:imported_script = Export. exported + END + writefile(import_star_as_lines_script_space_after_dot, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E1074:') + + var import_star_as_lines_missing_name =<< trim END + vim9script + import './Xexport.vim' as Export + def Func() + var imported = Export. + enddef + defcompile + END + writefile(import_star_as_lines_missing_name, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E1048:', '', 1, 'Func') + + var import_star_as_lbr_lines =<< trim END + vim9script + import './Xexport.vim' + as Export + def UseExport() + g:exported = Export.exported + enddef + UseExport() + END + writefile(import_star_as_lbr_lines, 'Ximport.vim') + source Ximport.vim + assert_equal(18, g:exported) + unlet g:exported + + # try to use something that exists but is not exported + var import_not_exported_lines =<< trim END + vim9script + import './Xexport.vim' as expo + echo expo.name + END + writefile(import_not_exported_lines, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E1049:', '', 3, 'Ximport.vim') + + # try to import something that is already defined + var import_already_defined =<< trim END + vim9script + var exported = 'something' + import './Xexport.vim' as exported + END + writefile(import_already_defined, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E1054:', '', 3, 'Ximport.vim') + + # try changing an imported const + var import_assign_to_const =<< trim END + vim9script + import './Xexport.vim' as expo + def Assign() + expo.CONST = 987 + enddef + defcompile + END + writefile(import_assign_to_const, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E46:', '', 1, '_Assign') + + # try changing an imported final + var import_assign_to_final =<< trim END + vim9script + import './Xexport.vim' as expo + def Assign() + expo.theList = [2] + enddef + defcompile + END + writefile(import_assign_to_final, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E46:', '', 1, '_Assign') + + var import_no_as_lines =<< trim END + vim9script + import './Xexport.vim' name + END + writefile(import_no_as_lines, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E488:', '', 2, 'Ximport.vim') + + var import_invalid_string_lines =<< trim END + vim9script + import Xexport.vim + END + writefile(import_invalid_string_lines, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E121:', '', 2, 'Ximport.vim') + + var import_wrong_name_lines =<< trim END + vim9script + import './XnoExport.vim' + END + writefile(import_wrong_name_lines, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E1053:', '', 2, 'Ximport.vim') + + var import_redefining_lines =<< trim END + vim9script + import './Xexport.vim' as exported + var exported = 5 + END + writefile(import_redefining_lines, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E1213: Redefining imported item "exported"', '', 3) + + var import_assign_wrong_type_lines =<< trim END + vim9script + import './Xexport.vim' as expo + expo.exported = 'xxx' + END + writefile(import_assign_wrong_type_lines, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E1012: Type mismatch; expected number but got string', '', 3) + + var import_assign_const_lines =<< trim END + vim9script + import './Xexport.vim' as expo + expo.CONST = 4321 + END + writefile(import_assign_const_lines, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E46: Cannot change read-only variable "CONST"', '', 3) + + delete('Ximport.vim') + delete('Ximport3.vim') + delete('Xexport.vim') + + # Check that in a Vim9 script 'cpo' is set to the Vim default. + # Flags added or removed are also applied to the restored value. + set cpo=abcd + var lines =<< trim END + vim9script + g:cpo_in_vim9script = &cpo + set cpo+=f + set cpo-=c + g:cpo_after_vim9script = &cpo + END + writefile(lines, 'Xvim9_script') + source Xvim9_script + assert_equal('fabd', &cpo) + set cpo&vim + assert_equal(&cpo, g:cpo_in_vim9script) + var newcpo = substitute(&cpo, 'c', '', '') .. 'f' + assert_equal(newcpo, g:cpo_after_vim9script) + + delete('Xvim9_script') +enddef + +def Test_import_funcref() + var lines =<< trim END + vim9script + export def F(): number + return 42 + enddef + export const G = F + END + writefile(lines, 'Xlib.vim') + + lines =<< trim END + vim9script + import './Xlib.vim' as lib + const Foo = lib.G() + assert_equal(42, Foo) + + def DoTest() + const Goo = lib.G() + assert_equal(42, Goo) + enddef + DoTest() + END + CheckScriptSuccess(lines) + + delete('Xlib.vim') +enddef + +def Test_import_fails() + writefile([], 'Xfoo.vim') + var lines =<< trim END + import './Xfoo.vim' as foo + foo = 'bar' + END + CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use foo itself']) + lines =<< trim END + vim9script + import './Xfoo.vim' as foo + var that = foo + END + CheckScriptFailure(lines, 'E1060: Expected dot after name: foo') + + lines =<< trim END + vim9script + import './Xfoo.vim' as 9foo + END + CheckScriptFailure(lines, 'E1047:') + lines =<< trim END + vim9script + import './Xfoo.vim' as the#foo + END + CheckScriptFailure(lines, 'E1047:') + lines =<< trim END + vim9script + import './Xfoo.vim' as g:foo + END + CheckScriptFailure(lines, 'E1047:') + + delete('Xfoo.vim') + + lines =<< trim END + vim9script + def TheFunc() + echo 'the func' + enddef + export var Ref = TheFunc + END + writefile([], 'Xthat.vim') + lines =<< trim END + import './Xthat.vim' as That + That() + END + CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use That itself']) + + mkdir('Ximport') + + writefile(['vim9script'], 'Ximport/.vim') + lines =<< trim END + vim9script + import './Ximport/.vim' + END + CheckScriptFailure(lines, 'E1261: Cannot import .vim without using "as"') + lines =<< trim END + vim9script + import './Ximport/.vim' as vim + END + CheckScriptSuccess(lines) + + writefile(['vim9script'], 'Ximport/.vimrc') + lines =<< trim END + vim9script + import './Ximport/.vimrc' + END + CheckScriptFailure(lines, 'E1257: Imported script must use "as" or end in .vim') + lines =<< trim END + vim9script + import './Ximport/.vimrc' as vimrc + END + CheckScriptSuccess(lines) + + delete('Ximport', 'rf') +enddef + +func g:Trigger() + source Ximport.vim + return "echo 'yes'\" +endfunc + +def Test_import_export_expr_map() + # check that :import and :export work when buffer is locked + var export_lines =<< trim END + vim9script + export def That(): string + return 'yes' + enddef + END + writefile(export_lines, 'Xexport_that.vim') + + var import_lines =<< trim END + vim9script + import './Xexport_that.vim' as that + assert_equal('yes', that.That()) + END + writefile(import_lines, 'Ximport.vim') + + nnoremap trigger g:Trigger() + feedkeys('trigger', "xt") + + delete('Xexport_that.vim') + delete('Ximport.vim') + nunmap trigger +enddef + +def Test_import_in_filetype() + # check that :import works when the buffer is locked + mkdir('ftplugin', 'p') + var export_lines =<< trim END + vim9script + export var That = 'yes' + END + writefile(export_lines, 'ftplugin/Xexport_ft.vim') + + var import_lines =<< trim END + vim9script + import './Xexport_ft.vim' as ft + assert_equal('yes', ft.That) + g:did_load_mytpe = 1 + END + writefile(import_lines, 'ftplugin/qf.vim') + + var save_rtp = &rtp + &rtp = getcwd() .. ',' .. &rtp + + filetype plugin on + copen + assert_equal(1, g:did_load_mytpe) + + quit! + delete('Xexport_ft.vim') + delete('ftplugin', 'rf') + &rtp = save_rtp +enddef + +def Test_use_import_in_mapping() + var lines =<< trim END + vim9script + export def Funcx() + g:result = 42 + enddef + END + writefile(lines, 'XsomeExport.vim') + lines =<< trim END + vim9script + import './XsomeExport.vim' as some + var Funcy = some.Funcx + nnoremap :call Funcy() + END + writefile(lines, 'Xmapscript.vim') + + source Xmapscript.vim + feedkeys("\", "xt") + assert_equal(42, g:result) + + unlet g:result + delete('XsomeExport.vim') + delete('Xmapscript.vim') + nunmap +enddef + +def Test_export_fails() + CheckScriptFailure(['export var some = 123'], 'E1042:') + CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') + CheckScriptFailure(['vim9script', 'export echo 134'], 'E1043:') + + assert_fails('export something', 'E1043:') +enddef + +func Test_import_fails_without_script() + CheckRunVimInTerminal + + " call indirectly to avoid compilation error for missing functions + call Run_Test_import_fails_on_command_line() +endfunc + +def Run_Test_import_fails_on_command_line() + var export =<< trim END + vim9script + export def Foo(): number + return 0 + enddef + END + writefile(export, 'XexportCmd.vim') + + var buf = RunVimInTerminal('-c "import Foo from ''./XexportCmd.vim''"', { + rows: 6, wait_for_ruler: 0}) + WaitForAssert(() => assert_match('^E1094:', term_getline(buf, 5))) + + delete('XexportCmd.vim') + StopVimInTerminal(buf) +enddef + +def Test_vim9_reload_noclear() + var lines =<< trim END + vim9script + export var exported = 'thexport' + + export def TheFunc(x = 0) + enddef + END + writefile(lines, 'XExportReload') + lines =<< trim END + vim9script noclear + g:loadCount += 1 + var s:reloaded = 'init' + import './XExportReload' as exp + + def Again(): string + return 'again' + enddef + + exp.TheFunc() + + if exists('s:loaded') | finish | endif + var s:loaded = true + + var s:notReloaded = 'yes' + s:reloaded = 'first' + def g:Values(): list + return [s:reloaded, s:notReloaded, Again(), Once(), exp.exported] + enddef + + def Once(): string + return 'once' + enddef + END + writefile(lines, 'XReloaded') + g:loadCount = 0 + source XReloaded + assert_equal(1, g:loadCount) + assert_equal(['first', 'yes', 'again', 'once', 'thexport'], g:Values()) + source XReloaded + assert_equal(2, g:loadCount) + assert_equal(['init', 'yes', 'again', 'once', 'thexport'], g:Values()) + source XReloaded + assert_equal(3, g:loadCount) + assert_equal(['init', 'yes', 'again', 'once', 'thexport'], g:Values()) + + delete('XReloaded') + delete('XExportReload') + delfunc g:Values + unlet g:loadCount + + lines =<< trim END + vim9script + def Inner() + enddef + END + lines->writefile('XreloadScript.vim') + source XreloadScript.vim + + lines =<< trim END + vim9script + def Outer() + def Inner() + enddef + enddef + defcompile + END + lines->writefile('XreloadScript.vim') + source XreloadScript.vim + + delete('XreloadScript.vim') +enddef + +def Test_vim9_reload_import() + var lines =<< trim END + vim9script + const var = '' + var valone = 1234 + def MyFunc(arg: string) + valone = 5678 + enddef + END + var morelines =<< trim END + var valtwo = 222 + export def GetValtwo(): number + return valtwo + enddef + END + writefile(lines + morelines, 'Xreload.vim') + source Xreload.vim + source Xreload.vim + source Xreload.vim + + # cannot declare a var twice + lines =<< trim END + vim9script + var valone = 1234 + var valone = 5678 + END + writefile(lines, 'Xreload.vim') + assert_fails('source Xreload.vim', 'E1041:', '', 3, 'Xreload.vim') + + delete('Xreload.vim') + delete('Ximport.vim') +enddef + +" if a script is reloaded with a script-local variable that changed its type, a +" compiled function using that variable must fail. +def Test_script_reload_change_type() + var lines =<< trim END + vim9script noclear + var str = 'string' + def g:GetStr(): string + return str .. 'xxx' + enddef + END + writefile(lines, 'Xreload.vim') + source Xreload.vim + echo g:GetStr() + + lines =<< trim END + vim9script noclear + var str = 1234 + END + writefile(lines, 'Xreload.vim') + source Xreload.vim + assert_fails('echo g:GetStr()', 'E1150:') + + delfunc g:GetStr + delete('Xreload.vim') +enddef + +" Define CallFunc so that the test can be compiled +command CallFunc echo 'nop' + +def Test_script_reload_from_function() + var lines =<< trim END + vim9script + + if exists('g:loaded') + finish + endif + g:loaded = 1 + delcommand CallFunc + command CallFunc Func() + def Func() + so XreloadFunc.vim + g:didTheFunc = 1 + enddef + END + writefile(lines, 'XreloadFunc.vim') + source XreloadFunc.vim + CallFunc + assert_equal(1, g:didTheFunc) + + delete('XreloadFunc.vim') + delcommand CallFunc + unlet g:loaded + unlet g:didTheFunc +enddef + +def s:RetSome(): string + return 'some' +enddef + +" Not exported function that is referenced needs to be accessed by the +" script-local name. +def Test_vim9_funcref() + var sortlines =<< trim END + vim9script + def Compare(i1: number, i2: number): number + return i2 - i1 + enddef + + export def FastSort(): list + return range(5)->sort(Compare) + enddef + + export def GetString(arg: string): string + return arg + enddef + END + writefile(sortlines, 'Xsort.vim') + + var lines =<< trim END + vim9script + import './Xsort.vim' + def Test() + g:result = Xsort.FastSort() + enddef + Test() + + # using a function imported with "as" + import './Xsort.vim' as anAlias + assert_equal('yes', anAlias.GetString('yes')) + + # using the function from a compiled function + def TestMore(): string + var s = s:anAlias.GetString('foo') + return s .. anAlias.GetString('bar') + enddef + assert_equal('foobar', TestMore()) + + # error when using a function that isn't exported + assert_fails('anAlias.Compare(1, 2)', 'E1049:') + END + writefile(lines, 'Xscript.vim') + + source Xscript.vim + assert_equal([4, 3, 2, 1, 0], g:result) + + unlet g:result + delete('Xsort.vim') + delete('Xscript.vim') + + var Funcref = function('s:RetSome') + assert_equal('some', Funcref()) +enddef + +" Check that when searching for "FilterFunc" it finds the import in the +" script where FastFilter() is called from, both as a string and as a direct +" function reference. +def Test_vim9_funcref_other_script() + var filterLines =<< trim END + vim9script + export def FilterFunc(idx: number, val: number): bool + return idx % 2 == 1 + enddef + export def FastFilter(): list + return range(10)->filter('FilterFunc(v:key, v:val)') + enddef + export def FastFilterDirect(): list + return range(10)->filter(FilterFunc) + enddef + END + writefile(filterLines, 'Xfilter.vim') + + var lines =<< trim END + vim9script + import './Xfilter.vim' as filter + def Test() + var x: list = filter.FastFilter() + enddef + Test() + def TestDirect() + var x: list = filter.FastFilterDirect() + enddef + TestDirect() + END + CheckScriptSuccess(lines) + delete('Xfilter.vim') +enddef + +def Test_import_absolute() + var import_lines = [ + 'vim9script', + 'import "' .. escape(getcwd(), '\') .. '/Xexport_abs.vim" as abs', + 'def UseExported()', + ' g:imported_abs = abs.exported', + ' abs.exported = 8888', + ' g:imported_after = abs.exported', + 'enddef', + 'UseExported()', + 'g:import_disassembled = execute("disass UseExported")', + ] + writefile(import_lines, 'Ximport_abs.vim') + writefile(s:export_script_lines, 'Xexport_abs.vim') + + source Ximport_abs.vim + + assert_equal(9876, g:imported_abs) + assert_equal(8888, g:imported_after) + assert_match('\d\+_UseExported\_s*' .. + 'g:imported_abs = abs.exported\_s*' .. + '0 LOADSCRIPT exported-2 from .*Xexport_abs.vim\_s*' .. + '1 STOREG g:imported_abs\_s*' .. + 'abs.exported = 8888\_s*' .. + '2 PUSHNR 8888\_s*' .. + '3 STORESCRIPT exported-2 in .*Xexport_abs.vim\_s*' .. + 'g:imported_after = abs.exported\_s*' .. + '4 LOADSCRIPT exported-2 from .*Xexport_abs.vim\_s*' .. + '5 STOREG g:imported_after', + g:import_disassembled) + + Undo_export_script_lines() + unlet g:imported_abs + unlet g:import_disassembled + + delete('Ximport_abs.vim') + delete('Xexport_abs.vim') +enddef + +def Test_import_rtp() + var import_lines = [ + 'vim9script', + 'import "Xexport_rtp.vim" as rtp', + 'g:imported_rtp = rtp.exported', + ] + writefile(import_lines, 'Ximport_rtp.vim') + mkdir('import', 'p') + writefile(s:export_script_lines, 'import/Xexport_rtp.vim') + + var save_rtp = &rtp + &rtp = getcwd() + source Ximport_rtp.vim + &rtp = save_rtp + + assert_equal(9876, g:imported_rtp) + + Undo_export_script_lines() + unlet g:imported_rtp + delete('Ximport_rtp.vim') + delete('import', 'rf') +enddef + +def Test_import_compile_error() + var export_lines = [ + 'vim9script', + 'export def ExpFunc(): string', + ' return notDefined', + 'enddef', + ] + writefile(export_lines, 'Xexported.vim') + + var import_lines = [ + 'vim9script', + 'import "./Xexported.vim" as expo', + 'def ImpFunc()', + ' echo expo.ExpFunc()', + 'enddef', + 'defcompile', + ] + writefile(import_lines, 'Ximport.vim') + + try + source Ximport.vim + catch /E1001/ + # Error should be before the Xexported.vim file. + assert_match('E1001: Variable not found: notDefined', v:exception) + assert_match('function \d\+_ImpFunc\[1\]..\d\+_ExpFunc, line 1', v:throwpoint) + endtry + + delete('Xexported.vim') + delete('Ximport.vim') +enddef + +def Test_func_overrules_import_fails() + var export_lines =<< trim END + vim9script + export def Func() + echo 'imported' + enddef + END + writefile(export_lines, 'XexportedFunc.vim') + + var lines =<< trim END + vim9script + import './XexportedFunc.vim' as Func + def Func() + echo 'local to function' + enddef + END + CheckScriptFailure(lines, 'E1236:') + + lines =<< trim END + vim9script + import './XexportedFunc.vim' as Func + def Outer() + def Func() + echo 'local to function' + enddef + enddef + defcompile + END + CheckScriptFailure(lines, 'E1236:') + + delete('XexportedFunc.vim') +enddef + +def Test_source_vim9_from_legacy() + var vim9_lines =<< trim END + vim9script + var local = 'local' + g:global = 'global' + export var exported = 'exported' + export def GetText(): string + return 'text' + enddef + END + writefile(vim9_lines, 'Xvim9_script.vim') + + var legacy_lines =<< trim END + source Xvim9_script.vim + + call assert_false(exists('local')) + call assert_false(exists('exported')) + call assert_false(exists('s:exported')) + call assert_equal('global', global) + call assert_equal('global', g:global) + + "" imported variable becomes script-local + "import exported from './Xvim9_script.vim' + "call assert_equal('exported', s:exported) + "call assert_false(exists('exported')) + + "" imported function becomes script-local + "import GetText from './Xvim9_script.vim' + "call assert_equal('text', s:GetText()) + "call assert_false(exists('*GetText')) + END + writefile(legacy_lines, 'Xlegacy_script.vim') + + source Xlegacy_script.vim + assert_equal('global', g:global) + unlet g:global + + delete('Xlegacy_script.vim') + delete('Xvim9_script.vim') +enddef + +def Test_cmdline_win() + # if the Vim syntax highlighting uses Vim9 constructs they can be used from + # the command line window. + mkdir('rtp/syntax', 'p') + var export_lines =<< trim END + vim9script + export var That = 'yes' + END + writefile(export_lines, 'rtp/syntax/Xexport.vim') + var import_lines =<< trim END + vim9script + import './Xexport.vim' as exp + echo exp.That + END + writefile(import_lines, 'rtp/syntax/vim.vim') + var save_rtp = &rtp + &rtp = getcwd() .. '/rtp' .. ',' .. &rtp + syntax on + augroup CmdWin + autocmd CmdwinEnter * g:got_there = 'yes' + augroup END + # this will open and also close the cmdline window + feedkeys('q:', 'xt') + assert_equal('yes', g:got_there) + + augroup CmdWin + au! + augroup END + &rtp = save_rtp + delete('rtp', 'rf') +enddef + +def Test_import_gone_when_sourced_twice() + var exportlines =<< trim END + vim9script + if exists('g:guard') + finish + endif + g:guard = 1 + export var name = 'someName' + END + writefile(exportlines, 'XexportScript.vim') + + var lines =<< trim END + vim9script + import './XexportScript.vim' as expo + def g:GetName(): string + return expo.name + enddef + END + writefile(lines, 'XscriptImport.vim') + so XscriptImport.vim + assert_equal('someName', g:GetName()) + + so XexportScript.vim + assert_fails('call g:GetName()', 'E1149:') + + delfunc g:GetName + delete('XexportScript.vim') + delete('XscriptImport.vim') + unlet g:guard +enddef + + +" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index b6dcf36212..8c7f85f167 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -2,10 +2,9 @@ source check.vim source term_util.vim -source view_util.vim source vim9.vim -source shared.vim source screendump.vim +source shared.vim def Test_vim9script_feature() # example from the help, here the feature is always present @@ -1142,552 +1141,6 @@ if has('channel') endfunc endif -let s:export_script_lines =<< trim END - vim9script - var name: string = 'bob' - def Concat(arg: string): string - return name .. arg - enddef - g:result = Concat('bie') - g:localname = name - - export const CONST = 1234 - export var exported = 9876 - export var exp_name = 'John' - export def Exported(): string - return 'Exported' - enddef - export def ExportedValue(): number - return exported - enddef - export def ExportedInc() - exported += 5 - enddef - export final theList = [1] -END - -def Undo_export_script_lines() - unlet g:result - unlet g:localname -enddef - -def Test_vim9_import_export() - writefile(s:export_script_lines, 'Xexport.vim') - var import_script_lines =<< trim END - vim9script - var dir = './' - var ext = ".vim" - import dir .. 'Xexport' .. ext as expo - - g:exported1 = expo.exported - expo.exported += 3 - g:exported2 = expo.exported - g:exported3 = expo.ExportedValue() - - expo.ExportedInc() - g:exported_i1 = expo.exported - g:exported_i2 = expo.ExportedValue() - - expo.exported = 11 - g:exported_s1 = expo.exported - g:exported_s2 = expo.ExportedValue() - - g:imported_func = expo.Exported() - - def GetExported(): string - var local_dict = {ref: expo.Exported} - return local_dict.ref() - enddef - g:funcref_result = GetExported() - - g:imported_name = expo.exp_name - expo.exp_name ..= ' Doe' - g:imported_name_appended = expo.exp_name - g:exported_later = expo.exported - - expo.theList->add(2) - assert_equal([1, 2], expo.theList) - END - writefile(import_script_lines, 'Ximport.vim') - source Ximport.vim - - assert_equal('bobbie', g:result) - assert_equal('bob', g:localname) - assert_equal(9876, g:exported1) - assert_equal(9879, g:exported2) - assert_equal(9879, g:exported3) - - assert_equal(9884, g:exported_i1) - assert_equal(9884, g:exported_i2) - - assert_equal(11, g:exported_s1) - assert_equal(11, g:exported_s2) - assert_equal(11, g:exported_later) - - assert_equal('Exported', g:imported_func) - assert_equal('Exported', g:funcref_result) - assert_equal('John', g:imported_name) - assert_equal('John Doe', g:imported_name_appended) - assert_false(exists('g:name')) - - Undo_export_script_lines() - unlet g:exported1 - unlet g:exported2 - unlet g:exported3 - unlet g:exported_i1 - unlet g:exported_i2 - unlet g:exported_later - unlet g:imported_func - unlet g:imported_name g:imported_name_appended - delete('Ximport.vim') - - # similar, with line breaks - var import_line_break_script_lines =<< trim END - vim9script - import './Xexport.vim' - as expo - g:exported = expo.exported - expo.exported += 7 - g:exported_added = expo.exported - g:imported_func = expo.Exported() - END - writefile(import_line_break_script_lines, 'Ximport_lbr.vim') - source Ximport_lbr.vim - - assert_equal(11, g:exported) - assert_equal(18, g:exported_added) - assert_equal('Exported', g:imported_func) - - # exported script not sourced again - assert_false(exists('g:result')) - unlet g:exported - unlet g:exported_added - unlet g:imported_func - delete('Ximport_lbr.vim') - - var line_break_before_dot =<< trim END - vim9script - import './Xexport.vim' as expo - g:exported = expo - .exported - END - writefile(line_break_before_dot, 'Ximport_lbr_before_dot.vim') - assert_fails('source Ximport_lbr_before_dot.vim', 'E1060:', '', 3) - delete('Ximport_lbr_before_dot.vim') - - var line_break_after_dot =<< trim END - vim9script - import './Xexport.vim' as expo - g:exported = expo. - exported - END - writefile(line_break_after_dot, 'Ximport_lbr_after_dot.vim') - assert_fails('source Ximport_lbr_after_dot.vim', 'E1074:', '', 3) - delete('Ximport_lbr_after_dot.vim') - - var import_star_as_lines =<< trim END - vim9script - import './Xexport.vim' as Export - def UseExport() - g:exported_def = Export.exported - enddef - g:exported_script = Export.exported - assert_equal(1, exists('Export.exported')) - assert_equal(0, exists('Export.notexported')) - UseExport() - END - writefile(import_star_as_lines, 'Ximport.vim') - source Ximport.vim - - assert_equal(18, g:exported_def) - assert_equal(18, g:exported_script) - unlet g:exported_def - unlet g:exported_script - - var import_star_as_lines_no_dot =<< trim END - vim9script - import './Xexport.vim' as Export - def Func() - var dummy = 1 - var imported = Export + dummy - enddef - defcompile - END - writefile(import_star_as_lines_no_dot, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E1060:', '', 2, 'Func') - - var import_star_as_lines_dot_space =<< trim END - vim9script - import './Xexport.vim' as Export - def Func() - var imported = Export . exported - enddef - defcompile - END - writefile(import_star_as_lines_dot_space, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E1074:', '', 1, 'Func') - - var import_func_duplicated =<< trim END - vim9script - import './Xexport.vim' as expo - import './Xexport.vim' as expo - - ExportedInc() - END - writefile(import_func_duplicated, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E1073:', '', 3, 'Ximport.vim') - - var import_star_as_duplicated =<< trim END - vim9script - import './Xexport.vim' as Export - var some = 'other' - import './Xexport.vim' as Export - defcompile - END - writefile(import_star_as_duplicated, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E1073:', '', 4, 'Ximport.vim') - - var import_star_as_lines_script_no_dot =<< trim END - vim9script - import './Xexport.vim' as Export - g:imported_script = Export exported - END - writefile(import_star_as_lines_script_no_dot, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E1060: Expected dot after name: Export exported') - - var import_star_as_lines_script_space_after_dot =<< trim END - vim9script - import './Xexport.vim' as Export - g:imported_script = Export. exported - END - writefile(import_star_as_lines_script_space_after_dot, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E1074:') - - var import_star_as_lines_missing_name =<< trim END - vim9script - import './Xexport.vim' as Export - def Func() - var imported = Export. - enddef - defcompile - END - writefile(import_star_as_lines_missing_name, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E1048:', '', 1, 'Func') - - var import_star_as_lbr_lines =<< trim END - vim9script - import './Xexport.vim' - as Export - def UseExport() - g:exported = Export.exported - enddef - UseExport() - END - writefile(import_star_as_lbr_lines, 'Ximport.vim') - source Ximport.vim - assert_equal(18, g:exported) - unlet g:exported - - # try to use something that exists but is not exported - var import_not_exported_lines =<< trim END - vim9script - import './Xexport.vim' as expo - echo expo.name - END - writefile(import_not_exported_lines, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E1049:', '', 3, 'Ximport.vim') - - # try to import something that is already defined - var import_already_defined =<< trim END - vim9script - var exported = 'something' - import './Xexport.vim' as exported - END - writefile(import_already_defined, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E1054:', '', 3, 'Ximport.vim') - - # try changing an imported const - var import_assign_to_const =<< trim END - vim9script - import './Xexport.vim' as expo - def Assign() - expo.CONST = 987 - enddef - defcompile - END - writefile(import_assign_to_const, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E46:', '', 1, '_Assign') - - # try changing an imported final - var import_assign_to_final =<< trim END - vim9script - import './Xexport.vim' as expo - def Assign() - expo.theList = [2] - enddef - defcompile - END - writefile(import_assign_to_final, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E46:', '', 1, '_Assign') - - var import_no_as_lines =<< trim END - vim9script - import './Xexport.vim' name - END - writefile(import_no_as_lines, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E488:', '', 2, 'Ximport.vim') - - var import_invalid_string_lines =<< trim END - vim9script - import Xexport.vim - END - writefile(import_invalid_string_lines, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E121:', '', 2, 'Ximport.vim') - - var import_wrong_name_lines =<< trim END - vim9script - import './XnoExport.vim' - END - writefile(import_wrong_name_lines, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E1053:', '', 2, 'Ximport.vim') - - var import_redefining_lines =<< trim END - vim9script - import './Xexport.vim' as exported - var exported = 5 - END - writefile(import_redefining_lines, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E1213: Redefining imported item "exported"', '', 3) - - var import_assign_wrong_type_lines =<< trim END - vim9script - import './Xexport.vim' as expo - expo.exported = 'xxx' - END - writefile(import_assign_wrong_type_lines, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E1012: Type mismatch; expected number but got string', '', 3) - - var import_assign_const_lines =<< trim END - vim9script - import './Xexport.vim' as expo - expo.CONST = 4321 - END - writefile(import_assign_const_lines, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E46: Cannot change read-only variable "CONST"', '', 3) - - delete('Ximport.vim') - delete('Ximport3.vim') - delete('Xexport.vim') - - # Check that in a Vim9 script 'cpo' is set to the Vim default. - # Flags added or removed are also applied to the restored value. - set cpo=abcd - var lines =<< trim END - vim9script - g:cpo_in_vim9script = &cpo - set cpo+=f - set cpo-=c - g:cpo_after_vim9script = &cpo - END - writefile(lines, 'Xvim9_script') - source Xvim9_script - assert_equal('fabd', &cpo) - set cpo&vim - assert_equal(&cpo, g:cpo_in_vim9script) - var newcpo = substitute(&cpo, 'c', '', '') .. 'f' - assert_equal(newcpo, g:cpo_after_vim9script) - - delete('Xvim9_script') -enddef - -def Test_import_funcref() - var lines =<< trim END - vim9script - export def F(): number - return 42 - enddef - export const G = F - END - writefile(lines, 'Xlib.vim') - - lines =<< trim END - vim9script - import './Xlib.vim' as lib - const Foo = lib.G() - assert_equal(42, Foo) - - def DoTest() - const Goo = lib.G() - assert_equal(42, Goo) - enddef - DoTest() - END - CheckScriptSuccess(lines) - - delete('Xlib.vim') -enddef - -def Test_import_fails() - writefile([], 'Xfoo.vim') - var lines =<< trim END - import './Xfoo.vim' as foo - foo = 'bar' - END - CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use foo itself']) - lines =<< trim END - vim9script - import './Xfoo.vim' as foo - var that = foo - END - CheckScriptFailure(lines, 'E1060: Expected dot after name: foo') - - lines =<< trim END - vim9script - import './Xfoo.vim' as 9foo - END - CheckScriptFailure(lines, 'E1047:') - lines =<< trim END - vim9script - import './Xfoo.vim' as the#foo - END - CheckScriptFailure(lines, 'E1047:') - lines =<< trim END - vim9script - import './Xfoo.vim' as g:foo - END - CheckScriptFailure(lines, 'E1047:') - - delete('Xfoo.vim') - - lines =<< trim END - vim9script - def TheFunc() - echo 'the func' - enddef - export var Ref = TheFunc - END - writefile([], 'Xthat.vim') - lines =<< trim END - import './Xthat.vim' as That - That() - END - CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use That itself']) - - mkdir('Ximport') - - writefile(['vim9script'], 'Ximport/.vim') - lines =<< trim END - vim9script - import './Ximport/.vim' - END - CheckScriptFailure(lines, 'E1261: Cannot import .vim without using "as"') - lines =<< trim END - vim9script - import './Ximport/.vim' as vim - END - CheckScriptSuccess(lines) - - writefile(['vim9script'], 'Ximport/.vimrc') - lines =<< trim END - vim9script - import './Ximport/.vimrc' - END - CheckScriptFailure(lines, 'E1257: Imported script must use "as" or end in .vim') - lines =<< trim END - vim9script - import './Ximport/.vimrc' as vimrc - END - CheckScriptSuccess(lines) - - delete('Ximport', 'rf') -enddef - -func g:Trigger() - source Ximport.vim - return "echo 'yes'\" -endfunc - -def Test_import_export_expr_map() - # check that :import and :export work when buffer is locked - var export_lines =<< trim END - vim9script - export def That(): string - return 'yes' - enddef - END - writefile(export_lines, 'Xexport_that.vim') - - var import_lines =<< trim END - vim9script - import './Xexport_that.vim' as that - assert_equal('yes', that.That()) - END - writefile(import_lines, 'Ximport.vim') - - nnoremap trigger g:Trigger() - feedkeys('trigger', "xt") - - delete('Xexport_that.vim') - delete('Ximport.vim') - nunmap trigger -enddef - -def Test_import_in_filetype() - # check that :import works when the buffer is locked - mkdir('ftplugin', 'p') - var export_lines =<< trim END - vim9script - export var That = 'yes' - END - writefile(export_lines, 'ftplugin/Xexport_ft.vim') - - var import_lines =<< trim END - vim9script - import './Xexport_ft.vim' as ft - assert_equal('yes', ft.That) - g:did_load_mytpe = 1 - END - writefile(import_lines, 'ftplugin/qf.vim') - - var save_rtp = &rtp - &rtp = getcwd() .. ',' .. &rtp - - filetype plugin on - copen - assert_equal(1, g:did_load_mytpe) - - quit! - delete('Xexport_ft.vim') - delete('ftplugin', 'rf') - &rtp = save_rtp -enddef - -def Test_use_import_in_mapping() - var lines =<< trim END - vim9script - export def Funcx() - g:result = 42 - enddef - END - writefile(lines, 'XsomeExport.vim') - lines =<< trim END - vim9script - import './XsomeExport.vim' as some - var Funcy = some.Funcx - nnoremap :call Funcy() - END - writefile(lines, 'Xmapscript.vim') - - source Xmapscript.vim - feedkeys("\", "xt") - assert_equal(42, g:result) - - unlet g:result - delete('XsomeExport.vim') - delete('Xmapscript.vim') - nunmap -enddef - def Test_vim9script_mix() var lines =<< trim END if has(g:feature) @@ -1712,200 +1165,11 @@ enddef def Test_vim9script_fails() CheckScriptFailure(['scriptversion 2', 'vim9script'], 'E1039:') CheckScriptFailure(['vim9script', 'scriptversion 2'], 'E1040:') - CheckScriptFailure(['export var some = 123'], 'E1042:') - CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') - CheckScriptFailure(['vim9script', 'export echo 134'], 'E1043:') CheckScriptFailure(['vim9script', 'var str: string', 'str = 1234'], 'E1012:') CheckScriptFailure(['vim9script', 'const str = "asdf"', 'str = "xxx"'], 'E46:') assert_fails('vim9script', 'E1038:') - assert_fails('export something', 'E1043:') -enddef - -func Test_import_fails_without_script() - CheckRunVimInTerminal - - " call indirectly to avoid compilation error for missing functions - call Run_Test_import_fails_on_command_line() -endfunc - -def Run_Test_import_fails_on_command_line() - var export =<< trim END - vim9script - export def Foo(): number - return 0 - enddef - END - writefile(export, 'XexportCmd.vim') - - var buf = RunVimInTerminal('-c "import Foo from ''./XexportCmd.vim''"', { - rows: 6, wait_for_ruler: 0}) - WaitForAssert(() => assert_match('^E1094:', term_getline(buf, 5))) - - delete('XexportCmd.vim') - StopVimInTerminal(buf) -enddef - -def Test_vim9script_reload_noclear() - var lines =<< trim END - vim9script - export var exported = 'thexport' - - export def TheFunc(x = 0) - enddef - END - writefile(lines, 'XExportReload') - lines =<< trim END - vim9script noclear - g:loadCount += 1 - var s:reloaded = 'init' - import './XExportReload' as exp - - def Again(): string - return 'again' - enddef - - exp.TheFunc() - - if exists('s:loaded') | finish | endif - var s:loaded = true - - var s:notReloaded = 'yes' - s:reloaded = 'first' - def g:Values(): list - return [s:reloaded, s:notReloaded, Again(), Once(), exp.exported] - enddef - - def Once(): string - return 'once' - enddef - END - writefile(lines, 'XReloaded') - g:loadCount = 0 - source XReloaded - assert_equal(1, g:loadCount) - assert_equal(['first', 'yes', 'again', 'once', 'thexport'], g:Values()) - source XReloaded - assert_equal(2, g:loadCount) - assert_equal(['init', 'yes', 'again', 'once', 'thexport'], g:Values()) - source XReloaded - assert_equal(3, g:loadCount) - assert_equal(['init', 'yes', 'again', 'once', 'thexport'], g:Values()) - - delete('XReloaded') - delete('XExportReload') - delfunc g:Values - unlet g:loadCount - - lines =<< trim END - vim9script - def Inner() - enddef - END - lines->writefile('XreloadScript.vim') - source XreloadScript.vim - - lines =<< trim END - vim9script - def Outer() - def Inner() - enddef - enddef - defcompile - END - lines->writefile('XreloadScript.vim') - source XreloadScript.vim - - delete('XreloadScript.vim') -enddef - -def Test_vim9script_reload_import() - var lines =<< trim END - vim9script - const var = '' - var valone = 1234 - def MyFunc(arg: string) - valone = 5678 - enddef - END - var morelines =<< trim END - var valtwo = 222 - export def GetValtwo(): number - return valtwo - enddef - END - writefile(lines + morelines, 'Xreload.vim') - source Xreload.vim - source Xreload.vim - source Xreload.vim - - # cannot declare a var twice - lines =<< trim END - vim9script - var valone = 1234 - var valone = 5678 - END - writefile(lines, 'Xreload.vim') - assert_fails('source Xreload.vim', 'E1041:', '', 3, 'Xreload.vim') - - delete('Xreload.vim') - delete('Ximport.vim') -enddef - -" if a script is reloaded with a script-local variable that changed its type, a -" compiled function using that variable must fail. -def Test_script_reload_change_type() - var lines =<< trim END - vim9script noclear - var str = 'string' - def g:GetStr(): string - return str .. 'xxx' - enddef - END - writefile(lines, 'Xreload.vim') - source Xreload.vim - echo g:GetStr() - - lines =<< trim END - vim9script noclear - var str = 1234 - END - writefile(lines, 'Xreload.vim') - source Xreload.vim - assert_fails('echo g:GetStr()', 'E1150:') - - delfunc g:GetStr - delete('Xreload.vim') -enddef - -" Define CallFunc so that the test can be compiled -command CallFunc echo 'nop' - -def Test_script_reload_from_function() - var lines =<< trim END - vim9script - - if exists('g:loaded') - finish - endif - g:loaded = 1 - delcommand CallFunc - command CallFunc Func() - def Func() - so XreloadFunc.vim - g:didTheFunc = 1 - enddef - END - writefile(lines, 'XreloadFunc.vim') - source XreloadFunc.vim - CallFunc - assert_equal(1, g:didTheFunc) - - delete('XreloadFunc.vim') - delcommand CallFunc - unlet g:loaded - unlet g:didTheFunc enddef def Test_script_var_shadows_function() @@ -1954,98 +1218,6 @@ def Test_vim9script_call_wrong_type() CheckScriptFailure(lines, 'E1085:') enddef -def s:RetSome(): string - return 'some' -enddef - -" Not exported function that is referenced needs to be accessed by the -" script-local name. -def Test_vim9script_funcref() - var sortlines =<< trim END - vim9script - def Compare(i1: number, i2: number): number - return i2 - i1 - enddef - - export def FastSort(): list - return range(5)->sort(Compare) - enddef - - export def GetString(arg: string): string - return arg - enddef - END - writefile(sortlines, 'Xsort.vim') - - var lines =<< trim END - vim9script - import './Xsort.vim' - def Test() - g:result = Xsort.FastSort() - enddef - Test() - - # using a function imported with "as" - import './Xsort.vim' as anAlias - assert_equal('yes', anAlias.GetString('yes')) - - # using the function from a compiled function - def TestMore(): string - var s = s:anAlias.GetString('foo') - return s .. anAlias.GetString('bar') - enddef - assert_equal('foobar', TestMore()) - - # error when using a function that isn't exported - assert_fails('anAlias.Compare(1, 2)', 'E1049:') - END - writefile(lines, 'Xscript.vim') - - source Xscript.vim - assert_equal([4, 3, 2, 1, 0], g:result) - - unlet g:result - delete('Xsort.vim') - delete('Xscript.vim') - - var Funcref = function('s:RetSome') - assert_equal('some', Funcref()) -enddef - -" Check that when searching for "FilterFunc" it finds the import in the -" script where FastFilter() is called from, both as a string and as a direct -" function reference. -def Test_vim9script_funcref_other_script() - var filterLines =<< trim END - vim9script - export def FilterFunc(idx: number, val: number): bool - return idx % 2 == 1 - enddef - export def FastFilter(): list - return range(10)->filter('FilterFunc(v:key, v:val)') - enddef - export def FastFilterDirect(): list - return range(10)->filter(FilterFunc) - enddef - END - writefile(filterLines, 'Xfilter.vim') - - var lines =<< trim END - vim9script - import './Xfilter.vim' as filter - def Test() - var x: list = filter.FastFilter() - enddef - Test() - def TestDirect() - var x: list = filter.FastFilterDirect() - enddef - TestDirect() - END - CheckScriptSuccess(lines) - delete('Xfilter.vim') -enddef - def Test_vim9script_reload_delfunc() var first_lines =<< trim END vim9script @@ -2109,99 +1281,6 @@ def Test_vim9script_reload_delvar() delete('XreloadVar.vim') enddef -def Test_import_absolute() - var import_lines = [ - 'vim9script', - 'import "' .. escape(getcwd(), '\') .. '/Xexport_abs.vim" as abs', - 'def UseExported()', - ' g:imported_abs = abs.exported', - ' abs.exported = 8888', - ' g:imported_after = abs.exported', - 'enddef', - 'UseExported()', - 'g:import_disassembled = execute("disass UseExported")', - ] - writefile(import_lines, 'Ximport_abs.vim') - writefile(s:export_script_lines, 'Xexport_abs.vim') - - source Ximport_abs.vim - - assert_equal(9876, g:imported_abs) - assert_equal(8888, g:imported_after) - assert_match('\d\+_UseExported\_s*' .. - 'g:imported_abs = abs.exported\_s*' .. - '0 LOADSCRIPT exported-2 from .*Xexport_abs.vim\_s*' .. - '1 STOREG g:imported_abs\_s*' .. - 'abs.exported = 8888\_s*' .. - '2 PUSHNR 8888\_s*' .. - '3 STORESCRIPT exported-2 in .*Xexport_abs.vim\_s*' .. - 'g:imported_after = abs.exported\_s*' .. - '4 LOADSCRIPT exported-2 from .*Xexport_abs.vim\_s*' .. - '5 STOREG g:imported_after', - g:import_disassembled) - - Undo_export_script_lines() - unlet g:imported_abs - unlet g:import_disassembled - - delete('Ximport_abs.vim') - delete('Xexport_abs.vim') -enddef - -def Test_import_rtp() - var import_lines = [ - 'vim9script', - 'import "Xexport_rtp.vim" as rtp', - 'g:imported_rtp = rtp.exported', - ] - writefile(import_lines, 'Ximport_rtp.vim') - mkdir('import', 'p') - writefile(s:export_script_lines, 'import/Xexport_rtp.vim') - - var save_rtp = &rtp - &rtp = getcwd() - source Ximport_rtp.vim - &rtp = save_rtp - - assert_equal(9876, g:imported_rtp) - - Undo_export_script_lines() - unlet g:imported_rtp - delete('Ximport_rtp.vim') - delete('import', 'rf') -enddef - -def Test_import_compile_error() - var export_lines = [ - 'vim9script', - 'export def ExpFunc(): string', - ' return notDefined', - 'enddef', - ] - writefile(export_lines, 'Xexported.vim') - - var import_lines = [ - 'vim9script', - 'import "./Xexported.vim" as expo', - 'def ImpFunc()', - ' echo expo.ExpFunc()', - 'enddef', - 'defcompile', - ] - writefile(import_lines, 'Ximport.vim') - - try - source Ximport.vim - catch /E1001/ - # Error should be before the Xexported.vim file. - assert_match('E1001: Variable not found: notDefined', v:exception) - assert_match('function \d\+_ImpFunc\[1\]..\d\+_ExpFunc, line 1', v:throwpoint) - endtry - - delete('Xexported.vim') - delete('Ximport.vim') -enddef - def Test_func_redefine_error() var lines = [ 'vim9script', @@ -2225,39 +1304,6 @@ def Test_func_redefine_error() delete('Xtestscript.vim') enddef -def Test_func_overrules_import_fails() - var export_lines =<< trim END - vim9script - export def Func() - echo 'imported' - enddef - END - writefile(export_lines, 'XexportedFunc.vim') - - var lines =<< trim END - vim9script - import './XexportedFunc.vim' as Func - def Func() - echo 'local to function' - enddef - END - CheckScriptFailure(lines, 'E1236:') - - lines =<< trim END - vim9script - import './XexportedFunc.vim' as Func - def Outer() - def Func() - echo 'local to function' - enddef - enddef - defcompile - END - CheckScriptFailure(lines, 'E1236:') - - delete('XexportedFunc.vim') -enddef - def Test_func_redefine_fails() var lines =<< trim END vim9script @@ -3877,47 +2923,6 @@ def Test_forward_declaration() delete('Xforward') enddef -def Test_source_vim9_from_legacy() - var vim9_lines =<< trim END - vim9script - var local = 'local' - g:global = 'global' - export var exported = 'exported' - export def GetText(): string - return 'text' - enddef - END - writefile(vim9_lines, 'Xvim9_script.vim') - - var legacy_lines =<< trim END - source Xvim9_script.vim - - call assert_false(exists('local')) - call assert_false(exists('exported')) - call assert_false(exists('s:exported')) - call assert_equal('global', global) - call assert_equal('global', g:global) - - "" imported variable becomes script-local - "import exported from './Xvim9_script.vim' - "call assert_equal('exported', s:exported) - "call assert_false(exists('exported')) - - "" imported function becomes script-local - "import GetText from './Xvim9_script.vim' - "call assert_equal('text', s:GetText()) - "call assert_false(exists('*GetText')) - END - writefile(legacy_lines, 'Xlegacy_script.vim') - - source Xlegacy_script.vim - assert_equal('global', g:global) - unlet g:global - - delete('Xlegacy_script.vim') - delete('Xvim9_script.vim') -enddef - def Test_declare_script_in_func() var lines =<< trim END vim9script @@ -4194,38 +3199,6 @@ def Test_error_in_autoload_script() delete(dir, 'rf') enddef -def Test_cmdline_win() - # if the Vim syntax highlighting uses Vim9 constructs they can be used from - # the command line window. - mkdir('rtp/syntax', 'p') - var export_lines =<< trim END - vim9script - export var That = 'yes' - END - writefile(export_lines, 'rtp/syntax/Xexport.vim') - var import_lines =<< trim END - vim9script - import './Xexport.vim' as exp - echo exp.That - END - writefile(import_lines, 'rtp/syntax/vim.vim') - var save_rtp = &rtp - &rtp = getcwd() .. '/rtp' .. ',' .. &rtp - syntax on - augroup CmdWin - autocmd CmdwinEnter * g:got_there = 'yes' - augroup END - # this will open and also close the cmdline window - feedkeys('q:', 'xt') - assert_equal('yes', g:got_there) - - augroup CmdWin - au! - augroup END - &rtp = save_rtp - delete('rtp', 'rf') -enddef - def Test_invalid_sid() assert_fails('func 1234_func', 'E123:') @@ -4552,37 +3525,6 @@ def Test_script_var_gone_when_sourced_twice() unlet g:guard enddef -"def Test_import_gone_when_sourced_twice() -" var exportlines =<< trim END -" vim9script -" if exists('g:guard') -" finish -" endif -" g:guard = 1 -" export var name = 'someName' -" END -" writefile(exportlines, 'XexportScript.vim') -" -" var lines =<< trim END -" vim9script -" import name from './XexportScript.vim' -" def g:GetName(): string -" return name -" enddef -" END -" writefile(lines, 'XscriptImport.vim') -" so XscriptImport.vim -" assert_equal('someName', g:GetName()) -" -" so XexportScript.vim -" assert_fails('call g:GetName()', 'E1149:') -" -" delfunc g:GetName -" delete('XexportScript.vim') -" delete('XscriptImport.vim') -" unlet g:guard -"enddef - def Test_unsupported_commands() var lines =<< trim END ka diff --git a/src/version.c b/src/version.c index 44d849ef5b..e86bd10336 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4036, /**/ 4035, /**/ From 370791465e745354d66696de8cbd15504cf958c0 Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Sat, 8 Jan 2022 10:38:48 +0000 Subject: [PATCH 14/28] patch 8.2.4037: Insert mode completion is insufficiently tested Problem: Insert mode completion is insufficiently tested. Solution: Add more tests. Fix uncovered memory leak. (Yegappan Lakshmanan, closes #9489) --- src/insexpand.c | 33 ++++- src/testdir/test_ins_complete.vim | 235 ++++++++++++++++++++++++++++++ src/version.c | 2 + 3 files changed, 264 insertions(+), 6 deletions(-) diff --git a/src/insexpand.c b/src/insexpand.c index e6d05bfe98..8fcce7f40f 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -698,7 +698,20 @@ ins_compl_add_infercase( } /* - * Add a match to the list of matches. + * Add a match to the list of matches. The arguments are: + * str - text of the match to add + * len - length of "str". If -1, then the length of "str" is + * computed. + * fname - file name to associate with this match. + * cptext - list of strings to use with this match (for abbr, menu, info + * and kind) + * user_data - user supplied data (any vim type) for this match + * cdir - match direction. If 0, use "compl_direction". + * flags_arg - match flags (cp_flags) + * adup - accept this match even if it is already present. + * If "cdir" is FORWARD, then the match is added after the current match. + * Otherwise, it is added before the current match. + * * If the given string is already in the list of completions, then return * NOTDONE, otherwise add it to the list and return OK. If there is an error, * maybe because alloc() returns NULL, then FAIL is returned. @@ -789,7 +802,8 @@ ins_compl_add( match->cp_user_data = *user_data; #endif - // Link the new match structure in the list of matches. + // Link the new match structure after (FORWARD) or before (BACKWARD) the + // current match in the list of matches . if (compl_first_match == NULL) match->cp_next = match->cp_prev = NULL; else if (dir == FORWARD) @@ -2704,6 +2718,7 @@ ins_compl_add_tv(typval_T *tv, int dir, int fast) int flags = fast ? CP_FAST : 0; char_u *(cptext[CPT_COUNT]); typval_T user_data; + int status; user_data.v_type = VAR_UNKNOWN; if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL) @@ -2735,8 +2750,14 @@ ins_compl_add_tv(typval_T *tv, int dir, int fast) CLEAR_FIELD(cptext); } if (word == NULL || (!empty && *word == NUL)) + { + clear_tv(&user_data); return FAIL; - return ins_compl_add(word, -1, NULL, cptext, &user_data, dir, flags, dup); + } + status = ins_compl_add(word, -1, NULL, cptext, &user_data, dir, flags, dup); + if (status != OK) + clear_tv(&user_data); + return status; } /* @@ -3157,8 +3178,8 @@ typedef struct * st->dict_f - flag specifying whether "dict" is an exact file name or not * * Returns INS_COMPL_CPT_OK if the next value is processed successfully. - * Returns INS_COMPL_CPT_CONT to skip the current value and process the next - * option value. + * Returns INS_COMPL_CPT_CONT to skip the current completion source matching + * the "st->e_cpt" option value and process the next matching source. * Returns INS_COMPL_CPT_END if all the values in "st->e_cpt" are processed. */ static int @@ -4521,7 +4542,7 @@ get_userdefined_compl_info(colnr_T curs_col UNUSED) return FAIL; } - // Reset extended parameters of completion, when start new + // Reset extended parameters of completion, when starting new // completion. compl_opt_refresh_always = FALSE; compl_opt_suppress_empty = FALSE; diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim index 86ad6098c9..5f7d0e3284 100644 --- a/src/testdir/test_ins_complete.vim +++ b/src/testdir/test_ins_complete.vim @@ -71,6 +71,11 @@ func Test_ins_complete() call assert_equal('Xtest11.one', getline('.')) normal ddk + " Test for expanding a non-existing filename + exe "normal oa1b2X3Y4\\" + call assert_equal('a1b2X3Y4', getline('.')) + normal ddk + set cpt=w " checks make_cyclic in other window exe "normal oST\\\\\" @@ -981,6 +986,27 @@ func Test_complete_erase_firstmatch() bw! endfunc +" Test for completing words from unloaded buffers +func Test_complete_from_unloadedbuf() + call writefile(['abc'], "Xfile1") + call writefile(['def'], "Xfile2") + edit Xfile1 + edit Xfile2 + new | close + enew + bunload Xfile1 Xfile2 + set complete=u + " complete from an unloaded buffer + exe "normal! ia\" + call assert_equal('abc', getline(1)) + exe "normal! od\" + call assert_equal('def', getline(2)) + set complete& + %bw! + call delete("Xfile1") + call delete("Xfile2") +endfunc + " Test for completing whole lines from unloaded buffers func Test_complete_wholeline_unloadedbuf() call writefile(['a line1', 'a line2', 'a line3'], "Xfile1") @@ -999,6 +1025,26 @@ func Test_complete_wholeline_unloadedbuf() call delete("Xfile1") endfunc +" Test for completing words from unlisted buffers +func Test_complete_from_unlistedbuf() + call writefile(['abc'], "Xfile1") + call writefile(['def'], "Xfile2") + edit Xfile1 + edit Xfile2 + new | close + bdel Xfile1 Xfile2 + set complete=U + " complete from an unlisted buffer + exe "normal! ia\" + call assert_equal('abc', getline(1)) + exe "normal! od\" + call assert_equal('def', getline(2)) + set complete& + %bw! + call delete("Xfile1") + call delete("Xfile2") +endfunc + " Test for completing whole lines from unlisted buffers func Test_complete_wholeline_unlistedbuf() call writefile(['a line1', 'a line2', 'a line3'], "Xfile1") @@ -1032,6 +1078,195 @@ func Test_complete_mbyte_char_add() bw! endfunc +" Test for using for local expansion even if 'complete' is set to +" not to complete matches from the local buffer. Also test using multiple +" to cancel the current completion mode. +func Test_complete_local_expansion() + new + set complete=t + call setline(1, ['abc', 'def']) + exe "normal! Go\\" + call assert_equal("def", getline(3)) + exe "normal! Go\" + call assert_equal("", getline(4)) + exe "normal! Go\\" + call assert_equal("abc", getline(5)) + exe "normal! Go\" + call assert_equal("", getline(6)) + + " use multiple to cancel the previous completion mode + exe "normal! Go\\\" + call assert_equal("", getline(7)) + exe "normal! Go\\\\" + call assert_equal("", getline(8)) + exe "normal! Go\\\\\" + call assert_equal("abc", getline(9)) + + " interrupt the current completion mode + set completeopt=menu,noinsert + exe "normal! Go\\\\\\" + call assert_equal("abc", getline(10)) + + " when only one is used to interrupt, do normal expansion + exe "normal! Go\\\\" + call assert_equal("", getline(11)) + set completeopt& + + " using two in non-completion mode and restarting the same mode + exe "normal! God\\\\\\\" + call assert_equal("def", getline(12)) + + " test for adding a match from the original empty text + %d + call setline(1, 'abc def g') + exe "normal! o\\\\\" + call assert_equal('def', getline(2)) + exe "normal! 0C\\\\\" + call assert_equal('abc', getline(2)) + + bw! +endfunc + +" Test for undoing changes after a insert-mode completion +func Test_complete_undo() + new + set complete=. + " undo with 'ignorecase' + call setline(1, ['ABOVE', 'BELOW']) + set ignorecase + exe "normal! Goab\u\" + call assert_equal("ABOVE", getline(3)) + undo + call assert_equal("ab", getline(3)) + set ignorecase& + %d + " undo with longest match + set completeopt=menu,longest + call setline(1, ['above', 'about']) + exe "normal! Goa\u\" + call assert_equal("abo", getline(3)) + undo + call assert_equal("a", getline(3)) + set completeopt& + %d + " undo for line completion + call setline(1, ['above that change', 'below that change']) + exe "normal! Goabove\u\\" + call assert_equal("above that change", getline(3)) + undo + call assert_equal("above", getline(3)) + + bw! +endfunc + +" Test for completing a very long word +func Test_complete_long_word() + set complete& + new + call setline(1, repeat('x', 950) .. ' one two three') + exe "normal! Gox\\\\\\\\" + call assert_equal(repeat('x', 950) .. ' one two three', getline(2)) + %d + " should fail when more than 950 characters are in a word + call setline(1, repeat('x', 951) .. ' one two three') + exe "normal! Gox\\\\\\\\" + call assert_equal(repeat('x', 951), getline(2)) + + " Test for adding a very long word to an existing completion + %d + call setline(1, ['abc', repeat('x', 1016) .. '012345']) + exe "normal! Goab\\\" + call assert_equal('abc ' .. repeat('x', 1016) .. '0123', getline(3)) + bw! +endfunc + +" Test for some fields in the complete items used by complete() +func Test_complete_items() + func CompleteItems(idx) + let items = [[#{word: "one", dup: 1, user_data: 'u1'}, #{word: "one", dup: 1, user_data: 'u2'}], + \ [#{word: "one", dup: 0, user_data: 'u3'}, #{word: "one", dup: 0, user_data: 'u4'}], + \ [#{word: "one", icase: 1, user_data: 'u7'}, #{word: "oNE", icase: 1, user_data: 'u8'}], + \ [#{user_data: 'u9'}], + \ [#{word: "", user_data: 'u10'}], + \ [#{word: "", empty: 1, user_data: 'u11'}]] + call complete(col('.'), items[a:idx]) + return '' + endfunc + new + exe "normal! i\=CompleteItems(0)\\\" + call assert_equal('u2', v:completed_item.user_data) + call assert_equal('one', getline(1)) + exe "normal! o\=CompleteItems(1)\\" + call assert_equal('u3', v:completed_item.user_data) + call assert_equal('one', getline(2)) + exe "normal! o\=CompleteItems(1)\\" + call assert_equal('', getline(3)) + set completeopt=menu,noinsert + exe "normal! o\=CompleteItems(2)\one\\" + call assert_equal('oNE', getline(4)) + call assert_equal('u8', v:completed_item.user_data) + set completeopt& + exe "normal! o\=CompleteItems(3)\" + call assert_equal('', getline(5)) + exe "normal! o\=CompleteItems(4)\" + call assert_equal('', getline(6)) + exe "normal! o\=CompleteItems(5)\" + call assert_equal('', getline(7)) + call assert_equal('u11', v:completed_item.user_data) + " pass invalid argument to complete() + let cmd = "normal! o\=complete(1, [[]])\" + call assert_fails('exe cmd', 'E730:') + bw! + delfunc CompleteItems +endfunc + +" Test for the "refresh" item in the dict returned by an insert completion +" function +func Test_complete_item_refresh_always() + let g:CallCount = 0 + func! Tcomplete(findstart, base) + if a:findstart + " locate the start of the word + let line = getline('.') + let start = col('.') - 1 + while start > 0 && line[start - 1] =~ '\a' + let start -= 1 + endwhile + return start + else + let g:CallCount += 1 + let res = ["update1", "update12", "update123"] + return #{words: res, refresh: 'always'} + endif + endfunc + new + set completeopt=menu,longest + set completefunc=Tcomplete + exe "normal! iup\\\\\\\" + call assert_equal('up', getline(1)) + call assert_equal(2, g:CallCount) + set completeopt& + set completefunc& + bw! + delfunc Tcomplete +endfunc + +" Test for completing from a thesaurus file without read permission +func Test_complete_unreadable_thesaurus_file() + CheckUnix + CheckNotRoot + + call writefile(['about', 'above'], 'Xfile') + call setfperm('Xfile', '---r--r--') + new + set complete=sXfile + exe "normal! ia\" + call assert_equal('a', getline(1)) + bw! + call delete('Xfile') + set complete& +endfunc + " Test to ensure 'Scanning...' messages are not recorded in messages history func Test_z1_complete_no_history() new diff --git a/src/version.c b/src/version.c index e86bd10336..9d568b64d2 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4037, /**/ 4036, /**/ From 748b308eebe8d8860888eb27da08333f175d547d Mon Sep 17 00:00:00 2001 From: Dominique Pelle Date: Sat, 8 Jan 2022 12:41:16 +0000 Subject: [PATCH 15/28] patch 8.2.4038: various code not used when features are disabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Various code not used when features are disabled. Solution: Add #ifdefs. (Dominique PellĂ©, closes #9491) --- src/alloc.c | 6 ++++++ src/buffer.c | 6 ++++++ src/charset.c | 2 ++ src/clipboard.c | 2 ++ src/cmdhist.c | 4 ++++ src/crypt.c | 2 ++ src/edit.c | 2 ++ src/eval.c | 49 ++++++------------------------------------------ src/evalbuffer.c | 4 +--- src/evalfunc.c | 2 ++ src/ex_docmd.c | 4 ++++ src/globals.h | 10 ++++++++++ src/gui_xim.c | 7 ++++--- src/hashtab.c | 2 ++ src/highlight.c | 2 ++ src/insexpand.c | 2 ++ src/main.c | 4 ++++ src/mark.c | 2 ++ src/message.c | 4 ++++ src/misc1.c | 4 +++- src/misc2.c | 2 ++ src/ops.c | 4 ++-- src/option.c | 4 ++++ src/option.h | 15 +++++++-------- src/optionstr.c | 2 ++ src/register.c | 16 ++++++++++++++++ src/scriptfile.c | 3 +-- src/tag.c | 12 ++++++------ src/term.c | 2 ++ src/typval.c | 4 ++++ src/usercmd.c | 4 ++++ src/userfunc.c | 2 ++ src/version.c | 2 ++ src/vim9script.c | 2 ++ src/vim9type.c | 6 ------ 35 files changed, 126 insertions(+), 74 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index cb781b0779..3651a2e599 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -151,6 +151,7 @@ alloc(size_t size) return lalloc(size, TRUE); } +#if defined(FEAT_QUICKFIX) || defined(PROTO) /* * alloc() with an ID for alloc_fail(). */ @@ -163,6 +164,7 @@ alloc_id(size_t size, alloc_id_T id UNUSED) #endif return lalloc(size, TRUE); } +#endif /* * Allocate memory and set all bytes to zero. @@ -178,6 +180,7 @@ alloc_clear(size_t size) return p; } +#if defined(FEAT_SIGNS) || defined(PROTO) /* * Same as alloc_clear() but with allocation id for testing */ @@ -190,6 +193,7 @@ alloc_clear_id(size_t size, alloc_id_T id UNUSED) #endif return alloc_clear(size); } +#endif /* * Allocate memory like lalloc() and set all bytes to zero. @@ -648,6 +652,7 @@ ga_clear_strings(garray_T *gap) ga_clear(gap); } +#if defined(FEAT_EVAL) || defined(PROTO) /* * Copy a growing array that contains a list of strings. */ @@ -682,6 +687,7 @@ ga_copy_strings(garray_T *from, garray_T *to) to->ga_len = from->ga_len; return OK; } +#endif /* * Initialize a growing array. Don't forget to set ga_itemsize and diff --git a/src/buffer.c b/src/buffer.c index c00993a945..3445b204f3 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -138,6 +138,7 @@ read_buffer( return retval; } +#if defined(FEAT_EVAL) || defined(PROTO) /* * Ensure buffer "buf" is loaded. Does not trigger the swap-exists action. */ @@ -154,6 +155,7 @@ buffer_ensure_loaded(buf_T *buf) aucmd_restbuf(&aco); } } +#endif /* * Open current buffer, that is: open the memfile and read the file into @@ -5609,6 +5611,7 @@ bt_prompt(buf_T *buf) return buf != NULL && buf->b_p_bt[0] == 'p' && buf->b_p_bt[1] == 'r'; } +#if defined(FEAT_PROP_POPUP) || defined(PROTO) /* * Return TRUE if "buf" is a buffer for a popup window. */ @@ -5618,6 +5621,7 @@ bt_popup(buf_T *buf) return buf != NULL && buf->b_p_bt != NULL && buf->b_p_bt[0] == 'p' && buf->b_p_bt[1] == 'o'; } +#endif /* * Return TRUE if "buf" is a "nofile", "acwrite", "terminal" or "prompt" @@ -5632,6 +5636,7 @@ bt_nofilename(buf_T *buf) || buf->b_p_bt[0] == 'p'); } +#if defined(FEAT_QUICKFIX) || defined(PROTO) /* * Return TRUE if "buf" has 'buftype' set to "nofile". */ @@ -5640,6 +5645,7 @@ bt_nofile(buf_T *buf) { return buf != NULL && buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f'; } +#endif /* * Return TRUE if "buf" is a "nowrite", "nofile", "terminal" or "prompt" diff --git a/src/charset.c b/src/charset.c index d762a2545b..12d6359708 100644 --- a/src/charset.c +++ b/src/charset.c @@ -1476,6 +1476,7 @@ skipwhite(char_u *q) return p; } +#if defined(FEAT_EVAL) || defined(PROTO) /* * skip over ' ', '\t' and '\n'. */ @@ -1488,6 +1489,7 @@ skipwhite_and_nl(char_u *q) ++p; return p; } +#endif /* * getwhitecols: return the number of whitespace diff --git a/src/clipboard.c b/src/clipboard.c index 09d05c9eed..e2ebd114b9 100644 --- a/src/clipboard.c +++ b/src/clipboard.c @@ -1540,6 +1540,7 @@ clip_x11_notify_cb(Widget w UNUSED, Atom *sel_atom UNUSED, Atom *target UNUSED) /* * Property callback to get a timestamp for XtOwnSelection. */ +# if (defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)) || defined(PROTO) static void clip_x11_timestamp_cb( Widget w, @@ -1592,6 +1593,7 @@ x11_setup_selection(Widget w) XtAddEventHandler(w, PropertyChangeMask, False, /*(XtEventHandler)*/clip_x11_timestamp_cb, (XtPointer)NULL); } +# endif static void clip_x11_request_selection_cb( diff --git a/src/cmdhist.c b/src/cmdhist.c index 8057344c13..6256fd91b0 100644 --- a/src/cmdhist.c +++ b/src/cmdhist.c @@ -37,11 +37,13 @@ get_histentry(int hist_type) return history[hist_type]; } +#if defined(FEAT_VIMINFO) || defined(PROTO) void set_histentry(int hist_type, histentry_T *entry) { history[hist_type] = entry; } +#endif int * get_hisidx(int hist_type) @@ -49,11 +51,13 @@ get_hisidx(int hist_type) return &hisidx[hist_type]; } +#if defined(FEAT_VIMINFO) || defined(PROTO) int * get_hisnum(int hist_type) { return &hisnum[hist_type]; } +#endif /* * Translate a history character to the associated type number. diff --git a/src/crypt.c b/src/crypt.c index 5a83588917..85ff33a314 100644 --- a/src/crypt.c +++ b/src/crypt.c @@ -247,6 +247,7 @@ crypt_get_header_len(int method_nr) } +#if defined(FEAT_SODIUM) || defined(PROTO) /* * Get maximum crypt method specific length of the file header in bytes. */ @@ -265,6 +266,7 @@ crypt_get_max_header_len() } return max; } +#endif /* * Set the crypt method for buffer "buf" to "method_nr" using the int value as diff --git a/src/edit.c b/src/edit.c index 4d5ee85591..739f0786e4 100644 --- a/src/edit.c +++ b/src/edit.c @@ -1715,6 +1715,7 @@ edit_putchar(int c, int highlight) } } +#if defined(FEAT_JOB_CHANNEL) || defined(PROTO) /* * Set the insert start position for when using a prompt buffer. */ @@ -1728,6 +1729,7 @@ set_insstart(linenr_T lnum, int col) Insstart_blank_vcol = MAXCOL; arrow_used = FALSE; } +#endif /* * Undo the previous edit_putchar(). diff --git a/src/eval.c b/src/eval.c index 7fed2867d1..ec896814d4 100644 --- a/src/eval.c +++ b/src/eval.c @@ -653,50 +653,10 @@ call_vim_function( return ret; } -/* - * Call Vim script function "func" and return the result as a number. - * Returns -1 when calling the function fails. - * Uses argv[0] to argv[argc - 1] for the function arguments. argv[argc] should - * have type VAR_UNKNOWN. - */ - varnumber_T -call_func_retnr( - char_u *func, - int argc, - typval_T *argv) -{ - typval_T rettv; - varnumber_T retval; - - if (call_vim_function(func, argc, argv, &rettv) == FAIL) - return -1; - - retval = tv_get_number_chk(&rettv, NULL); - clear_tv(&rettv); - return retval; -} - -/* - * Call Vim script function like call_func_retnr() and drop the result. - * Returns FAIL when calling the function fails. - */ - int -call_func_noret( - char_u *func, - int argc, - typval_T *argv) -{ - typval_T rettv; - - if (call_vim_function(func, argc, argv, &rettv) == FAIL) - return FAIL; - clear_tv(&rettv); - return OK; -} - /* * Call Vim script function "func" and return the result as a string. - * Uses "argv" and "argc" as call_func_retnr(). + * Uses "argv[0]" to "argv[argc - 1]" for the function arguments. "argv[argc]" + * should have type VAR_UNKNOWN. * Returns NULL when calling the function fails. */ void * @@ -718,7 +678,7 @@ call_func_retstr( /* * Call Vim script function "func" and return the result as a List. - * Uses "argv" and "argc" as call_func_retnr(). + * Uses "argv" and "argc" as call_func_retstr(). * Returns NULL when there is something wrong. */ void * @@ -4783,6 +4743,8 @@ set_ref_in_ht(hashtab_T *ht, int copyID, list_stack_T **list_stack) return abort; } +#if defined(FEAT_LUA) || defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \ + || defined(PROTO) /* * Mark a dict and its items with "copyID". * Returns TRUE if setting references failed somehow. @@ -4797,6 +4759,7 @@ set_ref_in_dict(dict_T *d, int copyID) } return FALSE; } +#endif /* * Mark a list and its items with "copyID". diff --git a/src/evalbuffer.c b/src/evalbuffer.c index b6bd67bce5..1b829848fb 100644 --- a/src/evalbuffer.c +++ b/src/evalbuffer.c @@ -864,9 +864,7 @@ f_setline(typval_T *argvars, typval_T *rettv) } #endif // FEAT_EVAL -#if defined(FEAT_JOB_CHANNEL) \ - || defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \ - || defined(PROTO) +#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) /* * Make "buf" the current buffer. restore_buffer() MUST be called to undo. * No autocommands will be executed. Use aucmd_prepbuf() if there are any. diff --git a/src/evalfunc.c b/src/evalfunc.c index fc2fd07064..bb50d5568f 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -3529,6 +3529,7 @@ execute_redir_str(char_u *value, int value_len) } } +#if defined(FEAT_LUA) || defined(PROTO) /* * Get next line from a string containing NL separated lines. * Called by do_cmdline() to get the next line. @@ -3570,6 +3571,7 @@ execute_cmds_from_string(char_u *str) do_cmdline(NULL, get_str_line, (void *)&str, DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT|DOCMD_KEYTYPED); } +#endif /* * Get next line from a list. diff --git a/src/ex_docmd.c b/src/ex_docmd.c index ea6dbb64c2..be95992f74 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -3082,6 +3082,7 @@ parse_command_modifiers( return OK; } +#if defined(FEAT_EVAL) || defined(PROTO) /* * Return TRUE if "cmod" has anything set. */ @@ -3110,6 +3111,7 @@ cmdmod_error(int ignore_silent) } return FALSE; } +#endif /* * Apply the command modifiers. Saves current state in "cmdmod", call @@ -3393,6 +3395,7 @@ append_command(char_u *cmd) *d = NUL; } +#if defined(FEAT_EVAL) || defined(PROTO) /* * If "start" points "&opt", "&l:opt", "&g:opt" or "$ENV" return a pointer to * the name. Otherwise just return "start". @@ -3413,6 +3416,7 @@ skip_option_env_lead(char_u *start) name += 1; return name; } +#endif /* * Find an Ex command by its name, either built-in or user. diff --git a/src/globals.h b/src/globals.h index b258aec125..f04b29e8b3 100644 --- a/src/globals.h +++ b/src/globals.h @@ -440,7 +440,9 @@ EXTERN type_T t_dict_string INIT6(VAR_DICT, 0, 0, TTFLAG_STATIC, &t_string, NULL #endif +#ifdef FEAT_EVAL EXTERN int did_source_packages INIT(= FALSE); +#endif // Magic number used for hashitem "hi_key" value indicating a deleted item. // Only the address is used. @@ -1153,7 +1155,9 @@ EXTERN int ctrl_c_interrupts INIT(= TRUE); // CTRL-C sets got_int EXTERN cmdmod_T cmdmod; // Ex command modifiers +#ifdef FEAT_EVAL EXTERN int is_export INIT(= FALSE); // :export {cmd} +#endif EXTERN int msg_silent INIT(= 0); // don't print messages EXTERN int emsg_silent INIT(= 0); // don't print error messages @@ -1190,7 +1194,9 @@ EXTERN typebuf_T typebuf // typeahead buffer #endif ; EXTERN int ex_normal_busy INIT(= 0); // recursiveness of ex_normal() +#ifdef FEAT_EVAL EXTERN int in_feedkeys INIT(= 0); // ex_normal_busy set in feedkeys() +#endif EXTERN int ex_normal_lock INIT(= 0); // forbid use of ex_normal() #ifdef FEAT_EVAL @@ -1394,8 +1400,10 @@ EXTERN char_u no_lines_msg[] INIT(= N_("--No lines in buffer--")); EXTERN long sub_nsubs; // total number of substitutions EXTERN linenr_T sub_nlines; // total number of lines changed +#ifdef FEAT_EVAL // Used when a compiled :substitute has an expression. EXTERN struct subs_expr_S *substitute_instr INIT(= NULL); +#endif // table to store parsed 'wildmode' EXTERN char_u wim_flags[4]; @@ -1588,7 +1596,9 @@ EXTERN int netbeansSuppressNoLines INIT(= 0); // skip "No lines in buffer" EXTERN char top_bot_msg[] INIT(= N_("search hit TOP, continuing at BOTTOM")); EXTERN char bot_top_msg[] INIT(= N_("search hit BOTTOM, continuing at TOP")); +#ifdef FEAT_EVAL EXTERN char line_msg[] INIT(= N_(" line ")); +#endif #ifdef FEAT_CRYPT EXTERN char need_key_msg[] INIT(= N_("Need encryption key for \"%s\"")); diff --git a/src/gui_xim.c b/src/gui_xim.c index 28d354ced3..1dfb1056da 100644 --- a/src/gui_xim.c +++ b/src/gui_xim.c @@ -125,6 +125,7 @@ free_xim_stuff(void) } #endif +#if defined(FEAT_EVAL) || defined(PROTO) /* * Mark the global 'imactivatefunc' and 'imstatusfunc' callbacks with 'copyID' * so that they are not garbage collected. @@ -134,14 +135,14 @@ set_ref_in_im_funcs(int copyID UNUSED) { int abort = FALSE; -#if defined(FEAT_EVAL) && \ - (defined(FEAT_XIM) || defined(IME_WITHOUT_XIM) || defined(VIMDLL)) +# if defined(FEAT_XIM) || defined(IME_WITHOUT_XIM) || defined(VIMDLL) abort = set_ref_in_callback(&imaf_cb, copyID); abort = abort || set_ref_in_callback(&imsf_cb, copyID); -#endif +# endif return abort; } +#endif #if defined(FEAT_XIM) || defined(PROTO) diff --git a/src/hashtab.c b/src/hashtab.c index dc0cbb6b86..482d83005e 100644 --- a/src/hashtab.c +++ b/src/hashtab.c @@ -288,6 +288,7 @@ hash_lock(hashtab_T *ht) ++ht->ht_locked; } +#if defined(FEAT_PROP_POPUP) || defined(PROTO) /* * Lock a hashtable at the specified number of entries. * Caller must make sure no more than "size" entries will be added. @@ -299,6 +300,7 @@ hash_lock_size(hashtab_T *ht, int size) (void)hash_may_resize(ht, size); ++ht->ht_locked; } +#endif /* * Unlock a hashtable: allow ht_array changes again. diff --git a/src/highlight.c b/src/highlight.c index fa329813d8..efbc5b10e2 100644 --- a/src/highlight.c +++ b/src/highlight.c @@ -343,6 +343,7 @@ static char *(highlight_init_dark[]) = { NULL }; +#if defined(FEAT_SYN_HL) || defined(PROTO) /* * Returns the number of highlight groups. */ @@ -369,6 +370,7 @@ highlight_link_id(int id) { return HL_TABLE()[id].sg_link; } +#endif void init_highlight( diff --git a/src/insexpand.c b/src/insexpand.c index 8fcce7f40f..51177fb2c7 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -263,7 +263,9 @@ ins_ctrl_x(void) /* * Functions to check the current CTRL-X mode. */ +#ifdef FEAT_CINDENT int ctrl_x_mode_none(void) { return ctrl_x_mode == 0; } +#endif int ctrl_x_mode_normal(void) { return ctrl_x_mode == CTRL_X_NORMAL; } int ctrl_x_mode_scroll(void) { return ctrl_x_mode == CTRL_X_SCROLL; } int ctrl_x_mode_whole_line(void) { return ctrl_x_mode == CTRL_X_WHOLE_LINE; } diff --git a/src/main.c b/src/main.c index dc82a8ad3c..5723d46336 100644 --- a/src/main.c +++ b/src/main.c @@ -1091,12 +1091,15 @@ state_no_longer_safe(char *reason UNUSED) was_safe = FALSE; } +#if defined(FEAT_EVAL) || defined(MESSAGE_QUEUE) || defined(PROTO) int get_was_safe_state(void) { return was_safe; } +#endif +#if defined(MESSAGE_QUEUE) || defined(PROTO) /* * Invoked when leaving code that invokes callbacks. Then trigger * SafeStateAgain, if it was safe when starting to wait for a character. @@ -1137,6 +1140,7 @@ may_trigger_safestateagain(void) "SafeState: back to waiting, not triggering SafeStateAgain"); #endif } +#endif /* diff --git a/src/mark.c b/src/mark.c index 771eb1b986..4765b79c17 100644 --- a/src/mark.c +++ b/src/mark.c @@ -1368,6 +1368,7 @@ free_all_marks(void) } #endif +#if defined(FEAT_VIMINFO) || defined(PROTO) /* * Return a pointer to the named file marks. */ @@ -1376,6 +1377,7 @@ get_namedfm(void) { return namedfm; } +#endif #if defined(FEAT_EVAL) || defined(PROTO) /* diff --git a/src/message.c b/src/message.c index 81c0f47492..17c541f95f 100644 --- a/src/message.c +++ b/src/message.c @@ -876,6 +876,7 @@ internal_error(char *where) siemsg(_(e_internal_error_str), where); } +#if defined(FEAT_EVAL) || defined(PROTO) /* * Like internal_error() but do not call abort(), to avoid tests using * test_unknown() and test_void() causing Vim to exit. @@ -885,6 +886,7 @@ internal_error_no_abort(char *where) { semsg(_(e_internal_error_str), where); } +#endif // emsg3() and emsgn() are in misc2.c to avoid warnings for the prototypes. @@ -894,6 +896,7 @@ emsg_invreg(int name) semsg(_(e_invalid_register_name_str), transchar(name)); } +#if defined(FEAT_EVAL) || defined(PROTO) /* * Give an error message which contains %s for "name[len]". */ @@ -905,6 +908,7 @@ emsg_namelen(char *msg, char_u *name, int len) semsg(msg, copy == NULL ? "NULL" : (char *)copy); vim_free(copy); } +#endif /* * Like msg(), but truncate to a single line if p_shm contains 't', or when diff --git a/src/misc1.c b/src/misc1.c index 31cc63b156..e43d001568 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -1896,7 +1896,6 @@ vim_unsetenv(char_u *var) vim_setenv(var, (char_u *)""); #endif } -#endif /* @@ -1914,6 +1913,7 @@ vim_setenv_ext(char_u *name, char_u *val) && STRICMP(name, "VIMRUNTIME") == 0) didset_vimruntime = FALSE; } +#endif /* * Our portable version of setenv. @@ -2230,6 +2230,7 @@ fast_breakcheck(void) } } +# if defined(FEAT_SPELL) || defined(PROTO) /* * Like line_breakcheck() but check 100 times less often. */ @@ -2242,6 +2243,7 @@ veryfast_breakcheck(void) ui_breakcheck(); } } +#endif #if defined(VIM_BACKTICK) || defined(FEAT_EVAL) \ || (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ diff --git a/src/misc2.c b/src/misc2.c index 6a65ec4756..aa39822781 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -2424,6 +2424,7 @@ get_user_name(char_u *buf, int len) return OK; } +#if defined(EXITFREE) || defined(PROTOS) /* * Free the memory allocated by get_user_name() */ @@ -2432,6 +2433,7 @@ free_username(void) { vim_free(username); } +#endif #ifndef HAVE_QSORT /* diff --git a/src/ops.c b/src/ops.c index 44a6a6e8e7..8b0f79c6e3 100644 --- a/src/ops.c +++ b/src/ops.c @@ -3350,6 +3350,7 @@ free_operatorfunc_option(void) } #endif +#if defined(FEAT_EVAL) || defined(PROTO) /* * Mark the global 'operatorfunc' callback with 'copyID' so that it is not * garbage collected. @@ -3359,12 +3360,11 @@ set_ref_in_opfunc(int copyID UNUSED) { int abort = FALSE; -#ifdef FEAT_EVAL abort = set_ref_in_callback(&opfunc_cb, copyID); -#endif return abort; } +#endif /* * Handle the "g@" operator: call 'operatorfunc'. diff --git a/src/option.c b/src/option.c index dd51593145..169f92998a 100644 --- a/src/option.c +++ b/src/option.c @@ -753,6 +753,7 @@ set_number_default(char *name, long val) options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val; } +#if defined(FEAT_PROP_POPUP) || defined(PROTO) /* * Set all window-local and buffer-local options to the Vim default. * local-global options will use the global value. @@ -784,6 +785,7 @@ set_local_options_default(win_T *wp, int do_buffer) curwin = save_curwin; curbuf = curwin->w_buffer; } +#endif #if defined(EXITFREE) || defined(PROTO) /* @@ -5535,6 +5537,7 @@ get_option_var(int opt_idx) return options[opt_idx].var; } +#if defined(FEAT_EVAL) || defined(PROTO) /* * Return the full name of the option at 'opt_idx' */ @@ -5543,6 +5546,7 @@ get_option_fullname(int opt_idx) { return (char_u *)options[opt_idx].fullname; } +#endif /* * Get the value of 'equalprg', either the buffer-local one or the global one. diff --git a/src/option.h b/src/option.h index a82258e3ab..00a2d2ecc4 100644 --- a/src/option.h +++ b/src/option.h @@ -486,7 +486,9 @@ EXTERN int p_deco; // 'delcombine' EXTERN char_u *p_ccv; // 'charconvert' #endif EXTERN int p_cdh; // 'cdhome' +#ifdef FEAT_CINDENT EXTERN char_u *p_cino; // 'cinoptions' +#endif #ifdef FEAT_CMDWIN EXTERN char_u *p_cedit; // 'cedit' EXTERN long p_cwh; // 'cmdwinheight' @@ -730,13 +732,6 @@ EXTERN char_u *p_mef; // 'makeef' EXTERN char_u *p_mp; // 'makeprg' #endif EXTERN char_u *p_mps; // 'matchpairs' -#ifdef FEAT_SIGNS -EXTERN char_u *p_scl; // signcolumn -#endif -#ifdef FEAT_SYN_HL -EXTERN char_u *p_cc; // 'colorcolumn' -EXTERN int p_cc_cols[256]; // array for 'colorcolumn' columns -#endif EXTERN long p_mat; // 'matchtime' EXTERN long p_mco; // 'maxcombine' #ifdef FEAT_EVAL @@ -840,7 +835,9 @@ EXTERN int p_ru; // 'ruler' EXTERN char_u *p_ruf; // 'rulerformat' #endif EXTERN char_u *p_pp; // 'packpath' +#ifdef FEAT_QUICKFIX EXTERN char_u *p_qftf; // 'quickfixtextfunc' +#endif EXTERN char_u *p_rtp; // 'runtimepath' EXTERN long p_sj; // 'scrolljump' #if defined(MSWIN) && defined(FEAT_GUI) @@ -949,7 +946,9 @@ EXTERN unsigned swb_flags; #define SWB_NEWTAB 0x008 #define SWB_VSPLIT 0x010 #define SWB_USELAST 0x020 +#ifdef FEAT_SYN_HL EXTERN char_u *p_syn; // 'syntax' +#endif EXTERN long p_ts; // 'tabstop' EXTERN int p_tbs; // 'tagbsearch' EXTERN char_u *p_tc; // 'tagcase' @@ -1026,8 +1025,8 @@ EXTERN unsigned ttym_flags; # define TTYM_URXVT 0x40 # define TTYM_SGR 0x80 #endif -EXTERN char_u *p_udir; // 'undodir' #ifdef FEAT_PERSISTENT_UNDO +EXTERN char_u *p_udir; // 'undodir' EXTERN int p_udf; // 'undofile' #endif EXTERN long p_ul; // 'undolevels' diff --git a/src/optionstr.c b/src/optionstr.c index 6cc4cf584f..94a1e2a245 100644 --- a/src/optionstr.c +++ b/src/optionstr.c @@ -454,6 +454,7 @@ set_string_option_direct_in_win( unblock_autocmds(); } +#if defined(FEAT_PROP_POPUP) || defined(PROTO) /* * Like set_string_option_direct(), but for a buffer-local option in "buf". * Blocks autocommands to avoid the old curbuf becoming invalid. @@ -477,6 +478,7 @@ set_string_option_direct_in_buf( curwin->w_buffer = curbuf; unblock_autocmds(); } +#endif /* * Set a string option to a new value, and handle the effects. diff --git a/src/register.c b/src/register.c index d61a5d0d10..08a73fe9b7 100644 --- a/src/register.c +++ b/src/register.c @@ -38,41 +38,53 @@ static void copy_yank_reg(yankreg_T *reg); #endif static void dis_msg(char_u *p, int skip_esc); +#if defined(FEAT_VIMINFO) || defined(PROTO) yankreg_T * get_y_regs(void) { return y_regs; } +#endif +#if defined(FEAT_CLIPBOARD) || defined(PROTO) yankreg_T * get_y_register(int reg) { return &y_regs[reg]; } +#endif +#if defined(FEAT_CLIPBOARD) || defined(FEAT_VIMINFO) || defined(FEAT_EVAL) || defined(PROTO) yankreg_T * get_y_current(void) { return y_current; } +#endif +#if defined(FEAT_CLIPBOARD) || defined(FEAT_VIMINFO) || defined(PROTO) yankreg_T * get_y_previous(void) { return y_previous; } +#endif +#if defined(FEAT_CLIPBOARD) || defined(PROTO) void set_y_current(yankreg_T *yreg) { y_current = yreg; } +#endif +#if defined(FEAT_CLIPBOARD) || defined(FEAT_VIMINFO) || defined(PROTO) void set_y_previous(yankreg_T *yreg) { y_previous = yreg; } +#endif void reset_y_append(void) @@ -474,6 +486,7 @@ stuff_yank(int regname, char_u *p) */ static int execreg_lastc = NUL; +#if defined(FEAT_VIMINFO) || defined(PROTO) int get_execreg_lastc(void) { @@ -485,6 +498,7 @@ set_execreg_lastc(int lastc) { execreg_lastc = lastc; } +#endif /* * When executing a register as a series of ex-commands, if the @@ -2308,6 +2322,7 @@ get_register_name(int num) } } +#if defined(FEAT_EVAL) || defined(PROTO) /* * Return the index of the register "" points to. */ @@ -2316,6 +2331,7 @@ get_unname_register() { return y_previous == NULL ? -1 : y_previous - &y_regs[0]; } +#endif /* * ":dis" and ":registers": Display the contents of the yank registers. diff --git a/src/scriptfile.c b/src/scriptfile.c index 4256b39742..8fb3cae015 100644 --- a/src/scriptfile.c +++ b/src/scriptfile.c @@ -1635,8 +1635,6 @@ free_autoload_scriptnames(void) } # endif -#endif - linenr_T get_sourced_lnum( char_u *(*fgetline)(int, void *, int, getline_opt_T), @@ -1646,6 +1644,7 @@ get_sourced_lnum( ? ((source_cookie_T *)cookie)->sourcing_lnum : SOURCING_LNUM; } +#endif static char_u * get_one_sourceline(source_cookie_T *sp) diff --git a/src/tag.c b/src/tag.c index c12c5fa075..bf816e16a8 100644 --- a/src/tag.c +++ b/src/tag.c @@ -102,6 +102,7 @@ static callback_T tfu_cb; // 'tagfunc' callback function // Used instead of NUL to separate tag fields in the growarrays. #define TAG_SEP 0x02 +#if defined(FEAT_EVAL) || defined(PROTO) /* * Reads the 'tagfunc' option value and convert that to a callback value. * Invoked when the 'tagfunc' option is set. The option value can be a name of @@ -125,8 +126,9 @@ set_tagfunc_option(void) return OK; } +#endif -#if defined(EXITFREE) || defined(PROTO) +# if defined(EXITFREE) || defined(PROTO) void free_tagfunc_option(void) { @@ -134,8 +136,9 @@ free_tagfunc_option(void) free_callback(&tfu_cb); # endif } -#endif +# endif +#if defined(FEAT_EVAL) || defined(PROTO) /* * Mark the global 'tagfunc' callback with 'copyID' so that it is not garbage * collected. @@ -145,9 +148,7 @@ set_ref_in_tagfunc(int copyID UNUSED) { int abort = FALSE; -#ifdef FEAT_EVAL abort = set_ref_in_callback(&tfu_cb, copyID); -#endif return abort; } @@ -159,12 +160,11 @@ set_ref_in_tagfunc(int copyID UNUSED) void set_buflocal_tfu_callback(buf_T *buf UNUSED) { -#ifdef FEAT_EVAL free_callback(&buf->b_tfu_cb); if (tfu_cb.cb_name != NULL && *tfu_cb.cb_name != NUL) copy_callback(&buf->b_tfu_cb, &tfu_cb); -#endif } +#endif /* * Jump to tag; handling of tag commands and tag stack diff --git a/src/term.c b/src/term.c index 853d93fefa..0090fb7ec2 100644 --- a/src/term.c +++ b/src/term.c @@ -3991,6 +3991,7 @@ cursor_off(void) } } +#ifdef FEAT_GUI /* * Check whether the cursor is invisible due to an ongoing cursor-less sleep */ @@ -3999,6 +4000,7 @@ cursor_is_sleeping(void) { return cursor_is_asleep; } +#endif /* * Disable the cursor and mark it disabled by cursor-less sleep diff --git a/src/typval.c b/src/typval.c index 23ce7124ab..eb0ef77b74 100644 --- a/src/typval.c +++ b/src/typval.c @@ -528,6 +528,7 @@ check_for_opt_dict_arg(typval_T *args, int idx) || check_for_dict_arg(args, idx) != FAIL); } +#if defined(FEAT_JOB_CHANNEL) || defined(PROTO) /* * Give an error and return FAIL unless "args[idx]" is a channel or a job. */ @@ -576,6 +577,7 @@ check_for_opt_job_arg(typval_T *args, int idx) return (args[idx].v_type == VAR_UNKNOWN || check_for_job_arg(args, idx) != FAIL); } +#endif /* * Give an error and return FAIL unless "args[idx]" is a string or @@ -642,6 +644,7 @@ check_for_opt_lnum_arg(typval_T *args, int idx) || check_for_lnum_arg(args, idx)); } +#if defined(FEAT_JOB_CHANNEL) || defined(PROTO) /* * Give an error and return FAIL unless "args[idx]" is a string or a blob. */ @@ -655,6 +658,7 @@ check_for_string_or_blob_arg(typval_T *args, int idx) } return OK; } +#endif /* * Give an error and return FAIL unless "args[idx]" is a string or a list. diff --git a/src/usercmd.c b/src/usercmd.c index 135752d117..de985f8a24 100644 --- a/src/usercmd.c +++ b/src/usercmd.c @@ -319,6 +319,7 @@ get_user_commands(expand_T *xp UNUSED, int idx) return NULL; } +#ifdef FEAT_EVAL /* * Get the name of user command "idx". "cmdidx" can be CMD_USER or * CMD_USER_BUF. @@ -343,6 +344,7 @@ get_user_command_name(int idx, int cmdidx) } return NULL; } +#endif /* * Function given to ExpandGeneric() to obtain the list of user address type @@ -394,6 +396,7 @@ get_user_cmd_complete(expand_T *xp UNUSED, int idx) return (char_u *)command_complete[idx].name; } +#ifdef FEAT_EVAL int cmdcomplete_str_to_type(char_u *complete_str) { @@ -405,6 +408,7 @@ cmdcomplete_str_to_type(char_u *complete_str) return EXPAND_NOTHING; } +#endif /* * List user commands starting with "name[name_len]". diff --git a/src/userfunc.c b/src/userfunc.c index 6821569b68..3617e7b106 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -39,6 +39,7 @@ func_init() hash_init(&func_hashtab); } +#if defined(FEAT_PROFILE) || defined(PROTO) /* * Return the function hash table */ @@ -47,6 +48,7 @@ func_tbl_get(void) { return &func_hashtab; } +#endif /* * Get one function argument. diff --git a/src/version.c b/src/version.c index 9d568b64d2..c4d639ef6a 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4038, /**/ 4037, /**/ diff --git a/src/vim9script.c b/src/vim9script.c index 4d16a2a7a5..e5e26959a4 100644 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -115,6 +115,7 @@ ex_vim9script(exarg_T *eap UNUSED) #endif } +#if defined(FEAT_EVAL) || defined(PROTO) /* * When in Vim9 script give an error and return FAIL. */ @@ -159,6 +160,7 @@ vim9_bad_comment(char_u *p) } return FALSE; } +#endif /* * Return TRUE if "p" points at a "#" not followed by one '{'. diff --git a/src/vim9type.c b/src/vim9type.c index 6671f5e3d4..bf82b7d3ce 100644 --- a/src/vim9type.c +++ b/src/vim9type.c @@ -531,12 +531,6 @@ check_typval_type(type_T *expected, typval_T *actual_tv, where_T where) return res; } - void -type_mismatch(type_T *expected, type_T *actual) -{ - arg_type_mismatch(expected, actual, 0); -} - void arg_type_mismatch(type_T *expected, type_T *actual, int arg_idx) { From 67ffb417861a90fd2c1b215a42fd230272ed94cb Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 8 Jan 2022 13:36:57 +0000 Subject: [PATCH 16/28] patch 8.2.4039: the xdiff library is linked in even when not used Problem: The xdiff library is linked in even when not used. Solution: Use configure to decide whether xdiff object files are included. --- src/Makefile | 2 +- src/auto/configure | 15 +++++++++++++++ src/config.mk.in | 2 ++ src/configure.ac | 10 ++++++++++ src/feature.h | 3 ++- src/version.c | 2 ++ 6 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index aafe1398dc..c65781ec59 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1874,7 +1874,7 @@ OBJ_COMMON = \ $(OS_EXTRA_OBJ) \ $(NETBEANS_OBJ) \ $(CHANNEL_OBJ) \ - $(XDIFF_OBJS) + $(XDIFF_OBJS_USED) # The files included by tests are not in OBJ_COMMON. OBJ_MAIN = \ diff --git a/src/auto/configure b/src/auto/configure index cde05d688e..72d2d076dc 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -714,6 +714,7 @@ LUA_SRC vi_cv_path_plain_lua vi_cv_path_luajit vi_cv_path_lua +XDIFF_OBJS_USED compiledby dogvimdiff dovimdiff @@ -5305,6 +5306,20 @@ else $as_echo "yes" >&6; } fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking diff feature" >&5 +$as_echo_n "checking diff feature... " >&6; } +if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled in $features version" >&5 +$as_echo "disabled in $features version" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5 +$as_echo "enabled" >&6; } + $as_echo "#define FEAT_DIFF 1" >>confdefs.h + + XDIFF_OBJS_USED="\$(XDIFF_OBJS)" + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-luainterp argument" >&5 $as_echo_n "checking --enable-luainterp argument... " >&6; } # Check whether --enable-luainterp was given. diff --git a/src/config.mk.in b/src/config.mk.in index df09cfe30b..4eb692839b 100644 --- a/src/config.mk.in +++ b/src/config.mk.in @@ -37,6 +37,8 @@ X_PRE_LIBS = @X_PRE_LIBS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIB@ +XDIFF_OBJS_USED = @XDIFF_OBJS_USED@ + LUA_LIBS = @LUA_LIBS@ LUA_SRC = @LUA_SRC@ LUA_OBJ = @LUA_OBJ@ diff --git a/src/configure.ac b/src/configure.ac index b5f217ca1f..86f70f581c 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -567,6 +567,16 @@ else AC_MSG_RESULT(yes) fi +AC_MSG_CHECKING([diff feature]) +if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then + AC_MSG_RESULT([disabled in $features version]) +else + AC_MSG_RESULT(enabled) + AC_DEFINE(FEAT_DIFF) + XDIFF_OBJS_USED="\$(XDIFF_OBJS)" + AC_SUBST(XDIFF_OBJS_USED) +fi + dnl Check for Lua feature. AC_MSG_CHECKING(--enable-luainterp argument) AC_ARG_ENABLE(luainterp, diff --git a/src/feature.h b/src/feature.h index fcd0d4b5cb..b2df6f9a5c 100644 --- a/src/feature.h +++ b/src/feature.h @@ -345,8 +345,9 @@ /* * +diff Displaying diffs in a nice way. * Requires +windows and +autocmd. + * Can be enabled in autoconf already. */ -#if defined(FEAT_NORMAL) +#if defined(FEAT_NORMAL) && !defined(FEAT_DIFF) # define FEAT_DIFF #endif diff --git a/src/version.c b/src/version.c index c4d639ef6a..542227c903 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4039, /**/ 4038, /**/ From 9f1a39a5d1cd7989ada2d1cb32f97d84360e050f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 8 Jan 2022 15:39:39 +0000 Subject: [PATCH 17/28] patch 8.2.4040: keeping track of allocated lines is too complicated Problem: Keeping track of allocated lines in user functions is too complicated. Solution: Instead of freeing individual lines keep them all until the end. --- src/alloc.c | 17 ++++++++-- src/message.c | 2 +- src/proto/alloc.pro | 3 +- src/proto/userfunc.pro | 2 +- src/testdir/test_vim9_func.vim | 16 ++++++++- src/usercmd.c | 4 +-- src/userfunc.c | 62 ++++++++++++++++++---------------- src/version.c | 2 ++ src/vim9compile.c | 17 ++++++---- src/viminfo.c | 4 +-- 10 files changed, 82 insertions(+), 47 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index 3651a2e599..e3cd8578f6 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -702,7 +702,7 @@ ga_init(garray_T *gap) } void -ga_init2(garray_T *gap, int itemsize, int growsize) +ga_init2(garray_T *gap, size_t itemsize, int growsize) { ga_init(gap); gap->ga_itemsize = itemsize; @@ -789,7 +789,7 @@ ga_concat_strings(garray_T *gap, char *sep) * When out of memory nothing changes and FAIL is returned. */ int -ga_add_string(garray_T *gap, char_u *p) +ga_copy_string(garray_T *gap, char_u *p) { char_u *cp = vim_strsave(p); @@ -805,6 +805,19 @@ ga_add_string(garray_T *gap, char_u *p) return OK; } +/* + * Add string "p" to "gap". + * When out of memory "p" is freed and FAIL is returned. + */ + int +ga_add_string(garray_T *gap, char_u *p) +{ + if (ga_grow(gap, 1) == FAIL) + return FAIL; + ((char_u **)(gap->ga_data))[gap->ga_len++] = p; + return OK; +} + /* * Concatenate a string to a growarray which contains bytes. * When "s" is NULL does not do anything. diff --git a/src/message.c b/src/message.c index 17c541f95f..04a51fbf35 100644 --- a/src/message.c +++ b/src/message.c @@ -587,7 +587,7 @@ ignore_error_for_testing(char_u *error) if (STRCMP("RESET", error) == 0) ga_clear_strings(&ignore_error_list); else - ga_add_string(&ignore_error_list, error); + ga_copy_string(&ignore_error_list, error); } static int diff --git a/src/proto/alloc.pro b/src/proto/alloc.pro index 2069ca8ca2..18281adaaf 100644 --- a/src/proto/alloc.pro +++ b/src/proto/alloc.pro @@ -17,10 +17,11 @@ void ga_clear(garray_T *gap); void ga_clear_strings(garray_T *gap); int ga_copy_strings(garray_T *from, garray_T *to); void ga_init(garray_T *gap); -void ga_init2(garray_T *gap, int itemsize, int growsize); +void ga_init2(garray_T *gap, size_t itemsize, int growsize); int ga_grow(garray_T *gap, int n); int ga_grow_inner(garray_T *gap, int n); char_u *ga_concat_strings(garray_T *gap, char *sep); +int ga_copy_string(garray_T *gap, char_u *p); int ga_add_string(garray_T *gap, char_u *p); void ga_concat(garray_T *gap, char_u *s); void ga_concat_len(garray_T *gap, char_u *s, size_t len); diff --git a/src/proto/userfunc.pro b/src/proto/userfunc.pro index 311cee2e12..6b054ffe61 100644 --- a/src/proto/userfunc.pro +++ b/src/proto/userfunc.pro @@ -38,7 +38,7 @@ char_u *untrans_function_name(char_u *name); char_u *get_scriptlocal_funcname(char_u *funcname); char_u *save_function_name(char_u **name, int *is_global, int skip, int flags, funcdict_T *fudi); void list_functions(regmatch_T *regmatch); -ufunc_T *define_function(exarg_T *eap, char_u *name_arg, char_u **line_to_free); +ufunc_T *define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free); void ex_function(exarg_T *eap); void ex_defcompile(exarg_T *eap); int eval_fname_script(char_u *p); diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 9e420ade74..75d0dd0b65 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -1757,6 +1757,21 @@ def Test_nested_function_with_args_split() CheckScriptFailure(lines, 'E1173: Text found after endfunction: BBBB') enddef +def Test_error_in_function_args() + var lines =<< trim END + def FirstFunction() + def SecondFunction(J = + # Nois + # one + + enddef|BBBB + enddef + # Compile all functions + defcompile + END + CheckScriptFailure(lines, 'E488:') +enddef + def Test_return_type_wrong() CheckScriptFailure([ 'def Func(): number', @@ -2048,7 +2063,6 @@ func Test_free_dict_while_in_funcstack() endfunc def Run_Test_free_dict_while_in_funcstack() - # this was freeing the TermRun() default argument dictionary while it was # still referenced in a funcstack_T var lines =<< trim END diff --git a/src/usercmd.c b/src/usercmd.c index de985f8a24..40790a1f56 100644 --- a/src/usercmd.c +++ b/src/usercmd.c @@ -1021,7 +1021,7 @@ may_get_cmd_block(exarg_T *eap, char_u *p, char_u **tofree, int *flags) char_u *line = NULL; ga_init2(&ga, sizeof(char_u *), 10); - if (ga_add_string(&ga, p) == FAIL) + if (ga_copy_string(&ga, p) == FAIL) return retp; // If the argument ends in "}" it must have been concatenated already @@ -1038,7 +1038,7 @@ may_get_cmd_block(exarg_T *eap, char_u *p, char_u **tofree, int *flags) emsg(_(e_missing_rcurly)); break; } - if (ga_add_string(&ga, line) == FAIL) + if (ga_copy_string(&ga, line) == FAIL) break; if (*skipwhite(line) == '}') break; diff --git a/src/userfunc.c b/src/userfunc.c index 3617e7b106..020d1bcfcb 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -166,13 +166,13 @@ one_function_arg( /* * Handle line continuation in function arguments or body. - * Get a next line, store it in "eap" if appropriate and use "line_to_free" to - * handle freeing the line later. + * Get a next line, store it in "eap" if appropriate and put the line in + * "lines_to_free" to free the line later. */ static char_u * get_function_line( exarg_T *eap, - char_u **line_to_free, + garray_T *lines_to_free, int indent, getline_opt_T getline_options) { @@ -184,10 +184,11 @@ get_function_line( theline = eap->getline(':', eap->cookie, indent, getline_options); if (theline != NULL) { - if (*eap->cmdlinep == *line_to_free) + if (lines_to_free->ga_len > 0 + && *eap->cmdlinep == ((char_u **)lines_to_free->ga_data) + [lines_to_free->ga_len - 1]) *eap->cmdlinep = theline; - vim_free(*line_to_free); - *line_to_free = theline; + ga_add_string(lines_to_free, theline); } return theline; @@ -210,7 +211,7 @@ get_function_args( garray_T *default_args, int skip, exarg_T *eap, - char_u **line_to_free) + garray_T *lines_to_free) { int mustend = FALSE; char_u *arg; @@ -241,7 +242,7 @@ get_function_args( && (*p == NUL || (VIM_ISWHITE(*whitep) && *p == '#'))) { // End of the line, get the next one. - char_u *theline = get_function_line(eap, line_to_free, 0, + char_u *theline = get_function_line(eap, lines_to_free, 0, GETLINE_CONCAT_CONT); if (theline == NULL) @@ -677,7 +678,7 @@ get_function_body( exarg_T *eap, garray_T *newlines, char_u *line_arg_in, - char_u **line_to_free) + garray_T *lines_to_free) { linenr_T sourcing_lnum_top = SOURCING_LNUM; linenr_T sourcing_lnum_off; @@ -744,7 +745,7 @@ get_function_body( } else { - theline = get_function_line(eap, line_to_free, indent, + theline = get_function_line(eap, lines_to_free, indent, getline_options); } if (KeyTyped) @@ -854,14 +855,20 @@ get_function_body( { // Another command follows. If the line came from "eap" // we can simply point into it, otherwise we need to - // change "eap->cmdlinep". + // change "eap->cmdlinep" to point to the last fetched + // line. eap->nextcmd = nextcmd; - if (*line_to_free != NULL - && *eap->cmdlinep != *line_to_free) + if (lines_to_free->ga_len > 0 + && *eap->cmdlinep != + ((char_u **)lines_to_free->ga_data) + [lines_to_free->ga_len - 1]) { + // *cmdlinep will be freed later, thus remove the + // line from lines_to_free. vim_free(*eap->cmdlinep); - *eap->cmdlinep = *line_to_free; - *line_to_free = NULL; + *eap->cmdlinep = ((char_u **)lines_to_free->ga_data) + [lines_to_free->ga_len - 1]; + --lines_to_free->ga_len; } } break; @@ -1118,7 +1125,6 @@ lambda_function_body( garray_T newlines; char_u *cmdline = NULL; int ret = FAIL; - char_u *line_to_free = NULL; partial_T *pt; char_u *name; int lnum_save = -1; @@ -1144,12 +1150,9 @@ lambda_function_body( } ga_init2(&newlines, (int)sizeof(char_u *), 10); - if (get_function_body(&eap, &newlines, NULL, &line_to_free) == FAIL) - { - if (cmdline != line_to_free) - vim_free(cmdline); + if (get_function_body(&eap, &newlines, NULL, + &evalarg->eval_tofree_ga) == FAIL) goto erret; - } // When inside a lambda must add the function lines to evalarg.eval_ga. evalarg->eval_break_count += newlines.ga_len; @@ -1208,8 +1211,6 @@ lambda_function_body( { ((char_u **)(tfgap->ga_data))[tfgap->ga_len++] = cmdline; evalarg->eval_using_cmdline = TRUE; - if (cmdline == line_to_free) - line_to_free = NULL; } } else @@ -1278,7 +1279,6 @@ lambda_function_body( erret: if (lnum_save >= 0) SOURCING_LNUM = lnum_save; - vim_free(line_to_free); ga_clear_strings(&newlines); if (newargs != NULL) ga_clear_strings(newargs); @@ -3957,10 +3957,11 @@ list_functions(regmatch_T *regmatch) * ":function" also supporting nested ":def". * When "name_arg" is not NULL this is a nested function, using "name_arg" for * the function name. + * "lines_to_free" is a list of strings to be freed later. * Returns a pointer to the function or NULL if no function defined. */ ufunc_T * -define_function(exarg_T *eap, char_u *name_arg, char_u **line_to_free) +define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free) { int j; int c; @@ -4229,7 +4230,7 @@ define_function(exarg_T *eap, char_u *name_arg, char_u **line_to_free) if (get_function_args(&p, ')', &newargs, eap->cmdidx == CMD_def ? &argtypes : NULL, FALSE, NULL, &varargs, &default_args, eap->skip, - eap, line_to_free) == FAIL) + eap, lines_to_free) == FAIL) goto errret_2; whitep = p; @@ -4339,7 +4340,7 @@ define_function(exarg_T *eap, char_u *name_arg, char_u **line_to_free) // Do not define the function when getting the body fails and when // skipping. - if (get_function_body(eap, &newlines, line_arg, line_to_free) == FAIL + if (get_function_body(eap, &newlines, line_arg, lines_to_free) == FAIL || eap->skip) goto erret; @@ -4645,10 +4646,11 @@ ret_free: void ex_function(exarg_T *eap) { - char_u *line_to_free = NULL; + garray_T lines_to_free; - (void)define_function(eap, NULL, &line_to_free); - vim_free(line_to_free); + ga_init2(&lines_to_free, sizeof(char_u *), 50); + (void)define_function(eap, NULL, &lines_to_free); + ga_clear_strings(&lines_to_free); } /* diff --git a/src/version.c b/src/version.c index 542227c903..9e4ae19cb0 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4040, /**/ 4039, /**/ diff --git a/src/vim9compile.c b/src/vim9compile.c index 5af30fd719..90d7adbb79 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -810,7 +810,7 @@ func_needs_compiling(ufunc_T *ufunc, compiletype_T compile_type) * Compile a nested :def command. */ static char_u * -compile_nested_function(exarg_T *eap, cctx_T *cctx, char_u **line_to_free) +compile_nested_function(exarg_T *eap, cctx_T *cctx, garray_T *lines_to_free) { int is_global = *eap->arg == 'g' && eap->arg[1] == ':'; char_u *name_start = eap->arg; @@ -876,7 +876,7 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx, char_u **line_to_free) goto theend; } - ufunc = define_function(eap, lambda_name, line_to_free); + ufunc = define_function(eap, lambda_name, lines_to_free); if (ufunc == NULL) { r = eap->skip ? OK : FAIL; @@ -2496,7 +2496,7 @@ compile_def_function( cctx_T *outer_cctx) { char_u *line = NULL; - char_u *line_to_free = NULL; + garray_T lines_to_free; char_u *p; char *errormsg = NULL; // error message cctx_T cctx; @@ -2514,6 +2514,9 @@ compile_def_function( #endif int debug_lnum = -1; + // allocated lines are freed at the end + ga_init2(&lines_to_free, sizeof(char_u *), 50); + // When using a function that was compiled before: Free old instructions. // The index is reused. Otherwise add a new entry in "def_functions". if (ufunc->uf_dfunc_idx > 0) @@ -2681,8 +2684,8 @@ compile_def_function( if (line != NULL) { line = vim_strsave(line); - vim_free(line_to_free); - line_to_free = line; + if (ga_add_string(&lines_to_free, line) == FAIL) + goto erret; } } @@ -2926,7 +2929,7 @@ compile_def_function( case CMD_def: case CMD_function: ea.arg = p; - line = compile_nested_function(&ea, &cctx, &line_to_free); + line = compile_nested_function(&ea, &cctx, &lines_to_free); break; case CMD_return: @@ -3236,7 +3239,7 @@ erret: if (do_estack_push) estack_pop(); - vim_free(line_to_free); + ga_clear_strings(&lines_to_free); free_imported(&cctx); free_locals(&cctx); ga_clear(&cctx.ctx_type_stack); diff --git a/src/viminfo.c b/src/viminfo.c index 3f9e5f3beb..ac0d3856e7 100644 --- a/src/viminfo.c +++ b/src/viminfo.c @@ -2730,7 +2730,7 @@ read_viminfo_barline(vir_T *virp, int got_encoding, int force, int writing) { // Continuation line of an unrecognized item. if (writing) - ga_add_string(&virp->vir_barlines, virp->vir_line); + ga_copy_string(&virp->vir_barlines, virp->vir_line); } else { @@ -2769,7 +2769,7 @@ read_viminfo_barline(vir_T *virp, int got_encoding, int force, int writing) default: // copy unrecognized line (for future use) if (writing) - ga_add_string(&virp->vir_barlines, virp->vir_line); + ga_copy_string(&virp->vir_barlines, virp->vir_line); } for (i = 0; i < values.ga_len; ++i) { From aa9b3cacd52a6c34591bbd89fb6b06d4c097fe03 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 8 Jan 2022 15:44:22 +0000 Subject: [PATCH 18/28] patch 8.2.4041: using unitialized pointer Problem: Using unitialized pointer. Solution: Store "ht" when variable is in another script. --- src/evalvars.c | 4 ++++ src/version.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/evalvars.c b/src/evalvars.c index 965b2048e4..3be9993fdc 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -2898,7 +2898,11 @@ find_var_also_in_script(char_u *name, hashtab_T **htp, int no_autoload) dictitem_T *di = find_var_in_ht(ht, 0, p + 1, no_autoload); if (di != NULL) + { + if (htp != NULL) + *htp = ht; return di; + } } } } diff --git a/src/version.c b/src/version.c index 9e4ae19cb0..27512d44f4 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4041, /**/ 4040, /**/ From 143367256836b0f69881dc0c65ff165ae091dbc5 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 8 Jan 2022 16:02:59 +0000 Subject: [PATCH 19/28] patch 8.2.4042: Vim9: build error Problem: Vim9: build error. Solution: Use grow array instead of character pointer. --- src/version.c | 2 ++ src/vim9execute.c | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/version.c b/src/version.c index 27512d44f4..579718e7b0 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4042, /**/ 4041, /**/ diff --git a/src/vim9execute.c b/src/vim9execute.c index 63c07fe043..5fab27dc43 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -3344,13 +3344,14 @@ exec_instructions(ectx_T *ectx) list_functions(NULL); else { - exarg_T ea; - char_u *line_to_free = NULL; + exarg_T ea; + garray_T lines_to_free; CLEAR_FIELD(ea); ea.cmd = ea.arg = iptr->isn_arg.string; - define_function(&ea, NULL, &line_to_free); - vim_free(line_to_free); + ga_init2(&lines_to_free, sizeof(char_u *), 50); + define_function(&ea, NULL, &lines_to_free); + ga_clear_strings(&lines_to_free); } break; From 04935fb17e5f0f66b82cf4546b9752d3d1fa650e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 8 Jan 2022 16:19:22 +0000 Subject: [PATCH 20/28] patch 8.2.4043: using int for second argument of ga_init2() Problem: Using int for second argument of ga_init2(). Solution: Remove unnessary type cast (int) when using sizeof(). --- src/arglist.c | 4 ++-- src/channel.c | 2 +- src/cmdexpand.c | 6 +++--- src/dict.c | 2 +- src/digraph.c | 2 +- src/eval.c | 2 +- src/evalfunc.c | 2 +- src/evalvars.c | 2 +- src/evalwindow.c | 2 +- src/ex_docmd.c | 2 +- src/fileio.c | 2 +- src/filepath.c | 4 ++-- src/findfile.c | 4 ++-- src/fold.c | 6 +++--- src/hardcopy.c | 4 ++-- src/help.c | 2 +- src/if_py_both.h | 2 +- src/job.c | 4 ++-- src/list.c | 6 +++--- src/menu.c | 2 +- src/os_win32.c | 2 +- src/register.c | 2 +- src/scriptfile.c | 6 +++--- src/spellfile.c | 12 ++++++------ src/spellsuggest.c | 6 +++--- src/strings.c | 4 ++-- src/syntax.c | 4 ++-- src/tag.c | 4 ++-- src/terminal.c | 8 ++++---- src/undo.c | 2 +- src/usercmd.c | 2 +- src/userfunc.c | 14 +++++++------- src/version.c | 2 ++ src/vim9execute.c | 2 +- src/viminfo.c | 2 +- src/window.c | 2 +- 36 files changed, 69 insertions(+), 67 deletions(-) diff --git a/src/arglist.c b/src/arglist.c index 3ca5e4ccce..fbd99af0d3 100644 --- a/src/arglist.c +++ b/src/arglist.c @@ -51,7 +51,7 @@ alist_clear(alist_T *al) void alist_init(alist_T *al) { - ga_init2(&al->al_ga, (int)sizeof(aentry_T), 5); + ga_init2(&al->al_ga, sizeof(aentry_T), 5); } /* @@ -275,7 +275,7 @@ do_one_arg(char_u *str) static int get_arglist(garray_T *gap, char_u *str, int escaped) { - ga_init2(gap, (int)sizeof(char_u *), 20); + ga_init2(gap, sizeof(char_u *), 20); while (*str != NUL) { if (ga_grow(gap, 1) == FAIL) diff --git a/src/channel.c b/src/channel.c index 4ab05499a5..0b8bfb3ba3 100644 --- a/src/channel.c +++ b/src/channel.c @@ -2306,7 +2306,7 @@ channel_add_block_id(chanpart_T *chanpart, int id) garray_T *gap = &chanpart->ch_block_ids; if (gap->ga_growsize == 0) - ga_init2(gap, (int)sizeof(int), 10); + ga_init2(gap, sizeof(int), 10); if (ga_grow(gap, 1) == OK) { ((int *)gap->ga_data)[gap->ga_len] = id; diff --git a/src/cmdexpand.c b/src/cmdexpand.c index e496bc3675..464dc96c19 100644 --- a/src/cmdexpand.c +++ b/src/cmdexpand.c @@ -2342,7 +2342,7 @@ expand_shellcmd( // Go over all directories in $PATH. Expand matches in that directory and // collect them in "ga". When "." is not in $PATH also expand for the // current directory, to find "subdir/cmd". - ga_init2(&ga, (int)sizeof(char *), 10); + ga_init2(&ga, sizeof(char *), 10); hash_init(&found_ht); for (s = path; ; s = e) { @@ -2497,7 +2497,7 @@ ExpandUserDefined( if (retstr == NULL) return FAIL; - ga_init2(&ga, (int)sizeof(char *), 3); + ga_init2(&ga, sizeof(char *), 3); for (s = retstr; *s != NUL; s = e) { e = vim_strchr(s, '\n'); @@ -2543,7 +2543,7 @@ ExpandUserList( if (retlist == NULL) return FAIL; - ga_init2(&ga, (int)sizeof(char *), 3); + ga_init2(&ga, sizeof(char *), 3); // Loop over the items in the list. FOR_ALL_LIST_ITEMS(retlist, li) { diff --git a/src/dict.c b/src/dict.c index 64c9d5f9e1..9c6b7d4532 100644 --- a/src/dict.c +++ b/src/dict.c @@ -759,7 +759,7 @@ dict2string(typval_T *tv, int copyID, int restore_copyID) if ((d = tv->vval.v_dict) == NULL) return NULL; - ga_init2(&ga, (int)sizeof(char), 80); + ga_init2(&ga, sizeof(char), 80); ga_append(&ga, '{'); todo = (int)d->dv_hashtab.ht_used; diff --git a/src/digraph.c b/src/digraph.c index 4c45e08900..f46e43f23e 100644 --- a/src/digraph.c +++ b/src/digraph.c @@ -2632,7 +2632,7 @@ ex_loadkeymap(exarg_T *eap) keymap_unload(); curbuf->b_kmap_state = 0; - ga_init2(&curbuf->b_kmap_ga, (int)sizeof(kmap_T), 20); + ga_init2(&curbuf->b_kmap_ga, sizeof(kmap_T), 20); // Set 'cpoptions' to "C" to avoid line continuation. p_cpo = (char_u *)"C"; diff --git a/src/eval.c b/src/eval.c index ec896814d4..390bb58110 100644 --- a/src/eval.c +++ b/src/eval.c @@ -487,7 +487,7 @@ typval2string(typval_T *tv, int convert) if (convert && tv->v_type == VAR_LIST) { - ga_init2(&ga, (int)sizeof(char), 80); + ga_init2(&ga, sizeof(char), 80); if (tv->vval.v_list != NULL) { list_join(&ga, tv->vval.v_list, (char_u *)"\n", TRUE, FALSE, 0); diff --git a/src/evalfunc.c b/src/evalfunc.c index bb50d5568f..949bab8d6b 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -3662,7 +3662,7 @@ execute_common(typval_T *argvars, typval_T *rettv, int arg_off) if (redir_execute) save_ga = redir_execute_ga; - ga_init2(&redir_execute_ga, (int)sizeof(char), 500); + ga_init2(&redir_execute_ga, sizeof(char), 500); redir_execute = TRUE; redir_off = FALSE; if (!echo_output) diff --git a/src/evalvars.c b/src/evalvars.c index 3be9993fdc..d93fed5b0e 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -4025,7 +4025,7 @@ clear_redir_lval(void) void init_redir_ga(void) { - ga_init2(&redir_ga, (int)sizeof(char), 500); + ga_init2(&redir_ga, sizeof(char), 500); } /* diff --git a/src/evalwindow.c b/src/evalwindow.c index 2a97adcf26..d632debe6d 100644 --- a/src/evalwindow.c +++ b/src/evalwindow.c @@ -1120,7 +1120,7 @@ f_winrestcmd(typval_T *argvars UNUSED, typval_T *rettv) garray_T ga; char_u buf[50]; - ga_init2(&ga, (int)sizeof(char), 70); + ga_init2(&ga, sizeof(char), 70); // Do this twice to handle some window layouts properly. for (i = 0; i < 2; ++i) diff --git a/src/ex_docmd.c b/src/ex_docmd.c index be95992f74..71343590d0 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -691,7 +691,7 @@ do_cmdline( #ifdef FEAT_EVAL CLEAR_FIELD(cstack); cstack.cs_idx = -1; - ga_init2(&lines_ga, (int)sizeof(wcmd_T), 10); + ga_init2(&lines_ga, sizeof(wcmd_T), 10); real_cookie = getline_cookie(fgetline, cookie); diff --git a/src/fileio.c b/src/fileio.c index c33625ad66..1fcf0d983a 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -4774,7 +4774,7 @@ readdir_core( struct dirent *dp; # endif - ga_init2(gap, (int)sizeof(void *), 20); + ga_init2(gap, sizeof(void *), 20); # ifdef FEAT_EVAL # define FREE_ITEM(item) do { \ diff --git a/src/filepath.c b/src/filepath.c index e44fcd0200..eb5b8e0502 100644 --- a/src/filepath.c +++ b/src/filepath.c @@ -1388,7 +1388,7 @@ f_globpath(typval_T *argvars, typval_T *rettv) } if (file != NULL && !error) { - ga_init2(&ga, (int)sizeof(char_u *), 10); + ga_init2(&ga, sizeof(char_u *), 10); globpath(tv_get_string(&argvars[0]), file, &ga, flags); if (rettv->v_type == VAR_STRING) rettv->vval.v_string = ga_concat_strings(&ga, "\n"); @@ -3908,7 +3908,7 @@ gen_expand_wildcards( /* * The matching file names are stored in a growarray. Init it empty. */ - ga_init2(&ga, (int)sizeof(char_u *), 30); + ga_init2(&ga, sizeof(char_u *), 30); for (i = 0; i < num_pat; ++i) { diff --git a/src/findfile.c b/src/findfile.c index 230f4870d4..110e06b1d6 100644 --- a/src/findfile.c +++ b/src/findfile.c @@ -2430,7 +2430,7 @@ uniquefy_paths(garray_T *gap, char_u *pattern) char_u *short_name; remove_duplicates(gap); - ga_init2(&path_ga, (int)sizeof(char_u *), 1); + ga_init2(&path_ga, sizeof(char_u *), 1); /* * We need to prepend a '*' at the beginning of file_pattern so that the @@ -2611,7 +2611,7 @@ expand_in_path( return 0; mch_dirname(curdir, MAXPATHL); - ga_init2(&path_ga, (int)sizeof(char_u *), 1); + ga_init2(&path_ga, sizeof(char_u *), 1); expand_path_option(curdir, &path_ga); vim_free(curdir); if (path_ga.ga_len == 0) diff --git a/src/fold.c b/src/fold.c index 5011887fb6..f314d7a349 100644 --- a/src/fold.c +++ b/src/fold.c @@ -647,7 +647,7 @@ foldCreate(linenr_T start, linenr_T end) if (ga_grow(gap, 1) == OK) { fp = (fold_T *)gap->ga_data + i; - ga_init2(&fold_ga, (int)sizeof(fold_T), 10); + ga_init2(&fold_ga, sizeof(fold_T), 10); // Count number of folds that will be contained in the new fold. for (cont = 0; i + cont < gap->ga_len; ++cont) @@ -1018,7 +1018,7 @@ foldMoveTo( void foldInitWin(win_T *new_win) { - ga_init2(&new_win->w_folds, (int)sizeof(fold_T), 10); + ga_init2(&new_win->w_folds, sizeof(fold_T), 10); } // find_wl_entry() {{{2 @@ -2868,7 +2868,7 @@ foldInsert(garray_T *gap, int i) if (gap->ga_len > 0 && i < gap->ga_len) mch_memmove(fp + 1, fp, sizeof(fold_T) * (gap->ga_len - i)); ++gap->ga_len; - ga_init2(&fp->fd_nested, (int)sizeof(fold_T), 10); + ga_init2(&fp->fd_nested, sizeof(fold_T), 10); return OK; } diff --git a/src/hardcopy.c b/src/hardcopy.c index 33c72b7112..c99dc5fa35 100644 --- a/src/hardcopy.c +++ b/src/hardcopy.c @@ -1650,7 +1650,7 @@ prt_flush_buffer(void) prt_write_string("s\n"); ga_clear(&prt_ps_buffer); - ga_init2(&prt_ps_buffer, (int)sizeof(char), prt_bufsiz); + ga_init2(&prt_ps_buffer, sizeof(char), prt_bufsiz); } } @@ -2649,7 +2649,7 @@ mch_print_init( prt_bufsiz = psettings->chars_per_line; if (prt_out_mbyte) prt_bufsiz *= 2; - ga_init2(&prt_ps_buffer, (int)sizeof(char), prt_bufsiz); + ga_init2(&prt_ps_buffer, sizeof(char), prt_bufsiz); prt_page_num = 0; diff --git a/src/help.c b/src/help.c index fca7cfc48b..16fbafc061 100644 --- a/src/help.c +++ b/src/help.c @@ -999,7 +999,7 @@ helptags_one( // If using the "++t" argument or generating tags for "$VIMRUNTIME/doc" // add the "help-tags" tag. - ga_init2(&ga, (int)sizeof(char_u *), 100); + ga_init2(&ga, sizeof(char_u *), 100); if (add_help_tags || fullpathcmp((char_u *)"$VIMRUNTIME/doc", dir, FALSE, TRUE) == FPC_SAME) { diff --git a/src/if_py_both.h b/src/if_py_both.h index 5364f6b2f5..8e349c55f8 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -3264,7 +3264,7 @@ FunctionRepr(FunctionObject *self) typval_T tv; char_u numbuf[NUMBUFLEN]; - ga_init2(&repr_ga, (int)sizeof(char), 70); + ga_init2(&repr_ga, sizeof(char), 70); ga_concat(&repr_ga, (char_u *)"name) ga_concat(&repr_ga, self->name); diff --git a/src/job.c b/src/job.c index 4055415b11..0ed33a78e5 100644 --- a/src/job.c +++ b/src/job.c @@ -1296,7 +1296,7 @@ job_start( job->jv_status = JOB_FAILED; #ifndef USE_ARGV - ga_init2(&ga, (int)sizeof(char*), 20); + ga_init2(&ga, sizeof(char*), 20); #endif if (opt_arg != NULL) @@ -1435,7 +1435,7 @@ job_start( { garray_T ga; - ga_init2(&ga, (int)sizeof(char), 200); + ga_init2(&ga, sizeof(char), 200); for (i = 0; i < argc; ++i) { if (i > 0) diff --git a/src/list.c b/src/list.c index 8658701b45..dca5ff0172 100644 --- a/src/list.c +++ b/src/list.c @@ -1299,7 +1299,7 @@ list2string(typval_T *tv, int copyID, int restore_copyID) if (tv->vval.v_list == NULL) return NULL; - ga_init2(&ga, (int)sizeof(char), 80); + ga_init2(&ga, sizeof(char), 80); ga_append(&ga, '['); CHECK_LIST_MATERIALIZE(tv->vval.v_list); if (list_join(&ga, tv->vval.v_list, (char_u *)", ", @@ -1412,7 +1412,7 @@ list_join( if (l->lv_len < 1) return OK; // nothing to do - ga_init2(&join_ga, (int)sizeof(join_T), l->lv_len); + ga_init2(&join_ga, sizeof(join_T), l->lv_len); retval = list_join_inner(gap, l, sep, echo_style, restore_copyID, copyID, &join_ga); @@ -1461,7 +1461,7 @@ f_join(typval_T *argvars, typval_T *rettv) if (sep != NULL) { - ga_init2(&ga, (int)sizeof(char), 80); + ga_init2(&ga, sizeof(char), 80); list_join(&ga, argvars[0].vval.v_list, sep, TRUE, FALSE, 0); ga_append(&ga, NUL); rettv->vval.v_string = (char_u *)ga.ga_data; diff --git a/src/menu.c b/src/menu.c index 614196aa0b..880a93a6db 100644 --- a/src/menu.c +++ b/src/menu.c @@ -2664,7 +2664,7 @@ ex_menutranslate(exarg_T *eap UNUSED) char_u *from, *from_noamp, *to; if (menutrans_ga.ga_itemsize == 0) - ga_init2(&menutrans_ga, (int)sizeof(menutrans_T), 5); + ga_init2(&menutrans_ga, sizeof(menutrans_T), 5); /* * ":menutrans clear": clear all translations. diff --git a/src/os_win32.c b/src/os_win32.c index fb1b29d71a..55df5064d8 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -5280,7 +5280,7 @@ mch_job_start(char *cmd, job_T *job, jobopt_T *options) ofd[1] = INVALID_HANDLE_VALUE; efd[0] = INVALID_HANDLE_VALUE; efd[1] = INVALID_HANDLE_VALUE; - ga_init2(&ga, (int)sizeof(wchar_t), 500); + ga_init2(&ga, sizeof(wchar_t), 500); jo = CreateJobObject(NULL, NULL); if (jo == NULL) diff --git a/src/register.c b/src/register.c index 08a73fe9b7..d604bae6b0 100644 --- a/src/register.c +++ b/src/register.c @@ -527,7 +527,7 @@ execreg_line_continuation(char_u **lines, long *idx) int j; char_u *str; - ga_init2(&ga, (int)sizeof(char_u), 400); + ga_init2(&ga, sizeof(char_u), 400); // search backwards to find the first line of this command. // Any line not starting with \ or "\ is the start of the diff --git a/src/scriptfile.c b/src/scriptfile.c index 8fb3cae015..c10a82f2cb 100644 --- a/src/scriptfile.c +++ b/src/scriptfile.c @@ -835,7 +835,7 @@ ExpandRTDir( *num_file = 0; *file = NULL; pat_len = (int)STRLEN(pat); - ga_init2(&ga, (int)sizeof(char *), 10); + ga_init2(&ga, sizeof(char *), 10); for (i = 0; dirnames[i] != NULL; ++i) { @@ -929,7 +929,7 @@ ExpandPackAddDir( *num_file = 0; *file = NULL; pat_len = (int)STRLEN(pat); - ga_init2(&ga, (int)sizeof(char *), 10); + ga_init2(&ga, sizeof(char *), 10); s = alloc(pat_len + 26); if (s == NULL) @@ -1833,7 +1833,7 @@ getsourceline( { garray_T ga; - ga_init2(&ga, (int)sizeof(char_u), 400); + ga_init2(&ga, sizeof(char_u), 400); ga_concat(&ga, line); if (*p == '\\') ga_concat(&ga, p + 1); diff --git a/src/spellfile.c b/src/spellfile.c index c00930dfed..af6c6ef2f9 100644 --- a/src/spellfile.c +++ b/src/spellfile.c @@ -5905,12 +5905,12 @@ mkspell( spin.si_ascii = ascii; spin.si_followup = TRUE; spin.si_rem_accents = TRUE; - ga_init2(&spin.si_rep, (int)sizeof(fromto_T), 20); - ga_init2(&spin.si_repsal, (int)sizeof(fromto_T), 20); - ga_init2(&spin.si_sal, (int)sizeof(fromto_T), 20); - ga_init2(&spin.si_map, (int)sizeof(char_u), 100); - ga_init2(&spin.si_comppat, (int)sizeof(char_u *), 20); - ga_init2(&spin.si_prefcond, (int)sizeof(char_u *), 50); + ga_init2(&spin.si_rep, sizeof(fromto_T), 20); + ga_init2(&spin.si_repsal, sizeof(fromto_T), 20); + ga_init2(&spin.si_sal, sizeof(fromto_T), 20); + ga_init2(&spin.si_map, sizeof(char_u), 100); + ga_init2(&spin.si_comppat, sizeof(char_u *), 20); + ga_init2(&spin.si_prefcond, sizeof(char_u *), 50); hash_init(&spin.si_commonwords); spin.si_newcompID = 127; // start compound ID at first maximum diff --git a/src/spellsuggest.c b/src/spellsuggest.c index e9f2cd570a..b2b402919f 100644 --- a/src/spellsuggest.c +++ b/src/spellsuggest.c @@ -774,8 +774,8 @@ spell_find_suggest( // Set the info in "*su". CLEAR_POINTER(su); - ga_init2(&su->su_ga, (int)sizeof(suggest_T), 10); - ga_init2(&su->su_sga, (int)sizeof(suggest_T), 10); + ga_init2(&su->su_ga, sizeof(suggest_T), 10); + ga_init2(&su->su_sga, sizeof(suggest_T), 10); if (*badptr == NUL) return; hash_init(&su->su_banned); @@ -2943,7 +2943,7 @@ score_combine(suginfo_T *su) check_suggestions(su, &su->su_sga); (void)cleanup_suggestions(&su->su_sga, su->su_maxscore, su->su_maxcount); - ga_init2(&ga, (int)sizeof(suginfo_T), 1); + ga_init2(&ga, sizeof(suginfo_T), 1); if (ga_grow(&ga, su->su_ga.ga_len + su->su_sga.ga_len) == FAIL) return; diff --git a/src/strings.c b/src/strings.c index 5c55c1ecbf..f6affd6fe0 100644 --- a/src/strings.c +++ b/src/strings.c @@ -893,7 +893,7 @@ string_filter_map( // set_vim_var_nr() doesn't set the type set_vim_var_type(VV_KEY, VAR_NUMBER); - ga_init2(&ga, (int)sizeof(char), 80); + ga_init2(&ga, sizeof(char), 80); for (p = str; *p != NUL; p += len) { typval_T newtv; @@ -1673,7 +1673,7 @@ f_tr(typval_T *argvars, typval_T *rettv) rettv->vval.v_string = NULL; if (fromstr == NULL || tostr == NULL) return; // type error; errmsg already given - ga_init2(&ga, (int)sizeof(char), 80); + ga_init2(&ga, sizeof(char), 80); if (!has_mbyte) // not multi-byte: fromstr and tostr must be the same length diff --git a/src/syntax.c b/src/syntax.c index f4d7f1d421..d2e15a36c7 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -1414,7 +1414,7 @@ store_current_state(void) { // Need to clear it, might be something remaining from when the // length was less than SST_FIX_STATES. - ga_init2(&sp->sst_union.sst_ga, (int)sizeof(bufstate_T), 1); + ga_init2(&sp->sst_union.sst_ga, sizeof(bufstate_T), 1); if (ga_grow(&sp->sst_union.sst_ga, current_state.ga_len) == FAIL) sp->sst_stacksize = 0; else @@ -1833,7 +1833,7 @@ syn_current_attr( // Init the list of zero-width matches with a nextlist. This is used to // avoid matching the same item in the same position twice. - ga_init2(&zero_width_next_ga, (int)sizeof(int), 10); + ga_init2(&zero_width_next_ga, sizeof(int), 10); // use syntax iskeyword option save_chartab(buf_chartab); diff --git a/src/tag.c b/src/tag.c index bf816e16a8..346e63c213 100644 --- a/src/tag.c +++ b/src/tag.c @@ -1752,7 +1752,7 @@ find_tags( #endif for (mtt = 0; mtt < MT_COUNT; ++mtt) { - ga_init2(&ga_match[mtt], (int)sizeof(char_u *), 100); + ga_init2(&ga_match[mtt], sizeof(char_u *), 100); hash_init(&ht_match[mtt]); } @@ -2952,7 +2952,7 @@ get_tagfname( if (first) { ga_clear_strings(&tag_fnames); - ga_init2(&tag_fnames, (int)sizeof(char_u *), 10); + ga_init2(&tag_fnames, sizeof(char_u *), 10); do_in_runtimepath((char_u *) #ifdef FEAT_MULTI_LANG # ifdef VMS diff --git a/src/terminal.c b/src/terminal.c index ab66ace444..281c673e8b 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -6674,8 +6674,8 @@ conpty_term_and_job_init( HANDLE i_ours = NULL; HANDLE o_ours = NULL; - ga_init2(&ga_cmd, (int)sizeof(char*), 20); - ga_init2(&ga_env, (int)sizeof(char*), 20); + ga_init2(&ga_cmd, sizeof(char*), 20); + ga_init2(&ga_env, sizeof(char*), 20); if (argvar->v_type == VAR_STRING) { @@ -7022,8 +7022,8 @@ winpty_term_and_job_init( garray_T ga_cmd, ga_env; char_u *cmd = NULL; - ga_init2(&ga_cmd, (int)sizeof(char*), 20); - ga_init2(&ga_env, (int)sizeof(char*), 20); + ga_init2(&ga_cmd, sizeof(char*), 20); + ga_init2(&ga_env, sizeof(char*), 20); if (argvar->v_type == VAR_STRING) { diff --git a/src/undo.c b/src/undo.c index ec972f0b64..4d186d4532 100644 --- a/src/undo.c +++ b/src/undo.c @@ -3081,7 +3081,7 @@ ex_undolist(exarg_T *eap UNUSED) */ mark = ++lastmark; nomark = ++lastmark; - ga_init2(&ga, (int)sizeof(char *), 20); + ga_init2(&ga, sizeof(char *), 20); uhp = curbuf->b_u_oldhead; while (uhp != NULL) diff --git a/src/usercmd.c b/src/usercmd.c index 40790a1f56..2830a50386 100644 --- a/src/usercmd.c +++ b/src/usercmd.c @@ -917,7 +917,7 @@ uc_add_command( { gap = &curbuf->b_ucmds; if (gap->ga_itemsize == 0) - ga_init2(gap, (int)sizeof(ucmd_T), 4); + ga_init2(gap, sizeof(ucmd_T), 4); } else gap = &ucmds; diff --git a/src/userfunc.c b/src/userfunc.c index 020d1bcfcb..b772913f15 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -222,11 +222,11 @@ get_function_args( char_u *whitep = *argp; if (newargs != NULL) - ga_init2(newargs, (int)sizeof(char_u *), 3); + ga_init2(newargs, sizeof(char_u *), 3); if (argtypes != NULL) - ga_init2(argtypes, (int)sizeof(char_u *), 3); + ga_init2(argtypes, sizeof(char_u *), 3); if (!skip && default_args != NULL) - ga_init2(default_args, (int)sizeof(char_u *), 3); + ga_init2(default_args, sizeof(char_u *), 3); if (varargs != NULL) *varargs = FALSE; @@ -1149,7 +1149,7 @@ lambda_function_body( eap.cookie = evalarg->eval_cookie; } - ga_init2(&newlines, (int)sizeof(char_u *), 10); + ga_init2(&newlines, sizeof(char_u *), 10); if (get_function_body(&eap, &newlines, NULL, &evalarg->eval_tofree_ga) == FAIL) goto erret; @@ -1436,7 +1436,7 @@ get_lambda_tv( if (pt == NULL) goto errret; - ga_init2(&newlines, (int)sizeof(char_u *), 1); + ga_init2(&newlines, sizeof(char_u *), 1); if (ga_grow(&newlines, 1) == FAIL) goto errret; @@ -1760,7 +1760,7 @@ get_func_tv( // Prepare for calling test_garbagecollect_now(), need to know // what variables are used on the call stack. if (funcargs.ga_itemsize == 0) - ga_init2(&funcargs, (int)sizeof(typval_T *), 50); + ga_init2(&funcargs, sizeof(typval_T *), 50); for (i = 0; i < argcount; ++i) if (ga_grow(&funcargs, 1) == OK) ((typval_T **)funcargs.ga_data)[funcargs.ga_len++] = @@ -4173,7 +4173,7 @@ define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free) goto ret_free; } - ga_init2(&newlines, (int)sizeof(char_u *), 10); + ga_init2(&newlines, sizeof(char_u *), 10); if (!eap->skip && name_arg == NULL) { diff --git a/src/version.c b/src/version.c index 579718e7b0..cdfadebdad 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4043, /**/ 4042, /**/ diff --git a/src/vim9execute.c b/src/vim9execute.c index 5fab27dc43..311baca016 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -174,7 +174,7 @@ static garray_T dict_stack = GA_EMPTY; dict_stack_save(typval_T *tv) { if (dict_stack.ga_growsize == 0) - ga_init2(&dict_stack, (int)sizeof(typval_T), 10); + ga_init2(&dict_stack, sizeof(typval_T), 10); if (ga_grow(&dict_stack, 1) == FAIL) return FAIL; ((typval_T *)dict_stack.ga_data)[dict_stack.ga_len] = *tv; diff --git a/src/viminfo.c b/src/viminfo.c index ac0d3856e7..3620b58de5 100644 --- a/src/viminfo.c +++ b/src/viminfo.c @@ -2912,7 +2912,7 @@ do_viminfo(FILE *fp_in, FILE *fp_out, int flags) return; vir.vir_fd = fp_in; vir.vir_conv.vc_type = CONV_NONE; - ga_init2(&vir.vir_barlines, (int)sizeof(char_u *), 100); + ga_init2(&vir.vir_barlines, sizeof(char_u *), 100); vir.vir_version = -1; if (fp_in != NULL) diff --git a/src/window.c b/src/window.c index 4a17c6241e..6d5d0a4b8a 100644 --- a/src/window.c +++ b/src/window.c @@ -5413,7 +5413,7 @@ win_size_save(garray_T *gap) { win_T *wp; - ga_init2(gap, (int)sizeof(int), 1); + ga_init2(gap, sizeof(int), 1); if (ga_grow(gap, win_count() * 2 + 1) == OK) { // first entry is value of 'lines' From 7c24dfddc28776eeff7464982ae5b94e187b6135 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 8 Jan 2022 17:03:55 +0000 Subject: [PATCH 21/28] patch 8.2.4044: Vim9: no error when importing the same script twice Problem: Vim9: no error when importing the same script twice. Solution: Give an error, unless it is a reload. --- src/errors.h | 2 ++ src/testdir/test_vim9_import.vim | 40 +++++++++++++++++--------------- src/version.c | 2 ++ src/vim9script.c | 38 ++++++++++++++++++++---------- 4 files changed, 51 insertions(+), 31 deletions(-) diff --git a/src/errors.h b/src/errors.h index 9facb82c4a..8e7ffee18d 100644 --- a/src/errors.h +++ b/src/errors.h @@ -2891,3 +2891,5 @@ EXTERN char e_cannot_unlet_imported_item_str[] INIT(= N_("E1260: Cannot unlet an imported item: %s")); EXTERN char e_cannot_import_dot_vim_without_using_as[] INIT(= N_("E1261: Cannot import .vim without using \"as\"")); +EXTERN char e_cannot_import_same_script_twice_str[] + INIT(= N_("E1262: Cannot import the same script twice: %s")); diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim index 9d09c63f6e..4e57f742f6 100644 --- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -189,25 +189,15 @@ def Test_vim9_import_export() writefile(import_star_as_lines_dot_space, 'Ximport.vim') assert_fails('source Ximport.vim', 'E1074:', '', 1, 'Func') - var import_func_duplicated =<< trim END + writefile(s:export_script_lines, 'Xexport2.vim') + var import_as_duplicated =<< trim END vim9script import './Xexport.vim' as expo - import './Xexport.vim' as expo - - ExportedInc() + import './Xexport2.vim' as expo END - writefile(import_func_duplicated, 'Ximport.vim') + writefile(import_as_duplicated, 'Ximport.vim') assert_fails('source Ximport.vim', 'E1073:', '', 3, 'Ximport.vim') - - var import_star_as_duplicated =<< trim END - vim9script - import './Xexport.vim' as Export - var some = 'other' - import './Xexport.vim' as Export - defcompile - END - writefile(import_star_as_duplicated, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E1073:', '', 4, 'Ximport.vim') + delete('Xexport2.vim') var import_star_as_lines_script_no_dot =<< trim END vim9script @@ -429,11 +419,20 @@ def Test_import_fails() export var Ref = TheFunc END writefile([], 'Xthat.vim') + lines =<< trim END import './Xthat.vim' as That That() END CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use That itself']) + + lines =<< trim END + import './Xthat.vim' as one + import './Xthat.vim' as two + END + CheckScriptFailure(lines, 'E1262:') + + delete('Xthat.vim') mkdir('Ximport') @@ -773,7 +772,14 @@ def Test_vim9_funcref() g:result = Xsort.FastSort() enddef Test() + END + writefile(lines, 'Xscript.vim') + source Xscript.vim + assert_equal([4, 3, 2, 1, 0], g:result) + unlet g:result + lines =<< trim END + vim9script # using a function imported with "as" import './Xsort.vim' as anAlias assert_equal('yes', anAlias.GetString('yes')) @@ -790,10 +796,6 @@ def Test_vim9_funcref() END writefile(lines, 'Xscript.vim') - source Xscript.vim - assert_equal([4, 3, 2, 1, 0], g:result) - - unlet g:result delete('Xsort.vim') delete('Xscript.vim') diff --git a/src/version.c b/src/version.c index cdfadebdad..86ab08594a 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4044, /**/ 4043, /**/ diff --git a/src/vim9script.c b/src/vim9script.c index e5e26959a4..3ebeab366a 100644 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -374,6 +374,8 @@ handle_import( int sid = -1; int res; long start_lnum = SOURCING_LNUM; + garray_T *import_gap; + int i; // The name of the file can be an expression, which must evaluate to a // string. @@ -440,6 +442,24 @@ handle_import( goto erret; } + import_gap = gap != NULL ? gap : &SCRIPT_ITEM(import_sid)->sn_imports; + for (i = 0; i < import_gap->ga_len; ++i) + { + imported_T *import = (imported_T *)import_gap->ga_data + i; + + if (import->imp_sid == sid) + { + if (import->imp_flags & IMP_FLAGS_RELOAD) + { + // encountering same script first ime on a reload is OK + import->imp_flags &= ~IMP_FLAGS_RELOAD; + break; + } + semsg(_(e_cannot_import_same_script_twice_str), tv.vval.v_string); + goto erret; + } + } + // Allow for the "as Name" to be in the next line. nextarg = eval_next_non_blank(expr_end, evalarg, &getnext); if (STRNCMP("as", nextarg, 2) == 0 && IS_WHITE_OR_NUL(nextarg[2])) @@ -494,22 +514,16 @@ handle_import( imported_T *imported; imported = find_imported(as_name, STRLEN(as_name), cctx); - if (imported != NULL && imported->imp_sid == sid) + if (imported != NULL && imported->imp_sid != sid) { - if (imported->imp_flags & IMP_FLAGS_RELOAD) - // import already defined on a previous script load - imported->imp_flags &= ~IMP_FLAGS_RELOAD; - else - { - semsg(_(e_name_already_defined_str), as_name); - goto erret; - } + semsg(_(e_name_already_defined_str), as_name); + goto erret; } - else if (check_defined(as_name, STRLEN(as_name), cctx, FALSE) == FAIL) + else if (imported == NULL + && check_defined(as_name, STRLEN(as_name), cctx, FALSE) == FAIL) goto erret; - imported = new_imported(gap != NULL ? gap - : &SCRIPT_ITEM(import_sid)->sn_imports); + imported = new_imported(import_gap); if (imported == NULL) goto erret; imported->imp_name = as_name; From 782b43d89473dac00e3a8e02224a8330b88dbfef Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Sat, 8 Jan 2022 18:43:40 +0000 Subject: [PATCH 22/28] patch 8.2.4045: some global functions are only used in one file Problem: Some global functions are only used in one file. Solution: Make the functions static. (Yegappan Lakshmanan, closes #9492) --- src/ex_getln.c | 50 ++++++++++---------- src/highlight.c | 31 +++++++------ src/proto/ex_getln.pro | 1 - src/proto/highlight.pro | 3 -- src/proto/vim9compile.pro | 1 - src/proto/vim9instr.pro | 3 -- src/proto/window.pro | 1 - src/version.c | 2 + src/vim9compile.c | 42 ++++++++--------- src/vim9instr.c | 6 +-- src/window.c | 96 +++++++++++++++++++-------------------- 11 files changed, 117 insertions(+), 119 deletions(-) diff --git a/src/ex_getln.c b/src/ex_getln.c index ede0f2020f..c63c8960f5 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -4095,7 +4095,33 @@ f_setcmdpos(typval_T *argvars, typval_T *rettv) if (pos >= 0) rettv->vval.v_number = set_cmdline_pos(pos); } +#endif +#if defined(FEAT_EVAL) || defined(FEAT_CMDWIN) +/* + * Get the current command-line type. + * Returns ':' or '/' or '?' or '@' or '>' or '-' + * Only works when the command line is being edited. + * Returns NUL when something is wrong. + */ + static int +get_cmdline_type(void) +{ + cmdline_info_T *p = get_ccline_ptr(); + + if (p == NULL) + return NUL; + if (p->cmdfirstc == NUL) + return +# ifdef FEAT_EVAL + (p->input_fn) ? '@' : +# endif + '-'; + return p->cmdfirstc; +} +#endif + +#if defined(FEAT_EVAL) || defined(PROTO) /* * "getcmdtype()" function */ @@ -4113,30 +4139,6 @@ f_getcmdtype(typval_T *argvars UNUSED, typval_T *rettv) #endif -#if defined(FEAT_EVAL) || defined(FEAT_CMDWIN) || defined(PROTO) -/* - * Get the current command-line type. - * Returns ':' or '/' or '?' or '@' or '>' or '-' - * Only works when the command line is being edited. - * Returns NUL when something is wrong. - */ - int -get_cmdline_type(void) -{ - cmdline_info_T *p = get_ccline_ptr(); - - if (p == NULL) - return NUL; - if (p->cmdfirstc == NUL) - return -# ifdef FEAT_EVAL - (p->input_fn) ? '@' : -# endif - '-'; - return p->cmdfirstc; -} -#endif - /* * Return the first character of the current command line. */ diff --git a/src/highlight.c b/src/highlight.c index efbc5b10e2..a8af2b18cf 100644 --- a/src/highlight.c +++ b/src/highlight.c @@ -460,6 +460,21 @@ init_highlight( #endif } +#if defined(FEAT_EVAL) && (defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)) +/* + * Load a default color list. Intended to support legacy color names but allows + * the user to override the color values. Only loaded once. + */ + static void +load_default_colors_lists() +{ + // Lacking a default color list isn't the end of the world but it is likely + // an inconvenience so users should know when it is missing. + if (source_runtime((char_u *)"colors/lists/default.vim", DIP_ALL) != OK) + msg("failed to load colors/lists/default.vim"); +} +#endif + /* * Load color file "name". * Return OK for success, FAIL for failure. @@ -2272,7 +2287,7 @@ hex_digit(int c) return 0x1ffffff; } - guicolor_T + static guicolor_T decode_hex_color(char_u *hex) { guicolor_T color; @@ -2294,7 +2309,7 @@ decode_hex_color(char_u *hex) // such name exists in the color table. The convention is to use lowercase for // all keys in the v:colornames dictionary. The value can be either a string in // the form #rrggbb or a number, either of which is converted to a guicolor_T. - guicolor_T + static guicolor_T colorname2rgb(char_u *name) { dict_T *colornames_table = get_vim_var_dict(VV_COLORNAMES); @@ -2335,18 +2350,6 @@ colorname2rgb(char_u *name) return INVALCOLOR; } -/* - * Load a default color list. Intended to support legacy color names but allows - * the user to override the color values. Only loaded once. - */ - void -load_default_colors_lists() -{ - // Lacking a default color list isn't the end of the world but it is likely - // an inconvenience so users should know when it is missing. - if (source_runtime((char_u *)"colors/lists/default.vim", DIP_ALL) != OK) - msg("failed to load colors/lists/default.vim"); -} #endif guicolor_T diff --git a/src/proto/ex_getln.pro b/src/proto/ex_getln.pro index d56893a657..f97719b756 100644 --- a/src/proto/ex_getln.pro +++ b/src/proto/ex_getln.pro @@ -34,7 +34,6 @@ void f_getcmdline(typval_T *argvars, typval_T *rettv); void f_getcmdpos(typval_T *argvars, typval_T *rettv); void f_setcmdpos(typval_T *argvars, typval_T *rettv); void f_getcmdtype(typval_T *argvars, typval_T *rettv); -int get_cmdline_type(void); int get_cmdline_firstc(void); int get_list_range(char_u **str, int *num1, int *num2); char *check_cedit(void); diff --git a/src/proto/highlight.pro b/src/proto/highlight.pro index b17f40df30..5635a17384 100644 --- a/src/proto/highlight.pro +++ b/src/proto/highlight.pro @@ -14,9 +14,6 @@ void hl_set_font_name(char_u *font_name); void hl_set_bg_color_name(char_u *name); void hl_set_fg_color_name(char_u *name); guicolor_T color_name2handle(char_u *name); -guicolor_T decode_hex_color(char_u *hex); -guicolor_T colorname2rgb(char_u *name); -void load_default_colors_lists(void); guicolor_T gui_get_color_cmn(char_u *name); guicolor_T gui_get_rgb_color_cmn(int r, int g, int b); int get_cterm_attr_idx(int attr, int fg, int bg); diff --git a/src/proto/vim9compile.pro b/src/proto/vim9compile.pro index 33290d09e7..98c40c86cb 100644 --- a/src/proto/vim9compile.pro +++ b/src/proto/vim9compile.pro @@ -8,7 +8,6 @@ int need_type(type_T *actual, type_T *expected, int offset, int arg_idx, cctx_T lvar_T *reserve_local(cctx_T *cctx, char_u *name, size_t len, int isConst, type_T *type); int get_script_item_idx(int sid, char_u *name, int check_writable, cctx_T *cctx); imported_T *find_imported(char_u *name, size_t len, cctx_T *cctx); -imported_T *find_imported_in_script(char_u *name, size_t len, int sid); char_u *may_peek_next_line(cctx_T *cctx, char_u *arg, char_u **nextp); char_u *peek_next_line_from_context(cctx_T *cctx); char_u *next_line_from_context(cctx_T *cctx, int skip_comment); diff --git a/src/proto/vim9instr.pro b/src/proto/vim9instr.pro index b20dcf7d1b..c9455003e9 100644 --- a/src/proto/vim9instr.pro +++ b/src/proto/vim9instr.pro @@ -1,7 +1,6 @@ /* vim9instr.c */ isn_T *generate_instr(cctx_T *cctx, isntype_T isn_type); isn_T *generate_instr_drop(cctx_T *cctx, isntype_T isn_type, int drop); -isn_T *generate_instr_type2(cctx_T *cctx, isntype_T isn_type, type_T *type, type_T *decl_type); isn_T *generate_instr_type(cctx_T *cctx, isntype_T isn_type, type_T *type); isn_T *generate_instr_debug(cctx_T *cctx); int may_generate_2STRING(int offset, int tolerant, cctx_T *cctx); @@ -28,9 +27,7 @@ int generate_GETITEM(cctx_T *cctx, int index, int with_op); int generate_SLICE(cctx_T *cctx, int count); int generate_CHECKLEN(cctx_T *cctx, int min_len, int more_OK); int generate_STORE(cctx_T *cctx, isntype_T isn_type, int idx, char_u *name); -int generate_STOREOUTER(cctx_T *cctx, int idx, int level); int generate_STORENR(cctx_T *cctx, int idx, varnumber_T value); -int generate_STOREOPT(cctx_T *cctx, isntype_T isn_type, char_u *name, int opt_flags); int generate_LOAD(cctx_T *cctx, isntype_T isn_type, int idx, char_u *name, type_T *type); int generate_LOADOUTER(cctx_T *cctx, int idx, int nesting, type_T *type); int generate_LOADV(cctx_T *cctx, char_u *name, int error); diff --git a/src/proto/window.pro b/src/proto/window.pro index 740d310b76..654d36a6e3 100644 --- a/src/proto/window.pro +++ b/src/proto/window.pro @@ -43,7 +43,6 @@ tabpage_T *win_find_tabpage(win_T *win); win_T *win_vert_neighbor(tabpage_T *tp, win_T *wp, int up, long count); win_T *win_horz_neighbor(tabpage_T *tp, win_T *wp, int left, long count); void win_enter(win_T *wp, int undo_sync); -void fix_current_dir(void); win_T *buf_jump_open_win(buf_T *buf); win_T *buf_jump_open_tab(buf_T *buf); void win_free_popup(win_T *win); diff --git a/src/version.c b/src/version.c index 86ab08594a..a1dea1fea0 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4045, /**/ 4044, /**/ diff --git a/src/vim9compile.c b/src/vim9compile.c index 90d7adbb79..11e3226451 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -557,6 +557,27 @@ get_script_item_idx(int sid, char_u *name, int check_writable, cctx_T *cctx) return -1; } + static imported_T * +find_imported_in_script(char_u *name, size_t len, int sid) +{ + scriptitem_T *si; + int idx; + + if (!SCRIPT_ID_VALID(sid)) + return NULL; + si = SCRIPT_ITEM(sid); + for (idx = 0; idx < si->sn_imports.ga_len; ++idx) + { + imported_T *import = ((imported_T *)si->sn_imports.ga_data) + idx; + + if (len == 0 ? STRCMP(name, import->imp_name) == 0 + : STRLEN(import->imp_name) == len + && STRNCMP(name, import->imp_name, len) == 0) + return import; + } + return NULL; +} + /* * Find "name" in imported items of the current script or in "cctx" if not * NULL. @@ -583,27 +604,6 @@ find_imported(char_u *name, size_t len, cctx_T *cctx) return find_imported_in_script(name, len, current_sctx.sc_sid); } - imported_T * -find_imported_in_script(char_u *name, size_t len, int sid) -{ - scriptitem_T *si; - int idx; - - if (!SCRIPT_ID_VALID(sid)) - return NULL; - si = SCRIPT_ITEM(sid); - for (idx = 0; idx < si->sn_imports.ga_len; ++idx) - { - imported_T *import = ((imported_T *)si->sn_imports.ga_data) + idx; - - if (len == 0 ? STRCMP(name, import->imp_name) == 0 - : STRLEN(import->imp_name) == len - && STRNCMP(name, import->imp_name, len) == 0) - return import; - } - return NULL; -} - /* * Free all imported variables. */ diff --git a/src/vim9instr.c b/src/vim9instr.c index 4961695f07..8ce32a766a 100644 --- a/src/vim9instr.c +++ b/src/vim9instr.c @@ -66,7 +66,7 @@ generate_instr_drop(cctx_T *cctx, isntype_T isn_type, int drop) * Generate instruction "isn_type" and put "type" on the type stack, * use "decl_type" for the declared type. */ - isn_T * + static isn_T * generate_instr_type2( cctx_T *cctx, isntype_T isn_type, @@ -828,7 +828,7 @@ generate_STORE(cctx_T *cctx, isntype_T isn_type, int idx, char_u *name) /* * Generate an ISN_STOREOUTER instruction. */ - int + static int generate_STOREOUTER(cctx_T *cctx, int idx, int level) { isn_T *isn; @@ -862,7 +862,7 @@ generate_STORENR(cctx_T *cctx, int idx, varnumber_T value) /* * Generate an ISN_STOREOPT or ISN_STOREFUNCOPT instruction */ - int + static int generate_STOREOPT( cctx_T *cctx, isntype_T isn_type, diff --git a/src/window.c b/src/window.c index 6d5d0a4b8a..05e85baf36 100644 --- a/src/window.c +++ b/src/window.c @@ -4734,6 +4734,54 @@ win_enter(win_T *wp, int undo_sync) | WEE_TRIGGER_ENTER_AUTOCMDS | WEE_TRIGGER_LEAVE_AUTOCMDS); } +/* + * Used after making another window the current one: change directory if + * needed. + */ + static void +fix_current_dir(void) +{ +#ifdef FEAT_AUTOCHDIR + if (p_acd) + do_autochdir(); + else +#endif + if (curwin->w_localdir != NULL || curtab->tp_localdir != NULL) + { + char_u *dirname; + + // Window or tab has a local directory: Save current directory as + // global directory (unless that was done already) and change to the + // local directory. + if (globaldir == NULL) + { + char_u cwd[MAXPATHL]; + + if (mch_dirname(cwd, MAXPATHL) == OK) + globaldir = vim_strsave(cwd); + } + if (curwin->w_localdir != NULL) + dirname = curwin->w_localdir; + else + dirname = curtab->tp_localdir; + + if (mch_chdir((char *)dirname) == 0) + { + last_chdir_reason = NULL; + shorten_fnames(TRUE); + } + } + else if (globaldir != NULL) + { + // Window doesn't have a local directory and we are not in the global + // directory: Change to the global directory. + vim_ignored = mch_chdir((char *)globaldir); + VIM_CLEAR(globaldir); + last_chdir_reason = NULL; + shorten_fnames(TRUE); + } +} + /* * Make window "wp" the current window. * Can be called with "flags" containing WEE_CURWIN_INVALID, which means that @@ -4858,54 +4906,6 @@ win_enter_ext(win_T *wp, int flags) return did_decrement; } -/* - * Used after making another window the current one: change directory if - * needed. - */ - void -fix_current_dir(void) -{ -#ifdef FEAT_AUTOCHDIR - if (p_acd) - do_autochdir(); - else -#endif - if (curwin->w_localdir != NULL || curtab->tp_localdir != NULL) - { - char_u *dirname; - - // Window or tab has a local directory: Save current directory as - // global directory (unless that was done already) and change to the - // local directory. - if (globaldir == NULL) - { - char_u cwd[MAXPATHL]; - - if (mch_dirname(cwd, MAXPATHL) == OK) - globaldir = vim_strsave(cwd); - } - if (curwin->w_localdir != NULL) - dirname = curwin->w_localdir; - else - dirname = curtab->tp_localdir; - - if (mch_chdir((char *)dirname) == 0) - { - last_chdir_reason = NULL; - shorten_fnames(TRUE); - } - } - else if (globaldir != NULL) - { - // Window doesn't have a local directory and we are not in the global - // directory: Change to the global directory. - vim_ignored = mch_chdir((char *)globaldir); - VIM_CLEAR(globaldir); - last_chdir_reason = NULL; - shorten_fnames(TRUE); - } -} - /* * Jump to the first open window that contains buffer "buf", if one exists. * Returns a pointer to the window found, otherwise NULL. From b2810f123cbf4b585f8bc5f0e594a6690d95729a Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 8 Jan 2022 21:38:52 +0000 Subject: [PATCH 23/28] patch 8.2.4046: some error messages not in the right place Problem: Some error messages not in the right place. Solution: Adjust the errors file. Fix typo. --- src/errors.h | 11 +++++++++-- src/regexp_bt.c | 2 +- src/typval.c | 2 +- src/version.c | 2 ++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/errors.h b/src/errors.h index 8e7ffee18d..1c723acac3 100644 --- a/src/errors.h +++ b/src/errors.h @@ -23,6 +23,7 @@ EXTERN char e_command_not_allowed_from_vimrc_in_current_dir_or_tag_search[] INIT(= N_("E12: Command not allowed from exrc/vimrc in current dir or tag search")); EXTERN char e_file_exists[] INIT(= N_("E13: File exists (add ! to override)")); +// E14 unused #ifdef FEAT_EVAL EXTERN char e_invalid_expression_str[] INIT(= N_("E15: Invalid expression: \"%s\"")); @@ -135,6 +136,9 @@ EXTERN char e_unmatched_str_open[] INIT(= N_("E54: Unmatched %s(")); EXTERN char e_unmatched_str_close[] INIT(= N_("E55: Unmatched %s)")); +// E56 unused +// E57 unused +// E58 unused EXTERN char e_invalid_character_after_str_at[] INIT(= N_("E59: invalid character after %s@")); EXTERN char e_too_many_complex_str_curly[] @@ -155,6 +159,8 @@ EXTERN char e_z_not_allowed_here[] EXTERN char e_z1_z9_not_allowed_here[] INIT(= N_("E67: \\z1 - \\z9 not allowed here")); #endif +EXTERN char e_invalid_character_after_bsl_z[] + INIT(= N_("E68: Invalid character after \\z")); EXTERN char e_missing_sb_after_str[] INIT(= N_("E69: Missing ] after %s%%[")); EXTERN char e_empty_str_brackets[] @@ -652,6 +658,7 @@ EXTERN char e_cannot_use_function_as_method_str[] EXTERN char e_unable_to_read_server_reply[] INIT(= N_("E277: Unable to read a server reply")); #endif +// E278 unused #ifdef FEAT_TERMINAL EXTERN char e_sorry_plusplusshell_not_supported_on_this_system[] INIT(= N_("E279: Sorry, ++shell is not supported on this system")); @@ -840,7 +847,7 @@ EXTERN char e_screen_mode_setting_not_supported[] EXTERN char e_cannot_execute_shell_with_f_option[] INIT(= N_("E360: Cannot execute shell with -f option")); // E361 unused -EXTERN char e_using_boolean_valud_as_float[] +EXTERN char e_using_boolean_value_as_float[] INIT(= N_("E362: Using a boolean value as a Float")); EXTERN char e_pattern_uses_more_memory_than_maxmempattern[] INIT(= N_("E363: pattern uses more memory than 'maxmempattern'")); @@ -1249,7 +1256,7 @@ EXTERN char e_comma_required[] INIT(= N_("E536: comma required")); EXTERN char e_commentstring_must_be_empty_or_contain_str[] INIT(= N_("E537: 'commentstring' must be empty or contain %s")); -// E538 unused (perhaps 538.nl ?) +// E538 unused EXTERN char e_illegal_character_str[] INIT(= N_("E539: Illegal character <%s>")); EXTERN char e_unclosed_expression_sequence[] diff --git a/src/regexp_bt.c b/src/regexp_bt.c index 9286d911ae..aee5c1becb 100644 --- a/src/regexp_bt.c +++ b/src/regexp_bt.c @@ -1489,7 +1489,7 @@ regatom(int *flagp) return NULL; break; - default: EMSG_RET_NULL(_("E68: Invalid character after \\z")); + default: EMSG_RET_NULL(_(e_invalid_character_after_bsl_z)); } } break; diff --git a/src/typval.c b/src/typval.c index eb0ef77b74..ab226403df 100644 --- a/src/typval.c +++ b/src/typval.c @@ -320,7 +320,7 @@ tv_get_float_chk(typval_T *varp, int *error) emsg(_(e_using_dictionary_as_float)); break; case VAR_BOOL: - emsg(_(e_using_boolean_valud_as_float)); + emsg(_(e_using_boolean_value_as_float)); break; case VAR_SPECIAL: emsg(_(e_using_special_value_as_float)); diff --git a/src/version.c b/src/version.c index a1dea1fea0..f2845e2106 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4046, /**/ 4045, /**/ From 2f0936cb9a2eb026acac03e6a8fd0b2a5d97508b Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 8 Jan 2022 21:51:59 +0000 Subject: [PATCH 24/28] Update runtime files --- runtime/doc/builtin.txt | 21 +++-- runtime/doc/cmdline.txt | 8 +- runtime/doc/editing.txt | 2 +- runtime/doc/eval.txt | 33 +++---- runtime/doc/helphelp.txt | 4 +- runtime/doc/if_cscop.txt | 4 +- runtime/doc/if_perl.txt | 3 +- runtime/doc/if_tcl.txt | 4 +- runtime/doc/indent.txt | 4 +- runtime/doc/insert.txt | 4 +- runtime/doc/map.txt | 7 +- runtime/doc/mbyte.txt | 6 +- runtime/doc/message.txt | 14 +-- runtime/doc/options.txt | 14 +-- runtime/doc/os_dos.txt | 12 +-- runtime/doc/pattern.txt | 27 +++--- runtime/doc/popup.txt | 6 +- runtime/doc/quickfix.txt | 4 +- runtime/doc/starting.txt | 4 +- runtime/doc/syntax.txt | 4 +- runtime/doc/tags | 20 +++- runtime/doc/terminal.txt | 1 + runtime/doc/todo.txt | 20 +++- runtime/doc/usr_06.txt | 4 +- runtime/doc/usr_40.txt | 4 +- runtime/doc/usr_41.txt | 12 +-- runtime/doc/various.txt | 6 +- runtime/doc/vim9.txt | 47 +++++++--- runtime/doc/windows.txt | 8 +- runtime/filetype.vim | 2 +- runtime/ftplugin/git.vim | 41 -------- runtime/ftplugin/gitcommit.vim | 47 ++++------ runtime/ftplugin/gitrebase.vim | 15 ++- .../dist/opt/termdebug/plugin/termdebug.vim | 10 +- runtime/syntax/git.vim | 93 ++++++++++++------- runtime/syntax/gitcommit.vim | 88 +++++++++++------- runtime/syntax/gitrebase.vim | 15 ++- runtime/syntax/i3config.vim | 5 +- 38 files changed, 342 insertions(+), 281 deletions(-) delete mode 100644 runtime/ftplugin/git.vim diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index c18df8a10b..786f9dee23 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -1,4 +1,4 @@ -*builtin.txt* For Vim version 8.2. Last change: 2021 Dec 28 +*builtin.txt* For Vim version 8.2. Last change: 2022 Jan 08 VIM REFERENCE MANUAL by Bram Moolenaar @@ -2435,7 +2435,7 @@ filter({expr1}, {expr2}) *filter()* For each item in {expr1} evaluate {expr2} and when the result is zero or false remove the item from the |List| or |Dictionary|. Similarly for each byte in a |Blob| and each - charactor in a |String|. + character in a |String|. {expr2} must be a |string| or |Funcref|. @@ -2466,7 +2466,9 @@ filter({expr1}, {expr2}) *filter()* return a:idx % 2 == 1 endfunc call filter(mylist, function('Odd')) -< It is shorter when using a |lambda|: > +< It is shorter when using a |lambda|. In |Vim9| syntax: > + call filter(myList, (idx, val) => idx * val <= 42) +< In legacy script syntax: > call filter(myList, {idx, val -> idx * val <= 42}) < If you do not use "val" you can leave it out: > call filter(myList, {idx -> idx % 2 == 1}) @@ -2744,8 +2746,10 @@ funcref({name} [, {arglist}] [, {dict}]) function {name} is redefined later. Unlike |function()|, {name} must be an existing user function. - Also for autoloaded functions. {name} cannot be a builtin - function. + It only works for an autoloaded function if it has already + been loaded (to avoid mistakenly loading the autoload script + when only intending to use the function name, use |function()| + instead). {name} cannot be a builtin function. Can also be used as a |method|: > GetFuncname()->funcref([arg]) @@ -4738,7 +4742,7 @@ js_encode({expr}) *js_encode()* Can also be used as a |method|: > GetObject()->js_encode() -json_decode({string}) *json_decode()* +json_decode({string}) *json_decode()* *E491* This parses a JSON formatted string and returns the equivalent in Vim values. See |json_encode()| for the relation between JSON and Vim values. @@ -5380,7 +5384,7 @@ match({expr}, {pat} [, {start} [, {count}]]) *match()* GetText()->match('word') GetList()->match('word') < - *matchadd()* *E798* *E799* *E801* *E957* + *matchadd()* *E290* *E798* *E799* *E801* *E957* matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]]) Defines a pattern to be highlighted in the current window (a "match"). It will be highlighted with {group}. Returns an @@ -8130,7 +8134,8 @@ sound_playfile({path} [, {callback}]) < Can also be used as a |method|: > GetSoundPath()->sound_playfile() -< {only available when compiled with the |+sound| feature} +< There is no error *E538* , but can listen to 538.nl. + {only available when compiled with the |+sound| feature} sound_stop({id}) *sound_stop()* diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt index 1d812207b8..c68c1619c3 100644 --- a/runtime/doc/cmdline.txt +++ b/runtime/doc/cmdline.txt @@ -1,4 +1,4 @@ -*cmdline.txt* For Vim version 8.2. Last change: 2021 Dec 26 +*cmdline.txt* For Vim version 8.2. Last change: 2022 Jan 08 VIM REFERENCE MANUAL by Bram Moolenaar @@ -748,7 +748,8 @@ Line numbers may be specified with: *:range* *{address}* Each may be followed (several times) by '+' or '-' and an optional number. This number is added or subtracted from the preceding line number. If the -number is omitted, 1 is used. +number is omitted, 1 is used. If there is nothing before the '+' or '-' then +the current line is used. The "/" and "?" after {pattern} are required to separate the pattern from anything that follows. @@ -778,7 +779,7 @@ Some commands allow for a count after the command. This count is used as the number of lines to be used, starting with the line given in the last line specifier (the default is the cursor line). The commands that accept a count are the ones that use a range but do not have a file name argument (because -a file name can also be a number). +a file name can also be a number). The count cannot be negative. Examples: > :s/x/X/g 5 substitute 'x' by 'X' in the current line and four @@ -949,6 +950,7 @@ Note: these are typed literally, they are not special keys! and "script {file-name}[{lnum}]" for a script line, and ".." in between items. E.g.: "function {function-name1}[{lnum}]..{function-name2}[{lnum}]" + If there is no call stack you get error *E489* . *:* ** When executing a ":source" command, is replaced with the line number. *E842* diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index d6161b11ac..ebb78b099a 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -1770,7 +1770,7 @@ There are three different types of searching: /u/user_x/work/include /u/user_x/include -< Note: If your 'path' setting includes an non-existing directory, Vim will +< Note: If your 'path' setting includes a non-existing directory, Vim will skip the non-existing directory, but continues searching in the parent of the non-existing directory if upwards searching is used. E.g. when searching "../include" and that doesn't exist, and upward searching is diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index dca886e85c..974f231ca8 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 8.2. Last change: 2021 Dec 28 +*eval.txt* For Vim version 8.2. Last change: 2022 Jan 08 VIM REFERENCE MANUAL by Bram Moolenaar @@ -13,9 +13,9 @@ done, the features in this document are not available. See |+eval| and |no-eval-feature|. This file is mainly about the backwards compatible (legacy) Vim script. For -specifics of Vim9 script, which executes much faster, supports type checking -and much more, see |vim9.txt|. Where the syntax or semantics differ a remark -is given. +specifics of Vim9 script, which can execute much faster, supports type +checking and much more, see |vim9.txt|. Where the syntax or semantics differ +a remark is given. 1. Variables |variables| 1.1 Variable types @@ -162,8 +162,8 @@ non-empty String, then the value is considered to be TRUE. Note that " " and "0" are also non-empty strings, thus considered to be TRUE. A List, Dictionary or Float is not a Number or String, thus evaluate to FALSE. - *E745* *E728* *E703* *E729* *E730* *E731* *E908* *E910* *E913* - *E974* *E975* *E976* + *E611* *E745* *E728* *E703* *E729* *E730* *E731* *E908* *E910* + *E913* *E974* *E975* *E976* |List|, |Dictionary|, |Funcref|, |Job|, |Channel| and |Blob| types are not automatically converted. @@ -172,7 +172,7 @@ When mixing Number and Float the Number is converted to Float. Otherwise there is no automatic conversion of Float. You can use str2float() for String to Float, printf() for Float to String and float2nr() for Float to Number. - *E891* *E892* *E893* *E894* *E907* *E911* *E914* + *E362* *E891* *E892* *E893* *E894* *E907* *E911* *E914* When expecting a Float a Number can also be used, but nothing else. *no-type-checking* @@ -1346,7 +1346,7 @@ When expr9 is a |Funcref| type variable, invoke the function it refers to. expr9->name([args]) method call *method* *->* expr9->{lambda}([args]) - *E276* + *E260* *E276* For methods that are also available as global functions this is the same as: > name(expr9 [, args]) There can also be methods specifically for the type of "expr9". @@ -1582,7 +1582,7 @@ See below |functions|. lambda expression *expr-lambda* *lambda* ----------------- -{args -> expr1} legacy lambda expression +{args -> expr1} legacy lambda expression *E451* (args) => expr1 |Vim9| lambda expression A lambda expression creates a new unnamed function which returns the result of @@ -1659,10 +1659,10 @@ See also: |numbered-function| 3. Internal variable *internal-variables* *E461* An internal variable name can be made up of letters, digits and '_'. But it -cannot start with a digit. In legacy script it also possible to use curly +cannot start with a digit. In legacy script it is also possible to use curly braces, see |curly-braces-names|. -In legacy script ann internal variable is created with the ":let" command +In legacy script an internal variable is created with the ":let" command |:let|. An internal variable is explicitly destroyed with the ":unlet" command |:unlet|. Using a name that is not an internal variable or refers to a variable that has @@ -2162,7 +2162,8 @@ v:lnum Line number for the 'foldexpr' |fold-expr|, 'formatexpr' and |sandbox|. *v:maxcol* *maxcol-variable* -v:maxcol Maximum line length. +v:maxcol Maximum line length. Depending on where it is used it can be + screen columns, characters or bytes. *v:mouse_win* *mouse_win-variable* v:mouse_win Window number for a mouse click obtained with |getchar()|. @@ -2573,7 +2574,7 @@ functions. In |Vim9| script functions are local to the script by default, prefix "g:" to define a global function. - *:fu* *:function* *E128* *E129* *E123* + *:fu* *:function* *E128* *E129* *E123* *E454* :fu[nction] List all functions and their arguments. :fu[nction] {name} List function {name}. @@ -2699,7 +2700,7 @@ See |:verbose-cmd| for more information. command, use line breaks instead of |:bar|: > :exe "func Foo()\necho 'foo'\nendfunc" < - *:delf* *:delfunction* *E130* *E131* *E933* + *:delf* *:delfunction* *E131* *E933* :delf[unction][!] {name} Delete function {name}. {name} can also be a |Dictionary| entry that is a @@ -4946,7 +4947,7 @@ When the |+eval| feature is available the command is skipped because of the silently ignored, and the command is executed. ============================================================================== -12. The sandbox *eval-sandbox* *sandbox* *E48* +12. The sandbox *eval-sandbox* *sandbox* The 'foldexpr', 'formatexpr', 'includeexpr', 'indentexpr', 'statusline' and 'foldtext' options may be evaluated in a sandbox. This means that you are @@ -4954,7 +4955,7 @@ protected from these expressions having nasty side effects. This gives some safety for when these options are set from a modeline. It is also used when the command from a tags file is executed and for CTRL-R = in the command line. The sandbox is also used for the |:sandbox| command. - + *E48* These items are not allowed in the sandbox: - changing the buffer text - defining or changing mapping, autocommands, user commands diff --git a/runtime/doc/helphelp.txt b/runtime/doc/helphelp.txt index 357a64e78a..d01b3daad6 100644 --- a/runtime/doc/helphelp.txt +++ b/runtime/doc/helphelp.txt @@ -1,4 +1,4 @@ -*helphelp.txt* For Vim version 8.2. Last change: 2021 Dec 13 +*helphelp.txt* For Vim version 8.2. Last change: 2022 Jan 08 VIM REFERENCE MANUAL by Bram Moolenaar @@ -224,7 +224,7 @@ command: > dialog. {only when compiled with |+GUI_GTK|} *:helpt* *:helptags* - *E154* *E150* *E151* *E152* *E153* *E670* + *E150* *E151* *E152* *E153* *E154* *E670* :helpt[ags] [++t] {dir} Generate the help tags file(s) for directory {dir}. When {dir} is ALL then all "doc" directories in diff --git a/runtime/doc/if_cscop.txt b/runtime/doc/if_cscop.txt index aa6512a944..ea84869abd 100644 --- a/runtime/doc/if_cscop.txt +++ b/runtime/doc/if_cscop.txt @@ -1,4 +1,4 @@ -*if_cscop.txt* For Vim version 8.2. Last change: 2019 May 05 +*if_cscop.txt* For Vim version 8.2. Last change: 2022 Jan 08 VIM REFERENCE MANUAL by Andy Kahn @@ -89,7 +89,7 @@ suggested use.) ============================================================================== 2. Cscope related commands *cscope-commands* - *:cscope* *:cs* *:scs* *:scscope* *E259* *E262* *E561* *E560* + *:cscope* *:cs* *:scs* *:scscope* *E259* *E262* *E560* *E561* All cscope commands are accessed through suboptions to the cscope commands. `:cscope` or `:cs` is the main command `:scscope` or `:scs` does the same and splits the window diff --git a/runtime/doc/if_perl.txt b/runtime/doc/if_perl.txt index b0bad1e6ad..a85b680053 100644 --- a/runtime/doc/if_perl.txt +++ b/runtime/doc/if_perl.txt @@ -1,4 +1,4 @@ -*if_perl.txt* For Vim version 8.2. Last change: 2019 Dec 07 +*if_perl.txt* For Vim version 8.2. Last change: 2022 Jan 08 VIM REFERENCE MANUAL by Sven Verdoolaege @@ -104,7 +104,6 @@ Here are some things you can try: > :perl VIM::Msg("hello") :perl $line = $curbuf->Get(42) < - *E299* Executing Perl commands in the |sandbox| is limited. ":perldo" will not be possible at all. ":perl" will be evaluated in the Safe environment, if possible. diff --git a/runtime/doc/if_tcl.txt b/runtime/doc/if_tcl.txt index 88ab1198ed..99301f362c 100644 --- a/runtime/doc/if_tcl.txt +++ b/runtime/doc/if_tcl.txt @@ -1,4 +1,4 @@ -*if_tcl.txt* For Vim version 8.2. Last change: 2021 May 27 +*if_tcl.txt* For Vim version 8.2. Last change: 2022 Jan 08 VIM REFERENCE MANUAL by Ingo Wilken @@ -16,9 +16,9 @@ The Tcl Interface to Vim *tcl* *Tcl* *TCL* 8. Examples |tcl-examples| 9. Dynamic loading |tcl-dynamic| -*E280* {only available when Vim was compiled with the |+tcl| feature} + *E280* WARNING: There are probably still some bugs. Please send bug reports, comments, ideas etc to diff --git a/runtime/doc/indent.txt b/runtime/doc/indent.txt index 87bbd488eb..d82f7423a3 100644 --- a/runtime/doc/indent.txt +++ b/runtime/doc/indent.txt @@ -879,7 +879,7 @@ For example, with N = 1, this will give: *PHP_outdentphpescape* To indent PHP escape tags as the surrounding non-PHP code (only affects the PHP escape tags): > -:let g:PHP_outdentphpescape = 0 + :let g:PHP_outdentphpescape = 0 ------------- *PHP_removeCRwhenUnix* @@ -1206,7 +1206,7 @@ comments will be indented according to the correctly indented code. VIM *ft-vim-indent* - + *g:vim_indent_cont* For indenting Vim scripts there is one variable that specifies the amount of indent for a continuation line, a line that starts with a backslash: > diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index 3751f279aa..acc7865755 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -850,7 +850,7 @@ space is preferred). Maximum line length is 510 bytes. For an example, imagine the 'thesaurus' file has a line like this: > angry furious mad enraged - :map @@ foo diff --git a/runtime/doc/mbyte.txt b/runtime/doc/mbyte.txt index 08c3ac1899..4747d482ea 100644 --- a/runtime/doc/mbyte.txt +++ b/runtime/doc/mbyte.txt @@ -1,4 +1,4 @@ -*mbyte.txt* For Vim version 8.2. Last change: 2021 Oct 04 +*mbyte.txt* For Vim version 8.2. Last change: 2022 Jan 08 VIM REFERENCE MANUAL by Bram Moolenaar et al. @@ -862,8 +862,8 @@ Use the RPM or port for your system. window specific to the input method. -USING XIM *multibyte-input* *E284* *E286* *E287* *E288* - *E285* *E289* +USING XIM *multibyte-input* *E284* *E285* *E286* *E287* + *E288* *E289* Note that Display and Input are independent. It is possible to see your language even though you have no input method for it. But when your Display diff --git a/runtime/doc/message.txt b/runtime/doc/message.txt index 1690e41e19..f174884bb0 100644 --- a/runtime/doc/message.txt +++ b/runtime/doc/message.txt @@ -1,4 +1,4 @@ -*message.txt* For Vim version 8.2. Last change: 2021 Dec 13 +*message.txt* For Vim version 8.2. Last change: 2022 Jan 08 VIM REFERENCE MANUAL by Bram Moolenaar @@ -118,7 +118,8 @@ wiped out a buffer which contains a mark or is referenced in another way. *E95* > Buffer with this name already exists -You cannot have two buffers with the same name. +You cannot have two buffers with exactly the same name. This includes the +path leading to the file. *E72* > Close error on swap file @@ -534,10 +535,10 @@ If you type "gq", it will execute this mapping, which will call "gq" again. *E22* > Scripts nested too deep -Scripts can be read with the "-s" command-line argument and with the ":source" -command. The script can then again read another script. This can continue -for about 14 levels. When more nesting is done, Vim assumes that there is a -recursive loop somewhere and stops with this error message. +Scripts can be read with the "-s" command-line argument and with the +`:source!` command. The script can then again read another script. This can +continue for about 14 levels. When more nesting is done, Vim assumes that +there is a recursive loop and stops with this error message. *E319* > Sorry, the command is not available in this version @@ -727,6 +728,7 @@ specified. Trailing characters An argument has been added to an Ex command that does not permit one. +Or the argument has invalid characters and has not been recognized. *E477* *E478* > No ! allowed diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 1967167b17..c7fbde64fd 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 8.2. Last change: 2021 Dec 26 +*options.txt* For Vim version 8.2. Last change: 2022 Jan 02 VIM REFERENCE MANUAL by Bram Moolenaar @@ -369,7 +369,7 @@ value to the local value, it doesn't switch back to using the global value This will make the local value of 'path' empty, so that the global value is used. Thus it does the same as: > :setlocal path= -Note: In the future more global options can be made global-local. Using +Note: In the future more global options can be made |global-local|. Using ":setlocal" on a global option might work differently then. @@ -877,11 +877,11 @@ A jump table for the options with a short description can be found at |Q_op|. global Write the contents of the file, if it has been modified, on each `:next`, `:rewind`, `:last`, `:first`, `:previous`, `:stop`, - `:suspend`, `:tag, `:!`, ``:make`, CTRL-] and CTRL-^ command; and when - a :buffer, CTRL-O, CTRL-I, '{A-Z0-9}, or `{A-Z0-9} command takes one + `:suspend`, `:tag`, `:!`, `:make`, CTRL-] and CTRL-^ command; and when + a `:buffer`, CTRL-O, CTRL-I, '{A-Z0-9}, or `{A-Z0-9} command takes one to another file. A buffer is not written if it becomes hidden, e.g. when 'bufhidden' is - set to "hide" and `:next` is used + set to "hide" and `:next` is used. Note that for some commands the 'autowrite' option is not used, see 'autowriteall' for that. Some buffers will not be written, specifically when 'buftype' is @@ -6684,6 +6684,8 @@ A jump table for the options with a short description can be found at |Q_op|. Don't include both "curdir" and "sesdir". When neither "curdir" nor "sesdir" is included, file names are stored with absolute paths. + If you leave out "options" many things won't work well after restoring + the session. "slash" and "unix" are useful on Windows when sharing session files with Unix. The Unix version of Vim cannot source dos format scripts, but the Windows version of Vim can source unix format scripts. @@ -8126,7 +8128,7 @@ A jump table for the options with a short description can be found at |Q_op|. another default. Backticks cannot be used in this option for security reasons. - *'thesaurusfunc'* *tsrfu'* + *'thesaurusfunc'* *'tsrfu'* 'thesaurusfunc' 'tsrfu' string (default: empty) global or local to buffer |global-local| {not available when compiled without the |+eval| diff --git a/runtime/doc/os_dos.txt b/runtime/doc/os_dos.txt index b473134ce1..b315be8a1b 100644 --- a/runtime/doc/os_dos.txt +++ b/runtime/doc/os_dos.txt @@ -342,12 +342,12 @@ PowerShell Execution Policy settings. See |option-backslash| about including spaces in 'shellcmdflag' when using multiple flags. -The 'shellpipe' and 'shellredir' option values re-encode the UTF-16le output +The 'shellpipe' and 'shellredir' option values re-encode the UTF-16LE output from PowerShell Desktop to your currently configured console codepage. The output can be forced into a different encoding by changing "default" to one of the following: - unicode - UTF-16le (default output from PowerShell 5.1) + unicode - UTF-16LE (default output from PowerShell 5.1) bigendianunicode - UTF-16 utf8 - UTF-8 utf7 - UTF-7 (no BOM) @@ -356,7 +356,7 @@ the following: default - System's active code page (typically ANSI) oem - System's current OEM code page -Note The abovce multi-byte Unicode encodings include a leading BOM unless +Note The above multi-byte Unicode encodings include a leading BOM unless otherwise indicated. By default PowerShell Core's output is UTF-8 encoded without a BOM. If you @@ -365,10 +365,10 @@ want to force the output of PowerShell Core into a different encoding then set encoding is one of the following: ascii - 7-bit ASCII character set - bigendianunicode - UTF-16be - bigendianutf32 - UTF-32be + bigendianunicode - UTF-16BE + bigendianutf32 - UTF-32BE oem - System's current OEM code page - unicode - UTF-16le + unicode - UTF-16LE utf7 - UTF-7 utf8 - UTF-8 utf8BOM - UTF-8, with BOM diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt index 8f6d77e414..ce1d0f49bc 100644 --- a/runtime/doc/pattern.txt +++ b/runtime/doc/pattern.txt @@ -1,4 +1,4 @@ -*pattern.txt* For Vim version 8.2. Last change: 2021 Jul 16 +*pattern.txt* For Vim version 8.2. Last change: 2022 Jan 08 VIM REFERENCE MANUAL by Bram Moolenaar @@ -315,7 +315,7 @@ the pattern. ============================================================================== 2. The definition of a pattern *search-pattern* *pattern* *[pattern]* *regular-expression* *regexp* *Pattern* - *E76* *E383* *E476* + *E383* *E476* For starters, read chapter 27 of the user manual |usr_27.txt|. @@ -929,9 +929,9 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on): \%23l Matches in a specific line. \%<23l Matches above a specific line (lower line number). \%>23l Matches below a specific line (higher line number). -\%.l Matches at the cursor line. -\%<.l Matches above the cursor line. -\%>.l Matches below the cursor line. +\%.l Matches at the cursor line. +\%<.l Matches above the cursor line. +\%>.l Matches below the cursor line. These six can be used to match specific lines in a buffer. The "23" can be any line number. The first line is 1. WARNING: When inserting or deleting lines Vim does not automatically @@ -950,9 +950,9 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on): \%23c Matches in a specific column. \%<23c Matches before a specific column. \%>23c Matches after a specific column. -\%.c Matches at the cursor column. -\%<.c Matches before the cursor column. -\%>.c Matches after the cursor column. +\%.c Matches at the cursor column. +\%<.c Matches before the cursor column. +\%>.c Matches after the cursor column. These six can be used to match specific columns in a buffer or string. The "23" can be any column number. The first column is 1. Actually, the column is the byte number (thus it's not exactly right for @@ -976,9 +976,9 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on): \%23v Matches in a specific virtual column. \%<23v Matches before a specific virtual column. \%>23v Matches after a specific virtual column. -\%.v Matches at the current virtual column. -\%<.v Matches before the current virtual column. -\%>.v Matches after the current virtual column. +\%.v Matches at the current virtual column. +\%<.v Matches before the current virtual column. +\%>.v Matches after the current virtual column. These six can be used to match specific virtual columns in a buffer or string. When not matching with a buffer in a window, the option values of the current window are used (e.g., 'tabstop'). @@ -1070,6 +1070,8 @@ match ASCII characters, as indicated by the range. \(\) A pattern enclosed by escaped parentheses. */\(* */\(\)* */\)* E.g., "\(^a\)" matches 'a' at the start of a line. + There can only be ten of these. You can use "\%(" to add more, but + not counting it as a sub-expression. *E51* *E54* *E55* *E872* *E873* \1 Matches the same string that was matched by */\1* *E65* @@ -1092,7 +1094,7 @@ x A single character, with no special meaning, matches itself \x A backslash followed by a single character, with no special meaning, is reserved for future expansions -[] (with 'nomagic': \[]) */[]* */\[]* */\_[]* */collection* +[] (with 'nomagic': \[]) */[]* */\[]* */\_[]* */collection* *E76* \_[] A collection. This is a sequence of characters enclosed in square brackets. It matches any single character in the collection. @@ -1488,5 +1490,4 @@ the matching positions and the fuzzy match scores. The "f" flag of `:vimgrep` enables fuzzy matching. - vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/popup.txt b/runtime/doc/popup.txt index b4d770245f..6645a7b2d9 100644 --- a/runtime/doc/popup.txt +++ b/runtime/doc/popup.txt @@ -1,4 +1,4 @@ -*popup.txt* For Vim version 8.2. Last change: 2021 Nov 29 +*popup.txt* For Vim version 8.2. Last change: 2022 Jan 08 VIM REFERENCE MANUAL by Bram Moolenaar @@ -54,7 +54,7 @@ A popup window has a window-ID like other windows, but behaves differently. The size can be up to the whole Vim window and it overlaps other windows. Popup windows can also overlap each other. The "zindex" property specifies what goes on top of what. - + *E366* The popup window contains a buffer, and that buffer is always associated with the popup window. The window cannot be in Normal, Visual or Insert mode, it does not get keyboard focus. You can use functions like `setbufline()` to @@ -262,7 +262,7 @@ popup_close({id} [, {result}]) *popup_close()* popup_create({what}, {options}) *popup_create()* - Open a popup window showing {what}, which is either: + Open a popup window showing {what}, which is either: *E450* - a buffer number - a string - a list of strings diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt index 47ead217f9..b7a01bdfd7 100644 --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -1,4 +1,4 @@ -*quickfix.txt* For Vim version 8.2. Last change: 2021 Dec 03 +*quickfix.txt* For Vim version 8.2. Last change: 2022 Jan 04 VIM REFERENCE MANUAL by Bram Moolenaar @@ -244,7 +244,7 @@ processing a quickfix or location list command, it will be aborted. [!] is not used. It works like ":qall!" |:qall|, except that Vim returns a non-zero exit code. - *:cf* *:cfile* + *:cf* *:cfi* *:cfile* :cf[ile][!] [errorfile] Read the error file and jump to the first error. This is done automatically when Vim is started with the -q option. You can use this command when you diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index d4e8cf818f..edd3fa8fd7 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1,4 +1,4 @@ -*starting.txt* For Vim version 8.2. Last change: 2021 May 08 +*starting.txt* For Vim version 8.2. Last change: 2022 Jan 03 VIM REFERENCE MANUAL by Bram Moolenaar @@ -560,6 +560,8 @@ a slash. Thus "-R" means recovery and "-/R" readonly. ":source!". When the "scriptout" file already exists, new characters are appended. See also |complex-repeat|. {scriptout} cannot start with a digit. + If you want to record what is typed in a human readable for + you can use |ch_logfile()|, It adds "raw key input" lines. *-W* -W {scriptout} Like -w, but do not append, overwrite an existing file. diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 35a4e3ad7a..737e0636c6 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1442,7 +1442,7 @@ add the following line to your startup file: > :let g:filetype_euphoria = "euphoria4" -Elixir and Euphoria share the *.ex file extension. If the filetype is +Elixir and Euphoria share the *.ex file extension. If the filetype is specifically set as Euphoria with the g:filetype_euphoria variable, or the file is determined to be Euphoria based on keywords in the file, then the filetype will be set as Euphoria. Otherwise, the filetype will default to @@ -1473,7 +1473,7 @@ The following file extensions are auto-detected as Elixir file types: *.ex, *.exs, *.eex, *.leex, *.lock -Elixir and Euphoria share the *.ex file extension. If the filetype is +Elixir and Euphoria share the *.ex file extension. If the filetype is specifically set as Euphoria with the g:filetype_euphoria variable, or the file is determined to be Euphoria based on keywords in the file, then the filetype will be set as Euphoria. Otherwise, the filetype will default to diff --git a/runtime/doc/tags b/runtime/doc/tags index b52e52644e..78e88f3032 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -1162,6 +1162,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX* 'ts' options.txt /*'ts'* 'tsl' options.txt /*'tsl'* 'tsr' options.txt /*'tsr'* +'tsrfu' options.txt /*'tsrfu'* 'ttimeout' options.txt /*'ttimeout'* 'ttimeoutlen' options.txt /*'ttimeoutlen'* 'ttm' options.txt /*'ttm'* @@ -1418,6 +1419,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX* +user_commands various.txt /*+user_commands* +vartabs various.txt /*+vartabs* +vertsplit various.txt /*+vertsplit* ++vim9script various.txt /*+vim9script* +viminfo various.txt /*+viminfo* +virtualedit various.txt /*+virtualedit* +visual various.txt /*+visual* @@ -2244,6 +2246,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX* :cexpr quickfix.txt /*:cexpr* :cf quickfix.txt /*:cf* :cfdo quickfix.txt /*:cfdo* +:cfi quickfix.txt /*:cfi* :cfile quickfix.txt /*:cfile* :cfir quickfix.txt /*:cfir* :cfirst quickfix.txt /*:cfirst* @@ -4013,7 +4016,6 @@ E127 eval.txt /*E127* E128 eval.txt /*E128* E129 eval.txt /*E129* E13 message.txt /*E13* -E130 eval.txt /*E130* E131 eval.txt /*E131* E132 eval.txt /*E132* E133 eval.txt /*E133* @@ -4153,6 +4155,7 @@ E257 if_cscop.txt /*E257* E258 remote.txt /*E258* E259 if_cscop.txt /*E259* E26 rileft.txt /*E26* +E260 eval.txt /*E260* E261 if_cscop.txt /*E261* E262 if_cscop.txt /*E262* E263 if_pyth.txt /*E263* @@ -4183,6 +4186,7 @@ E287 mbyte.txt /*E287* E288 mbyte.txt /*E288* E289 mbyte.txt /*E289* E29 change.txt /*E29* +E290 builtin.txt /*E290* E292 message.txt /*E292* E293 message.txt /*E293* E294 message.txt /*E294* @@ -4190,7 +4194,6 @@ E295 message.txt /*E295* E296 message.txt /*E296* E297 message.txt /*E297* E298 message.txt /*E298* -E299 if_perl.txt /*E299* E30 change.txt /*E30* E300 message.txt /*E300* E301 message.txt /*E301* @@ -4258,9 +4261,11 @@ E358 options.txt /*E358* E359 term.txt /*E359* E36 windows.txt /*E36* E360 various.txt /*E360* +E362 eval.txt /*E362* E363 options.txt /*E363* E364 builtin.txt /*E364* E365 print.txt /*E365* +E366 popup.txt /*E366* E367 autocmd.txt /*E367* E368 builtin.txt /*E368* E369 pattern.txt /*E369* @@ -4352,8 +4357,11 @@ E447 editing.txt /*E447* E448 various.txt /*E448* E449 builtin.txt /*E449* E45 message.txt /*E45* +E450 popup.txt /*E450* +E451 eval.txt /*E451* E452 eval.txt /*E452* E453 syntax.txt /*E453* +E454 eval.txt /*E454* E455 print.txt /*E455* E456 print.txt /*E456* E457 print.txt /*E457* @@ -4391,8 +4399,10 @@ E485 message.txt /*E485* E486 pattern.txt /*E486* E487 options.txt /*E487* E488 message.txt /*E488* +E489 cmdline.txt /*E489* E49 message.txt /*E49* E490 fold.txt /*E490* +E491 builtin.txt /*E491* E492 message.txt /*E492* E493 cmdline.txt /*E493* E494 editing.txt /*E494* @@ -4443,6 +4453,7 @@ E534 options.txt /*E534* E535 options.txt /*E535* E536 options.txt /*E536* E537 options.txt /*E537* +E538 builtin.txt /*E538* E539 options.txt /*E539* E54 pattern.txt /*E54* E540 options.txt /*E540* @@ -4518,6 +4529,7 @@ E608 eval.txt /*E608* E609 if_cscop.txt /*E609* E61 pattern.txt /*E61* E610 editing.txt /*E610* +E611 eval.txt /*E611* E612 sign.txt /*E612* E613 print.txt /*E613* E614 editing.txt /*E614* @@ -7010,6 +7022,7 @@ g:tex_subscripts syntax.txt /*g:tex_subscripts* g:tex_superscripts syntax.txt /*g:tex_superscripts* g:tex_verbspell syntax.txt /*g:tex_verbspell* g:var eval.txt /*g:var* +g:vim_indent_cont indent.txt /*g:vim_indent_cont* g:vimball_home pi_vimball.txt /*g:vimball_home* g:vimball_mkdir pi_vimball.txt /*g:vimball_mkdir* g:vimsyn_embed syntax.txt /*g:vimsyn_embed* @@ -7937,6 +7950,7 @@ matchstrpos() builtin.txt /*matchstrpos()* matlab-indent indent.txt /*matlab-indent* matlab-indenting indent.txt /*matlab-indenting* max() builtin.txt /*max()* +maxcol-variable eval.txt /*maxcol-variable* mbyte-IME mbyte.txt /*mbyte-IME* mbyte-XIM mbyte.txt /*mbyte-XIM* mbyte-combining mbyte.txt /*mbyte-combining* @@ -9870,7 +9884,6 @@ try-echoerr eval.txt /*try-echoerr* try-finally eval.txt /*try-finally* try-nested eval.txt /*try-nested* try-nesting eval.txt /*try-nesting* -tsrfu' options.txt /*tsrfu'* tutor usr_01.txt /*tutor* twice if_cscop.txt /*twice* two-engines pattern.txt /*two-engines* @@ -10005,6 +10018,7 @@ v:key eval.txt /*v:key* v:lang eval.txt /*v:lang* v:lc_time eval.txt /*v:lc_time* v:lnum eval.txt /*v:lnum* +v:maxcol eval.txt /*v:maxcol* v:mouse_col eval.txt /*v:mouse_col* v:mouse_lnum eval.txt /*v:mouse_lnum* v:mouse_win eval.txt /*v:mouse_win* diff --git a/runtime/doc/terminal.txt b/runtime/doc/terminal.txt index ca28f1f330..8e751d1f8b 100644 --- a/runtime/doc/terminal.txt +++ b/runtime/doc/terminal.txt @@ -39,6 +39,7 @@ If the result is "1" you have it. Stepping through code |termdebug-stepping| Inspecting variables |termdebug-variables| Other commands |termdebug-commands| + Events |termdebug-events| Prompt mode |termdebug-prompt| Communication |termdebug-communication| Customizing |termdebug-customizing| diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt index 5b227e38e2..b18effdccd 100644 --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1,4 +1,4 @@ -*todo.txt* For Vim version 8.2. Last change: 2021 Dec 30 +*todo.txt* For Vim version 8.2. Last change: 2022 Jan 08 VIM REFERENCE MANUAL by Bram Moolenaar @@ -38,15 +38,27 @@ browser use: https://github.com/vim/vim/issues/1234 *known-bugs* -------------------- Known bugs and current work ----------------------- +Autoload import syntax: + import autoload "filename" + import autoload "filename" as name +doesn't load the script yet + autoload items can be used without the "#dir#file#" prefix, but file.item + Add a test_override() item to load the script and compile functions the + moment it is encountered, so that types are checked. +"vim9script autoload" in an autoload script, using "export" will prefix + "dir#file#" to the exported item. + Once Vim9 is stable: -- Add the "vim9script" feature, can use has('vim9script') - Remove TODO in vim9.txt - Add all the error numbers in a good place in documentation. + done until E653 - Use Vim9 for runtime files. Further Vim9 improvements, possibly after launch: - Check performance with callgrind and kcachegrind. -- better implementation for partial and tests for that. +- Better implementation for partial and tests for that. +- when using "const" mark the variable type as const with TTFLAG_CONST, so + that an error is given at compile time when trying to change it. E.g. for a + const list and trying to call add(). - Compile options that are an expression, e.g. "expr:" in 'spellsuggest', 'foldexpr', 'foldtext', 'printexpr', 'diffexpr', 'patchexpr', 'charconvert', 'balloonexpr', 'includeexpr', 'indentexpr', 'formatexpr'. diff --git a/runtime/doc/usr_06.txt b/runtime/doc/usr_06.txt index aefe45b937..5e52209a96 100644 --- a/runtime/doc/usr_06.txt +++ b/runtime/doc/usr_06.txt @@ -189,7 +189,7 @@ You can specify #rrggbb hex colors and you can define new names for hex colors in |v:colornames| like so: > let v:colornames['mine_red'] = '#aa0000' -< + If you are authoring a color scheme for others to use, it is important to define these colors only when they do not exist: > @@ -197,7 +197,7 @@ to define these colors only when they do not exist: > This allows users of the color scheme to override the precise definition of that color prior to loading your color scheme. For example, in a |.vimrc| -file: +file: > runtime colors/lists/css_colors.vim let v:colornames['your_red'] = v:colornames['css_red'] diff --git a/runtime/doc/usr_40.txt b/runtime/doc/usr_40.txt index 21c09b43f8..9ed777f1eb 100644 --- a/runtime/doc/usr_40.txt +++ b/runtime/doc/usr_40.txt @@ -1,4 +1,4 @@ -*usr_40.txt* For Vim version 8.2. Last change: 2020 Sep 02 +*usr_40.txt* For Vim version 8.2. Last change: 2022 Jan 03 VIM USER MANUAL - by Bram Moolenaar @@ -20,7 +20,7 @@ Table of contents: |usr_toc.txt| ============================================================================== *40.1* Key mapping -A simple mapping was explained in section |05.3|. The principle is that one +A simple mapping was explained in section |05.4|. The principle is that one sequence of key strokes is translated into another sequence of key strokes. This is a simple, yet powerful mechanism. The simplest form is that one key is mapped to a sequence of keys. Since diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index a9abe59be1..1ef4f26b2c 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -1,4 +1,4 @@ -*usr_41.txt* For Vim version 8.2. Last change: 2021 Dec 30 +*usr_41.txt* For Vim version 8.2. Last change: 2022 Jan 01 VIM USER MANUAL - by Bram Moolenaar @@ -277,7 +277,7 @@ Example: > var name = "Peter" echo name -< peter ~ +< Peter ~ Every variable has a type. Very often, as in this example, the type is defined by assigning a value. This is called type inference. If you do not @@ -538,16 +538,16 @@ between the `while` and the `endwhile`: Example: > + var counter = 1 while counter < 40 - do_something() - if skip_flag + if skip_number(counter) continue endif - if finished_flag + if last_number(counter) break endif sleep 50m - --counter + ++counter endwhile The `sleep` command makes Vim take a nap. The "50m" specifies fifty diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index da44546b0f..a3feeb0213 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -1,4 +1,4 @@ -*various.txt* For Vim version 8.2. Last change: 2021 Dec 20 +*various.txt* For Vim version 8.2. Last change: 2022 Jan 08 VIM REFERENCE MANUAL by Bram Moolenaar @@ -244,10 +244,10 @@ g8 Print the hex values of the bytes used in the compiler will have set stdin to a non-interactive mode. - *:!cmd* *:!* *E34* + *:!cmd* *:!* :!{cmd} Execute {cmd} with the shell. See also the 'shell' and 'shelltype' option. - + *E34* Any '!' in {cmd} is replaced with the previous external command (see also 'cpoptions'). But not when there is a backslash before the '!', then that diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt index 5d3e5b1bb0..0af6dff33d 100644 --- a/runtime/doc/vim9.txt +++ b/runtime/doc/vim9.txt @@ -1,4 +1,4 @@ -*vim9.txt* For Vim version 8.2. Last change: 2021 Dec 27 +*vim9.txt* For Vim version 8.2. Last change: 2022 Jan 07 VIM REFERENCE MANUAL by Bram Moolenaar @@ -120,7 +120,7 @@ is the same as in shell scripts and Python programs. In Vi # is a command to list text with numbers. In Vim9 script you can use `:number` for that. > - 101 number + :101 number To improve readability there must be a space between a command and the # that starts a comment: > @@ -1358,8 +1358,14 @@ Same for |extend()|, use |extendnew()| instead, and for |flatten()|, use *vim9script* *vim9-export* *vim9-import* A Vim9 script can be written to be imported. This means that everything in -the script is local, unless exported. Those exported items, and only those -items, can then be imported in another script. +the script is local, except for items that are exported. Those exported +items, and only those items, can then be imported in another script. + +This mechanism exists for writing a script that can be sourced (imported) by +other scripts, while making sure these other scripts only have access to what +you want them to. This also avoids using the global namespace, which has a +risc of name collisions. For example when you have two plugins with similar +functionality. You can cheat by using the global namespace explicitly. We will assume here that you don't do that. @@ -1438,21 +1444,23 @@ The exported items can be imported in another Vim9 script: > This makes each item available as "myscript.item". In case the name is long or ambiguous, another name can be specified: > - import "thatscript.vim" as That + import "thatscript.vim" as that -Then you can use "That.EXPORTED_CONST", "That.someValue", etc. You are free -to choose the name "That". Use something that will be recognized as referring -to the imported script. Avoid command names, because the name will shadow -them. +Then you can use "that.EXPORTED_CONST", "that.someValue", etc. You are free +to choose the name "that". Use something that will be recognized as referring +to the imported script. Avoid command names and builtin function names, +because the name will shadow them. -In case the dot in the name is unwanted, a local reference can be made: > - var ThatFunc = That.LongFuncName +In case the dot in the name is undesired, a local reference can be made for a +function: > + var LongFunc = that.LongFuncName This also works for constants: > - cost MAXLEN = That.MAX_LEN_OF_NAME + const MAXLEN = that.MAX_LEN_OF_NAME -This does not work for variables, you could use a setter function and make a -local reference for it. +This does not work for variables, since the value would be copied once and +when changing the variable the copy will change, not the original variable. +You will need to use the full name, with the dot. `:import` can also be used in legacy Vim script. The imported items still become script-local, even when the "s:" prefix is not given. @@ -1471,12 +1479,21 @@ The script name after `import` can be: longer and unique, to avoid loading the wrong file. Note that "after/import" is not used. +If the name does not end in ".vim" then the use of "as name" is required. + Once a vim9 script file has been imported, the result is cached and used the next time the same script is imported. It will not be read again. It is not allowed to import the same script twice, also when using two different "as" names. - *:import-cycle* + +When using the imported name the dot and the item name must be in the same +line, there can be no line break: > + echo that. + name # Error! + echo that + .name # Error! +< *:import-cycle* The `import` commands are executed when encountered. If that script (directly or indirectly) imports the current script, then items defined after the `import` won't be processed yet. Therefore cyclic imports can exist, but may diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt index 2f608352db..79d00a70b2 100644 --- a/runtime/doc/windows.txt +++ b/runtime/doc/windows.txt @@ -1,4 +1,4 @@ -*windows.txt* For Vim version 8.2. Last change: 2021 Nov 29 +*windows.txt* For Vim version 8.2. Last change: 2022 Jan 08 VIM REFERENCE MANUAL by Bram Moolenaar @@ -146,7 +146,7 @@ highlight group (|hl-EndOfBuffer|) can be used to change the highlighting of the filler characters. ============================================================================== -3. Opening and closing a window *opening-window* *E36* +3. Opening and closing a window *opening-window* CTRL-W s *CTRL-W_s* CTRL-W S *CTRL-W_S* @@ -246,6 +246,10 @@ CTRL-W : Does the same as typing |:| - enter a command line. Useful in a Note that the 'splitbelow' and 'splitright' options influence where a new window will appear. + *E36* +Creating a window will fail if there is not enough room. Every window needs +at least one screen line and column, sometimes more. Options 'winminheight' +and 'winminwidth' are relevant. *:vert* *:vertical* :vert[ical] {cmd} diff --git a/runtime/filetype.vim b/runtime/filetype.vim index f6ba012f37..09abccf7da 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar -" Last Change: 2021 Dec 27 +" Last Change: 2022 Jan 05 " Listen very carefully, I will say this only once if exists("did_load_filetypes") diff --git a/runtime/ftplugin/git.vim b/runtime/ftplugin/git.vim deleted file mode 100644 index 75b20f021e..0000000000 --- a/runtime/ftplugin/git.vim +++ /dev/null @@ -1,41 +0,0 @@ -" Vim filetype plugin -" Language: generic git output -" Maintainer: Tim Pope -" Last Change: 2019 Dec 05 - -" Only do this when not done yet for this buffer -if (exists("b:did_ftplugin")) - finish -endif -let b:did_ftplugin = 1 - -if !exists('b:git_dir') - if expand('%:p') =~# '[\/]\.git[\/]modules[\/]\|:[\/][\/]\|^\a\a\+:' - " Stay out of the way - elseif expand('%:p') =~# '[\/]\.git[\/]worktrees' - let b:git_dir = matchstr(expand('%:p'),'.*\.git[\/]worktrees[\/][^\/]\+\>') - elseif expand('%:p') =~# '\.git\>' - let b:git_dir = matchstr(expand('%:p'),'.*\.git\>') - elseif $GIT_DIR != '' - let b:git_dir = $GIT_DIR - endif - if (has('win32') || has('win64')) && exists('b:git_dir') - let b:git_dir = substitute(b:git_dir,'\\','/','g') - endif -endif - -if exists('*shellescape') && exists('b:git_dir') && b:git_dir != '' - if b:git_dir =~# '/\.git$' " Not a bare repository - let &l:path = escape(fnamemodify(b:git_dir,':h'),'\, ').','.&l:path - endif - let &l:path = escape(b:git_dir,'\, ').','.&l:path - let &l:keywordprg = 'git --git-dir='.shellescape(b:git_dir).' show' -else - setlocal keywordprg=git\ show -endif -if has('gui_running') - let &l:keywordprg = substitute(&l:keywordprg,'^git\>','git --no-pager','') -endif - -setlocal includeexpr=substitute(v:fname,'^[^/]\\+/','','') -let b:undo_ftplugin = "setl keywordprg< path< includeexpr<" diff --git a/runtime/ftplugin/gitcommit.vim b/runtime/ftplugin/gitcommit.vim index 9b1998acaa..9342799b56 100644 --- a/runtime/ftplugin/gitcommit.vim +++ b/runtime/ftplugin/gitcommit.vim @@ -1,66 +1,57 @@ " Vim filetype plugin " Language: git commit file " Maintainer: Tim Pope -" Last Change: 2019 Dec 05 +" Last Change: 2022 Jan 05 " Only do this when not done yet for this buffer if (exists("b:did_ftplugin")) finish endif -runtime! ftplugin/git.vim let b:did_ftplugin = 1 -setlocal comments=:# commentstring=#\ %s setlocal nomodeline tabstop=8 formatoptions+=tl textwidth=72 setlocal formatoptions-=c formatoptions-=r formatoptions-=o formatoptions-=q formatoptions+=n setlocal formatlistpat+=\\\|^\\s*[-*+]\\s\\+ +setlocal include=^+++ +setlocal includeexpr=substitute(v:fname,'^[bi]/','','') -let b:undo_ftplugin = 'setl modeline< tabstop< formatoptions< tw< com< cms< formatlistpat<' +let b:undo_ftplugin = 'setl modeline< tabstop< formatoptions< tw< com< cms< formatlistpat< inc< inex<' -if exists("g:no_gitcommit_commands") || v:version < 700 +let s:l = search('\C\m^[#;@!$%^&|:] -\{24,\} >8 -\{24,\}$', 'cnW', '', 100) +let &l:comments = ':' . (matchstr(getline(s:l ? s:l : '$'), '^[#;@!$%^&|:]\S\@!') . '#')[0] +let &l:commentstring = &l:comments[1] . ' %s' +unlet s:l + +if exists("g:no_gitcommit_commands") finish endif -if !exists("b:git_dir") - let b:git_dir = expand("%:p:h") -endif - -command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(0,b:git_dir,) +command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(0, ) let b:undo_ftplugin = b:undo_ftplugin . "|delc DiffGitCached" -function! s:diffcomplete(A,L,P) +function! s:diffcomplete(A, L, P) abort let args = "" if a:P <= match(a:L." -- "," -- ")+3 let args = args . "-p\n--stat\n--shortstat\n--summary\n--patch-with-stat\n--no-renames\n-B\n-M\n-C\n" end - if exists("b:git_dir") && a:A !~ '^-' - let tree = fnamemodify(b:git_dir,':h') - if strpart(getcwd(),0,strlen(tree)) == tree - let args = args."\n".system("git diff --cached --name-only") - endif + if a:A !~ '^-' && !empty(getftype('.git')) + let args = args."\n".system("git diff --cached --name-only") endif return args endfunction -function! s:gitdiffcached(bang,gitdir,...) - let tree = fnamemodify(a:gitdir,':h') +function! s:gitdiffcached(bang, ...) abort let name = tempname() - let git = "git" - if strpart(getcwd(),0,strlen(tree)) != tree - let git .= " --git-dir=".(exists("*shellescape") ? shellescape(a:gitdir) : '"'.a:gitdir.'"') - endif if a:0 - let extra = join(map(copy(a:000),exists("*shellescape") ? 'shellescape(v:val)' : "'\"'.v:val.'\"'")) + let extra = join(map(copy(a:000), 'shellescape(v:val)')) else let extra = "-p --stat=".&columns endif - call system(git." diff --cached --no-color --no-ext-diff ".extra." > ".(exists("*shellescape") ? shellescape(name) : name)) - exe "pedit ".(exists("*fnameescape") ? fnameescape(name) : name) + call system("git diff --cached --no-color --no-ext-diff ".extra." > ".shellescape(name)) + exe "pedit " . fnameescape(name) wincmd P - let b:git_dir = a:gitdir - command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(0,b:git_dir,) - nnoremap q :q + command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(0, ) setlocal buftype=nowrite nobuflisted noswapfile nomodifiable filetype=git endfunction diff --git a/runtime/ftplugin/gitrebase.vim b/runtime/ftplugin/gitrebase.vim index 2fed53c829..143f86a251 100644 --- a/runtime/ftplugin/gitrebase.vim +++ b/runtime/ftplugin/gitrebase.vim @@ -1,22 +1,20 @@ " Vim filetype plugin " Language: git rebase --interactive " Maintainer: Tim Pope -" Last Change: 2019 Dec 05 +" Last Change: 2022 Jan 05 " Only do this when not done yet for this buffer if (exists("b:did_ftplugin")) finish endif -runtime! ftplugin/git.vim let b:did_ftplugin = 1 -setlocal comments=:# commentstring=#\ %s formatoptions-=t +let &l:comments = ':' . (matchstr(getline('$'), '^[#;@!$%^&|:]\S\@!') . '#')[0] +let &l:commentstring = &l:comments[1] . ' %s' +setlocal formatoptions-=t setlocal nomodeline -if !exists("b:undo_ftplugin") - let b:undo_ftplugin = "" -endif -let b:undo_ftplugin = b:undo_ftplugin."|setl com< cms< fo< ml<" +let b:undo_ftplugin = "setl com< cms< fo< ml<" function! s:choose(word) abort s/^\(\w\+\>\)\=\(\s*\)\ze\x\{4,40\}\>/\=(strlen(submatch(1)) == 1 ? a:word[0] : a:word) . substitute(submatch(2),'^$',' ','')/e @@ -41,8 +39,7 @@ if exists("g:no_plugin_maps") || exists("g:no_gitrebase_maps") finish endif -nnoremap K col('.') < 7 && expand('cword>') =~ '\X' && getline('.') =~ '^\w\+\s\+\x\+\>' ? 'wK' : 'K' nnoremap :=v:count1Cycle nnoremap :=v:count1Cycle! -let b:undo_ftplugin = b:undo_ftplugin . "|exe 'nunmap K'|exe 'nunmap '|exe 'nunmap '" +let b:undo_ftplugin = b:undo_ftplugin . "|exe 'nunmap '|exe 'nunmap '" diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 76836d6c29..d288af1797 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -147,7 +147,7 @@ func s:StartDebug_internal(dict) if &columns < g:termdebug_wide let s:save_columns = &columns let &columns = g:termdebug_wide - " If we make the Vim window wider, use the whole left halve for the debug + " If we make the Vim window wider, use the whole left half for the debug " windows. let s:allleft = 1 endif @@ -426,7 +426,7 @@ func s:StartDebug_prompt(dict) call s:SendCommand('set env COLORS = ' . &t_Co) call s:SendCommand('set env VIM_TERMINAL = ' . v:version) else - " TODO: open a new terminal get get the tty name, pass on to gdb + " TODO: open a new terminal, get the tty name, pass on to gdb call s:SendCommand('show inferior-tty') endif call s:SendCommand('set print pretty on') @@ -1067,10 +1067,10 @@ func s:GetEvaluationExpression(range, arg) return expr endfunc -" clean up expression that may got in because of range +" clean up expression that may get in because of range " (newlines and surrounding whitespace) " As it can also be specified via ex-command for assignments this function -" may not change the "content" parts (like replacing contained spaces +" may not change the "content" parts (like replacing contained spaces) func s:CleanupExpr(expr) " replace all embedded newlines/tabs/... let expr = substitute(a:expr, '\_s', ' ', 'g') @@ -1099,7 +1099,7 @@ func s:HandleEvaluate(msg) \ ->substitute('.*value="\(.*\)"', '\1', '') \ ->substitute('\\"', '"', 'g') \ ->substitute('\\\\', '\\', 'g') - "\ multi-byte characters arrive in octal form, replace everthing but NULL values + "\ multi-byte characters arrive in octal form, replace everything but NULL values \ ->substitute('\\000', s:NullRepl, 'g') \ ->substitute('\\\o\o\o', {-> eval('"' .. submatch(0) .. '"')}, 'g') "\ Note: GDB docs also mention hex encodings - the translations below work diff --git a/runtime/syntax/git.vim b/runtime/syntax/git.vim index a8467edd43..bf013ce195 100644 --- a/runtime/syntax/git.vim +++ b/runtime/syntax/git.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: generic git output " Maintainer: Tim Pope -" Last Change: 2019 Dec 05 +" Last Change: 2022 Jan 05 if exists("b:current_syntax") finish @@ -12,12 +12,28 @@ syn sync minlines=50 syn include @gitDiff syntax/diff.vim -syn region gitHead start=/\%^/ end=/^$/ -syn region gitHead start=/\%(^commit\%( \x\{40\}\)\{1,\}\%(\s*(.*)\)\=$\)\@=/ end=/^$/ - -" For git reflog and git show ...^{tree}, avoid sync issues -syn match gitHead /^\d\{6\} \%(\w\{4} \)\=\x\{40\}\%( [0-3]\)\=\t.*/ -syn match gitHead /^\x\{40\} \x\{40}\t.*/ +syn region gitHead start=/\%^\%(tag \|tree \|object \)\@=/ end=/^$/ contains=@NoSpell +syn region gitHead start=/\%(^commit\%( \x\{4,\}\)\{1,\}\%(\s*(.*)\)\=$\)\@=/ end=/^$/ contains=@NoSpell +" git log --oneline +" minimize false positives by verifying contents of buffer +if getline(1) =~# '^\x\{7,\} ' && getline('$') =~# '^\x\{7,\} ' + syn match gitHashAbbrev /^\x\{7,\} \@=/ contains=@NoSpell +elseif getline(1) =~# '^[|\/\\_ ]\{-\}\*[|\/\\_ ]\{-\} \x\{7,\} ' + syn match gitHashAbbrev /^[|\/\\_ ]\{-\}\*[|\/\\_ ]\{-\} \zs\x\{7,\} \@=/ contains=@NoSpell +endif +" git log --graph +syn region gitGraph start=/\%(^[|\/\\_ ]*\*[|\/\\_ ]\{-\} commit\%( \x\{4,\}\)\{1,\}\%(\s*(.*)\)\=$\)\@=/ end=/^\%([|\/\\_ ]*$\)\@=/ contains=@NoSpell +" git blame --porcelain +syn region gitHead start=/\%(^\x\{40,\} \d\+ \d\+\%( \d\+\)\=$\)\@=/ end=/^\t\@=/ contains=@NoSpell +" git ls-tree +syn match gitMode /^\d\{6\}\%( \%(blob\|tree\) \x\{4,\}\t\)\@=/ nextgroup=gitType skipwhite contains=@NoSpell +" git ls-files --stage +syn match gitMode /^\d\{6\}\%( \x\{4,\} [0-3]\t\)\@=/ nextgroup=gitHashStage skipwhite contains=@NoSpell +" .git/HEAD, .git/refs/ +syn match gitKeyword /\%^ref: \@=/ nextgroup=gitReference skipwhite contains=@NoSpell +syn match gitHash /\%^\x\{40,}\%$/ skipwhite contains=@NoSpell +" .git/logs/ +syn match gitReflog /^\x\{40,\} \x\{40,\} .\{-\}\d\+\s-\d\{4\}\t.*/ skipwhite contains=@NoSpell,gitReflogOld syn region gitDiff start=/^\%(diff --git \)\@=/ end=/^\%(diff --\|$\)\@=/ contains=@gitDiff fold syn region gitDiff start=/^\%(@@ -\)\@=/ end=/^\%(diff --\%(git\|cc\|combined\) \|$\)\@=/ contains=@gitDiff @@ -25,35 +41,47 @@ syn region gitDiff start=/^\%(@@ -\)\@=/ end=/^\%(diff --\%(git\|cc\|combined\) syn region gitDiffMerge start=/^\%(diff --\%(cc\|combined\) \)\@=/ end=/^\%(diff --\|$\)\@=/ contains=@gitDiff syn region gitDiffMerge start=/^\%(@@@@* -\)\@=/ end=/^\%(diff --\|$\)\@=/ contains=@gitDiff syn match gitDiffAdded "^ \++.*" contained containedin=gitDiffMerge -syn match gitDiffAdded "{+.*+}" contained containedin=gitDiff +syn match gitDiffAdded "{+[^}]*+}" contained containedin=gitDiff syn match gitDiffRemoved "^ \+-.*" contained containedin=gitDiffMerge -syn match gitDiffRemoved "\[-.*-\]" contained containedin=gitDiff +syn match gitDiffRemoved "\[-[^]]*-\]" contained containedin=gitDiff -syn match gitKeyword /^\%(object\|type\|tag\|commit\|tree\|parent\|encoding\)\>/ contained containedin=gitHead nextgroup=gitHash,gitType skipwhite -syn match gitKeyword /^\%(tag\>\|ref:\)/ contained containedin=gitHead nextgroup=gitReference skipwhite -syn match gitKeyword /^Merge:/ contained containedin=gitHead nextgroup=gitHashAbbrev skipwhite -syn match gitMode /^\d\{6\}\>/ contained containedin=gitHead nextgroup=gitType,gitHash skipwhite -syn match gitIdentityKeyword /^\%(author\|committer\|tagger\)\>/ contained containedin=gitHead nextgroup=gitIdentity skipwhite -syn match gitIdentityHeader /^\%(Author\|Commit\|Tagger\):/ contained containedin=gitHead nextgroup=gitIdentity skipwhite -syn match gitDateHeader /^\%(AuthorDate\|CommitDate\|Date\):/ contained containedin=gitHead nextgroup=gitDate skipwhite +syn match gitKeyword /^commit \@=/ contained containedin=gitHead nextgroup=gitHashAbbrev skipwhite contains=@NoSpell +syn match gitKeyword /^\%(object\|tree\|parent\|encoding\|gpgsig\%(-\w\+\)\=\|previous\) \@=/ contained containedin=gitHead nextgroup=gitHash skipwhite contains=@NoSpell +syn match gitKeyword /^Merge:/ contained containedin=gitHead nextgroup=gitHashAbbrev skipwhite contains=@NoSpell +syn match gitIdentityKeyword /^\%(author\|committer\|tagger\) \@=/ contained containedin=gitHead nextgroup=gitIdentity skipwhite contains=@NoSpell +syn match gitIdentityHeader /^\%(Author\|Commit\|Tagger\):/ contained containedin=gitHead nextgroup=gitIdentity skipwhite contains=@NoSpell +syn match gitDateHeader /^\%(AuthorDate\|CommitDate\|Date\):/ contained containedin=gitHead nextgroup=gitDate skipwhite contains=@NoSpell -syn match gitReflogHeader /^Reflog:/ contained containedin=gitHead nextgroup=gitReflogMiddle skipwhite -syn match gitReflogHeader /^Reflog message:/ contained containedin=gitHead skipwhite -syn match gitReflogMiddle /\S\+@{\d\+} (/he=e-2 nextgroup=gitIdentity +syn match gitKeyword /^[*|\/\\_ ]\+\zscommit \@=/ contained containedin=gitGraph nextgroup=gitHashAbbrev skipwhite contains=@NoSpell +syn match gitKeyword /^[|\/\\_ ]\+\zs\%(object\|tree\|parent\|encoding\|gpgsig\%(-\w\+\)\=\|previous\) \@=/ contained containedin=gitGraph nextgroup=gitHash skipwhite contains=@NoSpell +syn match gitKeyword /^[|\/\\_ ]\+\zsMerge:/ contained containedin=gitGraph nextgroup=gitHashAbbrev skipwhite contains=@NoSpell +syn match gitIdentityKeyword /^[|\/\\_ ]\+\zs\%(author\|committer\|tagger\) \@=/ contained containedin=gitGraph nextgroup=gitIdentity skipwhite contains=@NoSpell +syn match gitIdentityHeader /^[|\/\\_ ]\+\zs\%(Author\|Commit\|Tagger\):/ contained containedin=gitGraph nextgroup=gitIdentity skipwhite contains=@NoSpell +syn match gitDateHeader /^[|\/\\_ ]\+\zs\%(AuthorDate\|CommitDate\|Date\):/ contained containedin=gitGraph nextgroup=gitDate skipwhite contains=@NoSpell -syn match gitDate /\<\u\l\l \u\l\l \d\=\d \d\d:\d\d:\d\d \d\d\d\d [+-]\d\d\d\d/ contained -syn match gitDate /-\=\d\+ [+-]\d\d\d\d\>/ contained -syn match gitDate /\<\d\+ \l\+ ago\>/ contained -syn match gitType /\<\%(tag\|commit\|tree\|blob\)\>/ contained nextgroup=gitHash skipwhite -syn match gitStage /\<\d\t\@=/ contained -syn match gitReference /\S\+\S\@!/ contained -syn match gitHash /\<\x\{40\}\>/ contained nextgroup=gitIdentity,gitStage,gitHash skipwhite -syn match gitHash /^\<\x\{40\}\>/ containedin=gitHead contained nextgroup=gitHash skipwhite -syn match gitHashAbbrev /\<\x\{4,40\}\>/ contained nextgroup=gitHashAbbrev skipwhite -syn match gitHashAbbrev /\<\x\{4,39\}\.\.\./he=e-3 contained nextgroup=gitHashAbbrev skipwhite +syn match gitKeyword /^type \@=/ contained containedin=gitHead nextgroup=gitType skipwhite contains=@NoSpell +syn match gitKeyword /^\%(summary\|boundary\|filename\|\%(author\|committer\)-\%(time\|tz\)\) \@=/ contained containedin=gitHead skipwhite contains=@NoSpell +syn match gitKeyword /^tag \@=/ contained containedin=gitHead nextgroup=gitReference skipwhite contains=@NoSpell +syn match gitIdentityKeyword /^\%(author\|committer\)-mail \@=/ contained containedin=gitHead nextgroup=gitEmail skipwhite contains=@NoSpell +syn match gitReflogHeader /^Reflog:/ contained containedin=gitHead nextgroup=gitReflogMiddle skipwhite contains=@NoSpell +syn match gitReflogHeader /^Reflog message:/ contained containedin=gitHead skipwhite contains=@NoSpell +syn match gitReflogMiddle /\S\+@{\d\+} (/he=e-2 nextgroup=gitIdentity contains=@NoSpell + +syn match gitIdentity /\S.\{-\} <[^>]*>/ contained nextgroup=gitDate skipwhite contains=@NoSpell +syn region gitEmail matchgroup=gitEmailDelimiter start=// keepend oneline contained containedin=gitIdentity contains=@NoSpell +syn match gitDate /\<\u\l\l \u\l\l \d\=\d \d\d:\d\d:\d\d \d\d\d\d [+-]\d\d\d\d/ contained contains=@NoSpell +syn match gitDate /-\=\d\+ [+-]\d\d\d\d\>/ contained contains=@NoSpell +syn match gitDate /\<\d\+ \l\+ ago\>/ contained contains=@NoSpell +syn match gitType /\<\%(tag\|commit\|tree\|blob\)\>/ contained nextgroup=gitHashAbbrev skipwhite contains=@NoSpell +syn match gitReference /\S\+\S\@!/ contained contains=@NoSpell +syn match gitHash /\<\x\{40,\}\>/ contained nextgroup=gitIdentity,gitHash skipwhite contains=@NoSpell +syn match gitReflogOld /^\x\{40,\} \@=/ contained nextgroup=gitReflogNew skipwhite contains=@NoSpell +syn match gitReflogNew /\<\x\{40,\} \@=/ contained nextgroup=gitIdentity skipwhite contains=@NoSpell +syn match gitHashAbbrev /\<\x\{4,\}\>/ contained nextgroup=gitHashAbbrev skipwhite contains=@NoSpell +syn match gitHashAbbrev /\<\x\{4,39\}\.\.\./he=e-3 contained nextgroup=gitHashAbbrev skipwhite contains=@NoSpell +syn match gitHashStage /\<\x\{4,\}\>/ contained nextgroup=gitStage skipwhite contains=@NoSpell +syn match gitStage /\<\d\t\@=/ contained contains=@NoSpell -syn match gitIdentity /\S.\{-\} <[^>]*>/ contained nextgroup=gitDate skipwhite -syn region gitEmail matchgroup=gitEmailDelimiter start=// keepend oneline contained containedin=gitIdentity syn match gitNotesHeader /^Notes:\ze\n / @@ -68,7 +96,10 @@ hi def link gitEmailDelimiter Delimiter hi def link gitEmail Special hi def link gitDate Number hi def link gitMode Number +hi def link gitHashStage gitHash hi def link gitHashAbbrev gitHash +hi def link gitReflogOld gitHash +hi def link gitReflogNew gitHash hi def link gitHash Identifier hi def link gitReflogMiddle gitReference hi def link gitReference Function diff --git a/runtime/syntax/gitcommit.vim b/runtime/syntax/gitcommit.vim index 63b1ce920f..42c8d4414f 100644 --- a/runtime/syntax/gitcommit.vim +++ b/runtime/syntax/gitcommit.vim @@ -2,71 +2,87 @@ " Language: git commit file " Maintainer: Tim Pope " Filenames: *.git/COMMIT_EDITMSG -" Last Change: 2019 Dec 05 +" Last Change: 2022 Jan 05 if exists("b:current_syntax") finish endif +scriptencoding utf-8 + syn case match syn sync minlines=50 +syn sync linebreaks=1 if has("spell") syn spell toplevel endif syn include @gitcommitDiff syntax/diff.vim -syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|#\)\@=/ fold contains=@gitcommitDiff +syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|@@\@!\|[^[:alnum:]\ +-]\S\@!\)\@=/ fold contains=@gitcommitDiff syn match gitcommitSummary "^.*\%<51v." contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell syn match gitcommitOverflow ".*" contained contains=@Spell -syn match gitcommitBlank "^[^#].*" contained contains=@Spell +syn match gitcommitBlank "^.\+" contained contains=@Spell +syn match gitcommitFirstLine "\%^.*" nextgroup=gitcommitBlank,gitcommitComment skipnl -if get(g:, "gitcommit_cleanup") is# "scissors" - syn match gitcommitFirstLine "\%^.*" nextgroup=gitcommitBlank skipnl - syn region gitcommitComment start=/^# -\+ >8 -\+$/ end=/\%$/ contains=gitcommitDiff -else - syn match gitcommitFirstLine "\%^[^#].*" nextgroup=gitcommitBlank skipnl - syn match gitcommitComment "^#.*" +let s:scissors = 0 +let s:l = search('^[#;@!$%^&|:] -\{24,\} >8 -\{24,\}$', 'cnW', '', 100) +if s:l == 0 + let s:l = line('$') +elseif getline(s:l)[0] !=# getline(s:l - 1)[0] + let s:scissors = 1 endif +let s:comment = escape((matchstr(getline(s:l), '^[#;@!$%^&|:]\S\@!') . '#')[0], '^$.*[]~\"/') -syn match gitcommitHead "^\%(# .*\n\)\+#$" contained transparent -syn match gitcommitOnBranch "\%(^# \)\@<=On branch" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite -syn match gitcommitOnBranch "\%(^# \)\@<=Your branch .\{-\} '" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite +if s:scissors + let s:comment .= ' -\{24,\} >8 -\{24,\}$' + exe 'syn region gitcommitComment start="^' . s:comment . '" end="\%$" contains=gitcommitDiff' +else + exe 'syn match gitcommitComment "^' . s:comment . '.*"' +endif +exe 'syn match gitcommitTrailers "\n\@<=\n\%([[:alnum:]-]\+\s*:.*\|(cherry picked from commit .*\)\%(\n\s.*\|\n[[:alnum:]-]\+\s*:.*\|\n(cherry picked from commit .*\)*\%(\n\n*\%(' . s:comment . '\)\|\n*\%$\)\@="' + +unlet s:l s:comment s:scissors + +syn match gitcommitTrailerToken "^[[:alnum:]-]\+\s*:" contained containedin=gitcommitTrailers + +syn match gitcommitHash "\<\x\{40,}\>" contains=@NoSpell display +syn match gitcommitOnBranch "\%(^. \)\@<=On branch" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite +syn match gitcommitOnBranch "\%(^. \)\@<=Your branch .\{-\} '" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite syn match gitcommitBranch "[^ ']\+" contained -syn match gitcommitNoBranch "\%(^# \)\@<=Not currently on any branch." contained containedin=gitcommitComment -syn match gitcommitHeader "\%(^# \)\@<=.*:$" contained containedin=gitcommitComment -syn region gitcommitAuthor matchgroup=gitCommitHeader start=/\%(^# \)\@<=\%(Author\|Committer\):/ end=/$/ keepend oneline contained containedin=gitcommitComment transparent -syn match gitcommitNoChanges "\%(^# \)\@<=No changes$" contained containedin=gitcommitComment +syn match gitcommitNoBranch "\%(^. \)\@<=Not currently on any branch." contained containedin=gitcommitComment +syn match gitcommitHeader "\%(^. \)\@<=\S.*[::]\%(\n^$\)\@!$" contained containedin=gitcommitComment +syn region gitcommitAuthor matchgroup=gitCommitHeader start=/\%(^. \)\@<=\%(Author\|Committer\|Date\):/ end=/$/ keepend oneline contained containedin=gitcommitComment transparent +syn match gitcommitHeader "\%(^. \)\@<=commit\%( \x\{40,\}$\)\@=" contained containedin=gitcommitComment nextgroup=gitcommitHash skipwhite +syn match gitcommitNoChanges "\%(^. \)\@<=No changes$" contained containedin=gitcommitComment -syn region gitcommitUntracked start=/^# Untracked files:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitUntrackedFile fold -syn match gitcommitUntrackedFile "\t\@<=.*" contained +syn match gitcommitType "\%(^.\t\)\@<=[^[:punct:][:space:]][^/::]*[^[:punct:][:space:]][::]\ze "he=e-1 contained containedin=gitcommitComment nextgroup=gitcommitFile skipwhite +syn match gitcommitFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitArrow +syn match gitcommitArrow " -> " contained nextgroup=gitcommitFile +syn match gitcommitUntrackedFile "\%(^.\t\)\@<=[^::/]*\%(/.*\)\=$" contained containedin=gitcommitComment -syn region gitcommitDiscarded start=/^# Change\%(s not staged for commit\|d but not updated\):/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitDiscardedType fold -syn region gitcommitSelected start=/^# Changes to be committed:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitSelectedType fold -syn region gitcommitUnmerged start=/^# Unmerged paths:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitUnmergedType fold +syn region gitcommitUntracked start=/^\z(.\) Untracked files:$/ end=/^\z1\=$\|^\z1\@!/ contains=gitcommitHeader containedin=gitcommitComment containedin=gitcommitComment contained transparent fold +syn region gitcommitDiscarded start=/^\z(.\) Change\%(s not staged for commit\|d but not updated\):$/ end=/^\z1\=$\|^\z1\@!/ contains=gitcommitHeader,gitcommitDiscardedType containedin=gitcommitComment containedin=gitcommitComment contained transparent fold +syn region gitcommitSelected start=/^\z(.\) Changes to be committed:$/ end=/^\z1$\|^\z1\@!/ contains=gitcommitHeader,gitcommitSelectedType containedin=gitcommitComment containedin=gitcommitComment contained transparent fold +syn region gitcommitUnmerged start=/^\z(.\) Unmerged paths:$/ end=/^\z1\=$\|^\z1\@!/ contains=gitcommitHeader,gitcommitUnmergedType containedin=gitcommitComment containedin=gitcommitComment contained transparent fold +syn match gitcommitUntrackedFile "\%(^.\t\)\@<=.*" contained containedin=gitcommitUntracked -syn match gitcommitDiscardedType "\t\@<=[[:lower:]][^:]*[[:lower:]]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitDiscardedFile skipwhite -syn match gitcommitSelectedType "\t\@<=[[:lower:]][^:]*[[:lower:]]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitSelectedFile skipwhite -syn match gitcommitUnmergedType "\t\@<=[[:lower:]][^:]*[[:lower:]]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitUnmergedFile skipwhite -syn match gitcommitDiscardedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitDiscardedArrow -syn match gitcommitSelectedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow -syn match gitcommitUnmergedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow +syn match gitcommitDiscardedType "\%(^.\t\)\@<=[^[:punct:][:space:]][^/::]*[^[:punct:][:space:]][::]\ze "he=e-1 contained nextgroup=gitcommitDiscardedFile skipwhite +syn match gitcommitSelectedType "\%(^.\t\)\@<=[^[:punct:][:space:]][^/::]*[^[:punct:][:space:]][::]\ze "he=e-1 contained nextgroup=gitcommitSelectedFile skipwhite +syn match gitcommitUnmergedType "\%(^.\t\)\@<=[^[:punct:][:space:]][^/::]*[^[:punct:][:space:]][::]\ze "he=e-1 contained nextgroup=gitcommitUnmergedFile skipwhite +syn match gitcommitDiscardedFile "\S.\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitDiscardedArrow +syn match gitcommitSelectedFile "\S.\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow +syn match gitcommitUnmergedFile "\S.\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitUnmergedArrow syn match gitcommitDiscardedArrow " -> " contained nextgroup=gitcommitDiscardedFile syn match gitcommitSelectedArrow " -> " contained nextgroup=gitcommitSelectedFile -syn match gitcommitUnmergedArrow " -> " contained nextgroup=gitcommitSelectedFile - -syn match gitcommitWarning "\%^[^#].*: needs merge$" nextgroup=gitcommitWarning skipnl -syn match gitcommitWarning "^[^#].*: needs merge$" nextgroup=gitcommitWarning skipnl contained -syn match gitcommitWarning "^\%(no changes added to commit\|nothing \%(added \)\=to commit\)\>.*\%$" +syn match gitcommitUnmergedArrow " -> " contained nextgroup=gitcommitUnmergedFile hi def link gitcommitSummary Keyword +hi def link gitcommitTrailerToken Label hi def link gitcommitComment Comment -hi def link gitcommitUntracked gitcommitComment -hi def link gitcommitDiscarded gitcommitComment -hi def link gitcommitSelected gitcommitComment -hi def link gitcommitUnmerged gitcommitComment +hi def link gitcommitHash Identifier hi def link gitcommitOnBranch Comment hi def link gitcommitBranch Special hi def link gitcommitNoBranch gitCommitBranch diff --git a/runtime/syntax/gitrebase.vim b/runtime/syntax/gitrebase.vim index bc6f34d1a7..13f157b005 100644 --- a/runtime/syntax/gitrebase.vim +++ b/runtime/syntax/gitrebase.vim @@ -2,7 +2,7 @@ " Language: git rebase --interactive " Maintainer: Tim Pope " Filenames: git-rebase-todo -" Last Change: 2019 Dec 06 +" Last Change: 2022 Jan 05 if exists("b:current_syntax") finish @@ -10,8 +10,10 @@ endif syn case match -syn match gitrebaseHash "\v<\x{7,}>" contained -syn match gitrebaseCommit "\v<\x{7,}>" nextgroup=gitrebaseSummary skipwhite +let s:c = escape((matchstr(getline('$'), '^[#;@!$%^&|:]\S\@!') . '#')[0], '^$.*[]~\"/') + +syn match gitrebaseHash "\v<\x{7,}>" contained contains=@NoSpell +syn match gitrebaseCommit "\v<\x{7,}>" nextgroup=gitrebaseSummary skipwhite contains=@NoSpell syn match gitrebasePick "\v^p%(ick)=>" nextgroup=gitrebaseCommit skipwhite syn match gitrebaseReword "\v^r%(eword)=>" nextgroup=gitrebaseCommit skipwhite syn match gitrebaseEdit "\v^e%(dit)=>" nextgroup=gitrebaseCommit skipwhite @@ -26,12 +28,15 @@ syn match gitrebaseLabel "\v^l(abel)=>" nextgroup=gitrebaseName skipwhite syn match gitrebaseReset "\v^(t|reset)=>" nextgroup=gitrebaseName skipwhite syn match gitrebaseSummary ".*" contains=gitrebaseHash contained syn match gitrebaseCommand ".*" contained -syn match gitrebaseComment "^\s*#.*" contains=gitrebaseHash +exe 'syn match gitrebaseComment " \@<=' . s:c . ' empty$" containedin=gitrebaseSummary contained' +exe 'syn match gitrebaseComment "^\s*' . s:c . '.*" contains=gitrebaseHash' syn match gitrebaseSquashError "\v%^%(s%(quash)=>|f%(ixup)=>)" nextgroup=gitrebaseCommit skipwhite syn match gitrebaseMergeOption "\v-[Cc]>" nextgroup=gitrebaseMergeCommit skipwhite contained syn match gitrebaseMergeCommit "\v<\x{7,}>" nextgroup=gitrebaseName skipwhite contained syn match gitrebaseName "\v[^[:space:].*?i:^~/-]\S+" nextgroup=gitrebaseMergeComment skipwhite contained -syn match gitrebaseMergeComment "#" nextgroup=gitrebaseSummary skipwhite contained +exe 'syn match gitrebaseMergeComment "' . s:c . '" nextgroup=gitrebaseSummary skipwhite contained' + +unlet s:c hi def link gitrebaseCommit gitrebaseHash hi def link gitrebaseHash Identifier diff --git a/runtime/syntax/i3config.vim b/runtime/syntax/i3config.vim index a8b6637140..f9e15d57e5 100644 --- a/runtime/syntax/i3config.vim +++ b/runtime/syntax/i3config.vim @@ -1,8 +1,9 @@ " Vim syntax file " Language: i3 config file -" Maintainer: Mohamed Boughaba +" Original Author: Mohamed Boughaba +" Maintainer: Quentin Hibon (github user hiqua) " Version: 0.4 -" Last Change: 2021 Dec 14 +" Last Change: 2022 Jan 04 " References: " http://i3wm.org/docs/userguide.html#configuring From f85a424c832777892c4efaff163c2fa710ce8d91 Mon Sep 17 00:00:00 2001 From: Dominique Pelle Date: Sun, 9 Jan 2022 12:49:31 +0000 Subject: [PATCH 25/28] patch 8.2.4047: depending on the build features error messages are unused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Depending on the build features error messages are unused. Solution: Add #ifdefs. (Dominique PellĂ©, closes #9493) --- src/errors.h | 374 +++++++++++++++++++++++++++++++++++++++++++++----- src/version.c | 2 + 2 files changed, 341 insertions(+), 35 deletions(-) diff --git a/src/errors.h b/src/errors.h index 1c723acac3..d30b4b0f02 100644 --- a/src/errors.h +++ b/src/errors.h @@ -124,12 +124,16 @@ EXTERN char e_not_allowed_in_sandbox[] #endif EXTERN char e_invalid_scroll_size[] INIT(= N_("E49: Invalid scroll size")); +#ifdef FEAT_SYN_HL EXTERN char e_too_many_z[] INIT(= N_("E50: Too many \\z(")); +#endif EXTERN char e_too_many_str_open[] INIT(= N_("E51: Too many %s(")); +#ifdef FEAT_SYN_HL EXTERN char e_unmatched_z[] INIT(= N_("E52: Unmatched \\z(")); +#endif EXTERN char e_unmatched_str_percent_open[] INIT(= N_("E53: Unmatched %s%%(")); EXTERN char e_unmatched_str_open[] @@ -235,14 +239,18 @@ EXTERN char e_cant_find_buffer_str[] EXTERN char e_buffer_str_is_not_in_diff_mode[] INIT(= N_("E103: Buffer \"%s\" is not in diff mode")); #endif +#ifdef FEAT_DIGRAPHS EXTERN char e_escape_not_allowed_in_digraph[] INIT(= N_("E104: Escape not allowed in digraph")); +#endif +#ifdef FEAT_KEYMAP EXTERN char e_using_loadkeymap_not_in_sourced_file[] INIT(= N_("E105: Using :loadkeymap not in a sourced file")); +#endif // E106 unused +#ifdef FEAT_EVAL EXTERN char e_missing_parenthesis_str[] INIT(= N_("E107: Missing parentheses: %s")); -#ifdef FEAT_EVAL EXTERN char e_no_such_variable_str[] INIT(= N_("E108: No such variable: \"%s\"")); EXTERN char e_missing_colon_after_questionmark[] @@ -251,7 +259,6 @@ EXTERN char e_missing_closing_paren[] INIT(= N_("E110: Missing ')'")); EXTERN char e_missing_closing_square_brace[] INIT(= N_("E111: Missing ']'")); -#endif EXTERN char e_option_name_missing_str[] INIT(= N_("E112: Option name missing: %s")); EXTERN char e_unknown_option_str[] @@ -260,7 +267,6 @@ EXTERN char e_missing_double_quote_str[] INIT(= N_("E114: Missing double quote: %s")); EXTERN char e_missing_single_quote_str[] INIT(= N_("E115: Missing single quote: %s")); -#ifdef FEAT_EVAL EXTERN char e_invalid_arguments_for_function_str[] INIT(= N_("E116: Invalid arguments for function %s")); EXTERN char e_unknown_function_str[] @@ -343,18 +349,24 @@ EXTERN char e_unable_to_open_str_for_reading[] INIT(= N_("E153: Unable to open %s for reading")); EXTERN char e_duplicate_tag_str_in_file_str_str[] INIT(= N_("E154: Duplicate tag \"%s\" in file %s/%s")); +#ifdef FEAT_SIGNS EXTERN char e_unknown_sign_str[] INIT(= N_("E155: Unknown sign: %s")); EXTERN char e_missing_sign_name[] INIT(= N_("E156: Missing sign name")); EXTERN char e_invalid_sign_id_nr[] INIT(= N_("E157: Invalid sign ID: %d")); +#endif +#if defined(FEAT_SIGNS) || defined(FEAT_EVAL) EXTERN char e_invalid_buffer_name_str[] INIT(= N_("E158: Invalid buffer name: %s")); +#endif +#ifdef FEAT_SIGNS EXTERN char e_missing_sign_number[] INIT(= N_("E159: Missing sign number")); EXTERN char e_unknown_sign_command_str[] INIT(= N_("E160: Unknown sign command: %s")); +#endif #ifdef FEAT_EVAL EXTERN char e_breakpoint_not_found_str[] INIT(= N_("E161: Breakpoint not found: %s")); @@ -371,10 +383,13 @@ EXTERN char e_cant_open_linked_file_for_writing[] INIT(= N_("E166: Can't open linked file for writing")); EXTERN char e_scriptencoding_used_outside_of_sourced_file[] INIT(= N_("E167: :scriptencoding used outside of a sourced file")); +#ifdef FEAT_EVAL EXTERN char e_finish_used_outside_of_sourced_file[] INIT(= N_("E168: :finish used outside of a sourced file")); +#endif EXTERN char e_command_too_recursive[] INIT(= N_("E169: Command too recursive")); +#ifdef FEAT_EVAL EXTERN char e_missing_endwhile[] INIT(= N_("E170: Missing :endwhile")); EXTERN char e_missing_endfor[] @@ -383,6 +398,7 @@ EXTERN char e_missing_endif[] INIT(= N_("E171: Missing :endif")); EXTERN char e_missing_marker[] INIT(= N_("E172: Missing marker")); +#endif EXTERN char e_nr_more_file_to_edit[] INIT(= N_("E173: %d more file to edit")); EXTERN char e_nr_more_files_to_edit[] @@ -427,12 +443,16 @@ EXTERN char e_argument_must_be_letter_or_forward_backward_quote[] INIT(= N_("E191: Argument must be a letter or forward/backward quote")); EXTERN char e_recursive_use_of_normal_too_deep[] INIT(= N_("E192: Recursive use of :normal too deep")); +#ifdef FEAT_EVAL EXTERN char e_str_not_inside_function[] INIT(= N_("E193: %s not inside a function")); +#endif EXTERN char e_no_alternate_file_name_to_substitute_for_hash[] INIT(= N_("E194: No alternate file name to substitute for '#'")); +#ifdef FEAT_VIMINFO EXTERN char e_cannot_open_viminfo_file_for_reading[] INIT(= N_("E195: Cannot open viminfo file for reading")); +#endif #ifndef FEAT_DIGRAPHS EXTERN char e_no_digraphs_version[] INIT(= N_("E196: No digraphs in this version")); @@ -440,14 +460,18 @@ EXTERN char e_no_digraphs_version[] EXTERN char e_cannot_set_language_to_str[] INIT(= N_("E197: Cannot set language to \"%s\"")); // E198 unused +#ifdef FEAT_CMDWIN EXTERN char e_active_window_or_buffer_deleted[] INIT(= N_("E199: Active window or buffer deleted")); +#endif EXTERN char e_readpre_autocommands_made_file_unreadable[] INIT(= N_("E200: *ReadPre autocommands made the file unreadable")); EXTERN char e_readpre_autocommands_must_not_change_current_buffer[] INIT(= N_("E201: *ReadPre autocommands must not change current buffer")); +#ifdef FEAT_EVAL EXTERN char e_conversion_mad_file_unreadable[] INIT(= N_("E202: Conversion made file unreadable!")); +#endif EXTERN char e_autocommands_deleted_or_unloaded_buffer_to_be_written[] INIT(= N_("E203: Autocommands deleted or unloaded buffer to be written")); EXTERN char e_autocommands_changed_number_of_lines_in_unexpected_way[] @@ -470,8 +494,10 @@ EXTERN char e_cant_open_file_for_writing[] INIT(= N_("E212: Can't open file for writing")); EXTERN char e_cannot_convert_add_bang_to_write_without_conversion[] INIT(= N_("E213: Cannot convert (add ! to write without conversion)")); +#ifdef FEAT_EVAL EXTERN char e_cant_find_temp_file_for_writing[] INIT(= N_("E214: Can't find temp file for writing")); +#endif EXTERN char e_illegal_character_after_star_str[] INIT(= N_("E215: Illegal character after *: %s")); EXTERN char e_no_such_event_str[] @@ -486,8 +512,10 @@ EXTERN char e_missing_open_curly[] INIT(= N_("E219: Missing {.")); EXTERN char e_missing_close_curly[] INIT(= N_("E220: Missing }.")); +#ifdef FEAT_EVAL EXTERN char e_marker_cannot_start_with_lower_case_letter[] INIT(= N_("E221: Marker cannot start with lower case letter")); +#endif EXTERN char e_add_to_internal_buffer_that_was_already_read_from[] INIT(= N_("E222: Add to internal buffer that was already read from")); EXTERN char e_recursive_mapping[] @@ -509,8 +537,10 @@ EXTERN char e_cannot_read_from_str[] INIT(= N_("E230: Cannot read from \"%s\"")); EXTERN char e_guifontwide_invalid[] INIT(= N_("E231: 'guifontwide' invalid")); +#ifdef FEAT_BEVAL_GUI EXTERN char e_cannot_create_ballooneval_with_both_message_and_callback[] INIT(= N_("E232: Cannot create BalloonEval with both message and callback")); +#endif # if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) EXTERN char e_cannot_open_display[] INIT(= N_("E233: cannot open display")); @@ -535,8 +565,10 @@ EXTERN char e_printer_selection_failed[] EXTERN char e_print_error_str[] INIT(= N_("E238: Print error: %s")); #endif +#ifdef FEAT_SIGNS EXTERN char e_invalid_sign_text_str[] INIT(= N_("E239: Invalid sign text: %s")); +#endif #if defined(FEAT_CLIENTSERVER) && defined(FEAT_X11) EXTERN char e_no_connection_to_x_server[] INIT(= N_("E240: No connection to the X server")); @@ -590,8 +622,10 @@ EXTERN char e_couldnt_read_in_sign_data[] INIT(= N_("E255: Couldn't read in sign data")); #endif // E256 unused +#ifdef FEAT_CSCOPE EXTERN char e_cstag_tag_not_founc[] INIT(= N_("E257: cstag: tag not found")); +#endif #ifdef FEAT_CLIENTSERVER EXTERN char e_unable_to_send_to_client[] INIT(= N_("E258: Unable to send to client")); @@ -659,7 +693,7 @@ EXTERN char e_unable_to_read_server_reply[] INIT(= N_("E277: Unable to read a server reply")); #endif // E278 unused -#ifdef FEAT_TERMINAL +#if defined(FEAT_TERMINAL) && !defined(UNIX) && !defined(MSWIN) EXTERN char e_sorry_plusplusshell_not_supported_on_this_system[] INIT(= N_("E279: Sorry, ++shell is not supported on this system")); #endif @@ -673,12 +707,13 @@ EXTERN char e_cannot_read_from_str_2[] EXTERN char e_no_marks_matching_str[] INIT(= N_("E283: No marks matching \"%s\"")); #ifdef FEAT_XIM +# ifndef FEAT_GUI_GTK EXTERN char e_cannot_set_ic_values[] INIT(= N_("E284: Cannot set IC values")); -# if defined(FEAT_GUI_X11) +# endif +# ifdef FEAT_GUI_X11 EXTERN char e_failed_to_create_input_context[] INIT(= N_("E285: Failed to create input context")); -# endif EXTERN char e_failed_to_open_input_method[] INIT(= N_("E286: Failed to open input method")); EXTERN char e_warning_could_not_set_destroy_callback_to_im[] @@ -687,6 +722,7 @@ EXTERN char e_input_method_doesnt_support_any_style[] INIT(= N_("E288: input method doesn't support any style")); EXTERN char e_input_method_doesnt_support_my_preedit_type[] INIT(= N_("E289: input method doesn't support my preedit type")); +# endif #endif #ifdef FEAT_SEARCH_EXTRA EXTERN char e_list_or_number_required[] @@ -774,12 +810,11 @@ EXTERN char e_attention[] INIT(= N_("E325: ATTENTION")); EXTERN char e_too_many_swap_files_found[] INIT(= N_("E326: Too many swap files found")); +#ifdef FEAT_MENU EXTERN char_u e_part_of_menu_item_path_is_not_sub_menu[] INIT(= N_("E327: Part of menu-item path is not sub-menu")); -#ifdef FEAT_MENU EXTERN char e_menu_only_exists_in_another_mode[] INIT(= N_("E328: Menu only exists in another mode")); -#endif EXTERN char_u e_no_menu_str[] INIT(= N_("E329: No menu \"%s\"")); EXTERN char e_menu_path_must_not_lead_to_sub_menu[] @@ -798,8 +833,11 @@ EXTERN char e_menu_path_must_lead_to_sub_menu[] INIT(= N_("E336: Menu path must lead to a sub-menu")); EXTERN char e_menu_not_found_check_menu_names[] INIT(= N_("E337: Menu not found - check menu names")); +#endif +#ifdef FEAT_BROWSE EXTERN char e_sorry_no_file_browser_in_console_mode[] INIT(= N_("E338: Sorry, no file browser in console mode")); +#endif EXTERN char e_pattern_too_long[] INIT(= N_("E339: Pattern too long")); // E340 unused @@ -807,8 +845,11 @@ EXTERN char e_internal_error_lalloc_zero[] INIT(= N_("E341: Internal error: lalloc(0, )")); EXTERN char e_out_of_memory_allocating_nr_bytes[] INIT(= N_("E342: Out of memory! (allocating %lu bytes)")); +#ifdef FEAT_PATH_EXTRA EXTERN char e_invalid_path_number_must_be_at_end_of_path_or_be_followed_by_str[] INIT(= N_("E343: Invalid path: '**[number]' must be at the end of the path or be followed by '%s'.")); +#endif +#ifdef FEAT_SEARCHPATH EXTERN char e_cant_find_directory_str_in_cdpath[] INIT(= N_("E344: Can't find directory \"%s\" in cdpath")); EXTERN char e_cant_find_file_str_in_path[] @@ -817,16 +858,19 @@ EXTERN char e_no_more_directory_str_found_in_cdpath[] INIT(= N_("E346: No more directory \"%s\" found in cdpath")); EXTERN char e_no_more_file_str_found_in_path[] INIT(= N_("E347: No more file \"%s\" found in path")); +#endif EXTERN char e_no_string_under_cursor[] INIT(= N_("E348: No string under cursor")); EXTERN char e_no_identifier_under_cursor[] INIT(= N_("E349: No identifier under cursor")); +#ifdef FEAT_FOLDING EXTERN char e_cannot_create_fold_with_current_foldmethod[] INIT(= N_("E350: Cannot create fold with current 'foldmethod'")); EXTERN char e_cannot_delete_fold_with_current_foldmethod[] INIT(= N_("E351: Cannot delete fold with current 'foldmethod'")); EXTERN char e_cannot_erase_folds_with_current_foldmethod[] INIT(= N_("E352: Cannot erase folds with current 'foldmethod'")); +#endif EXTERN char e_nothing_in_register_str[] INIT(= N_("E353: Nothing in register %s")); EXTERN char e_invalid_register_name_str[] @@ -835,20 +879,26 @@ EXTERN char e_unknown_option_str_2[] INIT(= N_("E355: Unknown option: %s")); EXTERN char e_get_varp_error[] INIT(= N_("E356: get_varp ERROR")); +#ifdef FEAT_LANGMAP EXTERN char e_langmap_matching_character_missing_for_str[] INIT(= N_("E357: 'langmap': Matching character missing for %s")); EXTERN char e_langmap_extra_characters_after_semicolon_str[] INIT(= N_("E358: 'langmap': Extra characters after semicolon: %s")); +#endif #if defined(AMIGA) || defined(MACOS_X) || defined(MSWIN) \ || defined(UNIX) || defined(VMS) EXTERN char e_screen_mode_setting_not_supported[] INIT(= N_("E359: Screen mode setting not supported")); #endif +#ifdef AMIGA EXTERN char e_cannot_execute_shell_with_f_option[] INIT(= N_("E360: Cannot execute shell with -f option")); +#endif // E361 unused +#if defined(FEAT_EVAL) && defined(FEAT_FLOAT) EXTERN char e_using_boolean_value_as_float[] INIT(= N_("E362: Using a boolean value as a Float")); +#endif EXTERN char e_pattern_uses_more_memory_than_maxmempattern[] INIT(= N_("E363: pattern uses more memory than 'maxmempattern'")); #ifdef FEAT_LIBCALL @@ -859,8 +909,10 @@ EXTERN char e_library_call_failed_for_str[] EXTERN char e_failed_to_print_postscript_file[] INIT(= N_("E365: Failed to print PostScript file")); #endif +#ifdef FEAT_PROP_POPUP EXTERN char e_not_allowed_to_enter_popup_window[] INIT(= N_("E366: Not allowed to enter a popup window")); +#endif EXTERN char e_no_such_group_str[] INIT(= N_("E367: No such group: \"%s\"")); #ifdef FEAT_LIBCALL @@ -877,6 +929,7 @@ EXTERN char e_could_not_load_library_str_str[] EXTERN char e_command_not_found[] INIT(= N_("E371: Command not found")); #endif +#ifdef FEAT_QUICKFIX EXTERN char e_too_many_chr_in_format_string[] INIT(= N_("E372: Too many %%%c in format string")); EXTERN char e_unexpected_chr_in_format_str[] @@ -899,6 +952,7 @@ EXTERN char e_at_top_of_quickfix_stack[] INIT(= N_("E381: At top of quickfix stack")); EXTERN char e_cannot_write_buftype_option_is_set[] INIT(= N_("E382: Cannot write, 'buftype' option is set")); +#endif EXTERN char e_invalid_search_string_str[] INIT(= N_("E383: Invalid search string: %s")); EXTERN char e_search_hit_top_without_match_for_str[] @@ -907,12 +961,15 @@ EXTERN char e_search_hit_bottom_without_match_for_str[] INIT(= N_("E385: search hit BOTTOM without match for: %s")); EXTERN char e_expected_question_or_slash_after_semicolon[] INIT(= N_("E386: Expected '?' or '/' after ';'")); +#ifdef FEAT_FIND_ID EXTERN char e_match_is_on_current_line[] INIT(= N_("E387: Match is on current line")); EXTERN char e_couldnt_find_definition[] INIT(= N_("E388: Couldn't find definition")); EXTERN char e_couldnt_find_pattern[] INIT(= N_("E389: Couldn't find pattern")); +#endif +#ifdef FEAT_SYN_HL EXTERN char e_illegal_argument_str_2[] INIT(= N_("E390: Illegal argument: %s")); EXTERN char e_no_such_syntax_cluster_1[] @@ -954,6 +1011,7 @@ EXTERN char e_unknown_group_name_str[] INIT(= N_("E409: Unknown group name: %s")); EXTERN char e_invalid_syntax_subcommand_str[] INIT(= N_("E410: Invalid :syntax subcommand: %s")); +#endif EXTERN char e_highlight_group_name_not_found_str[] INIT(= N_("E411: highlight group not found: %s")); EXTERN char e_not_enough_arguments_highlight_link_str[] @@ -992,8 +1050,10 @@ EXTERN char e_cannot_go_beyond_last_matching_tag[] INIT(= N_("E428: Cannot go beyond last matching tag")); EXTERN char e_file_str_does_not_exist[] INIT(= N_("E429: File \"%s\" does not exist")); +#ifdef FEAT_EMACS_TAGS EXTERN char e_tag_file_path_truncated_for_str[] INIT(= N_("E430: Tag file path truncated for %s\n")); +#endif EXTERN char e_format_error_in_tags_file_str[] INIT(= N_("E431: Format error in tags file \"%s\"")); EXTERN char e_tags_file_not_sorted_str[] @@ -1014,8 +1074,10 @@ EXTERN char e_undo_list_corrupt[] INIT(= N_("E439: undo list corrupt")); EXTERN char e_undo_line_missing[] INIT(= N_("E440: undo line missing")); +#ifdef FEAT_QUICKFIX EXTERN char e_there_is_no_preview_window[] INIT(= N_("E441: There is no preview window")); +#endif EXTERN char e_cant_split_topleft_and_botright_at_the_same_time[] INIT(= N_("E442: Can't split topleft and botright at the same time")); EXTERN char e_cannot_rotate_when_another_window_is_split[] @@ -1024,10 +1086,12 @@ EXTERN char e_cannot_close_last_window[] INIT(= N_("E444: Cannot close last window")); EXTERN char e_other_window_contains_changes[] INIT(= N_("E445: Other window contains changes")); +#ifdef FEAT_SEARCHPATH EXTERN char e_no_file_name_under_cursor[] INIT(= N_("E446: No file name under cursor")); EXTERN char e_cant_find_file_str_in_path_2[] INIT(= N_("E447: Can't find file \"%s\" in path")); +#endif #ifdef USING_LOAD_LIBRARY EXTERN char e_could_not_load_library_function_str[] INIT(= N_("E448: Could not load library function %s")); @@ -1036,18 +1100,22 @@ EXTERN char e_could_not_load_library_function_str[] EXTERN char e_invalid_expression_received[] INIT(= N_("E449: Invalid expression received")); #endif +#ifdef FEAT_PROP_POPUP EXTERN char e_buffer_number_text_or_list_required[] INIT(= N_("E450: buffer number, text or a list required")); +#endif +#ifdef FEAT_EVAL EXTERN char e_expected_right_curly_str[] INIT(= N_("E451: Expected }: %s")); -#ifdef FEAT_EVAL EXTERN char e_double_semicolon_in_list_of_variables[] INIT(= N_("E452: Double ; in list of variables")); #endif EXTERN char e_ul_color_unknown[] INIT(= N_("E453: UL color unknown")); +#ifdef FEAT_EVAL EXTERN char e_function_list_was_modified[] INIT(= N_("E454: function list was modified")); +#endif #ifdef FEAT_POSTSCRIPT EXTERN char e_error_writing_to_postscript_output_file[] INIT(= N_("E455: Error writing to PostScript output file")); @@ -1058,15 +1126,17 @@ EXTERN char e_cant_find_postscript_resource_file_str_ps[] EXTERN char e_cant_read_postscript_resource_file_str[] INIT(= N_("E457: Can't read PostScript resource file \"%s\"")); #endif +#ifdef FEAT_GUI_X11 EXTERN char e_cannot_allocate_colormap_entry_some_colors_may_be_incorrect[] INIT(= N_("E458: Cannot allocate colormap entry, some colors may be incorrect")); +#endif #if defined(UNIX) || defined(FEAT_SESSION) EXTERN char e_cannot_go_back_to_previous_directory[] INIT(= N_("E459: Cannot go back to previous directory")); #endif +#ifdef FEAT_EVAL EXTERN char e_entries_missing_in_mapset_dict_argument[] INIT(= N_("E460: entries missing in mapset() dict argument")); -#ifdef FEAT_EVAL EXTERN char e_illegal_variable_name_str[] INIT(= N_("E461: Illegal variable name: %s")); #endif @@ -1082,12 +1152,16 @@ EXTERN char e_winsize_requires_two_number_arguments[] INIT(= N_("E465: :winsize requires two number arguments")); EXTERN char e_winpos_requires_two_number_arguments[] INIT(= N_("E466: :winpos requires two number arguments")); +#ifdef FEAT_EVAL EXTERN char e_custom_completion_requires_function_argument[] INIT(= N_("E467: Custom completion requires a function argument")); +#endif EXTERN char e_completion_argument_only_allowed_for_custom_completion[] INIT(= N_("E468: Completion argument only allowed for custom completion")); +#ifdef FEAT_CSCOPE EXTERN char e_invalid_cscopequickfix_flag_chr_for_chr[] INIT(= N_("E469: invalid cscopequickfix flag %c for %c")); +#endif EXTERN char e_command_aborted[] INIT(= N_("E470: Command aborted")); EXTERN char e_argument_required[] @@ -1102,8 +1176,10 @@ EXTERN char e_invalid_argument_str[] INIT(= N_("E475: Invalid argument: %s")); EXTERN char e_invalid_value_for_argument_str[] INIT(= N_("E475: Invalid value for argument %s")); +#if defined(FEAT_JOB_CHANNEL) || defined(FEAT_PROP_POPUP) EXTERN char e_invalid_value_for_argument_str_str[] INIT(= N_("E475: Invalid value for argument %s: %s")); +#endif EXTERN char e_invalid_command[] INIT(= N_("E476: Invalid command")); #ifdef FEAT_EVAL @@ -1230,46 +1306,58 @@ EXTERN char e_missing_colon[] INIT(= N_("E524: Missing colon")); EXTERN char e_zero_length_string[] INIT(= N_("E525: Zero length string")); +#ifdef FEAT_VIMINFO EXTERN char e_missing_number_after_angle_str_angle[] INIT(= N_("E526: Missing number after <%s>")); EXTERN char e_missing_comma[] INIT(= N_("E527: Missing comma")); EXTERN char e_must_specify_a_value[] INIT(= N_("E528: Must specify a ' value")); +#endif EXTERN char e_cannot_set_term_to_empty_string[] INIT(= N_("E529: Cannot set 'term' to empty string")); +#ifdef FEAT_GUI EXTERN char e_cannot_change_term_in_GUI[] INIT(= N_("E530: Cannot change 'term' in the GUI")); EXTERN char e_use_gui_to_start_GUI[] INIT(= N_("E531: Use \":gui\" to start the GUI")); +#endif #ifdef FEAT_NETBEANS_INTG EXTERN char e_highlighting_color_name_too_long_in_defineAnnoType[] INIT(= N_("E532: highlighting color name too long in defineAnnoType")); #endif +#ifdef FEAT_GUI EXTERN char e_cant_select_wide_font[] INIT(= N_("E533: can't select wide font")); EXTERN char e_invalid_wide_font[] INIT(= N_("E534: Invalid wide font")); +#endif EXTERN char e_illegal_character_after_chr[] INIT(= N_("E535: Illegal character after <%c>")); +#ifdef FEAT_FOLDING EXTERN char e_comma_required[] INIT(= N_("E536: comma required")); EXTERN char e_commentstring_must_be_empty_or_contain_str[] INIT(= N_("E537: 'commentstring' must be empty or contain %s")); +#endif // E538 unused EXTERN char e_illegal_character_str[] INIT(= N_("E539: Illegal character <%s>")); +#ifdef FEAT_STL_OPT EXTERN char e_unclosed_expression_sequence[] INIT(= N_("E540: Unclosed expression sequence")); // E541 unused EXTERN char e_unbalanced_groups[] INIT(= N_("E542: unbalanced groups")); +#endif #ifdef MSWIN EXTERN char e_not_valid_codepage[] INIT(= N_("E543: Not a valid codepage")); #endif +#ifdef FEAT_KEYMAP EXTERN char e_keymap_file_not_found[] INIT(= N_("E544: Keymap file not found")); +#endif #ifdef CURSOR_SHAPE EXTERN char e_missing_colon_2[] INIT(= N_("E545: Missing colon")); @@ -1284,14 +1372,18 @@ EXTERN char e_digit_expected[] INIT(= N_("E548: digit expected")); EXTERN char e_illegal_percentage[] INIT(= N_("E549: Illegal percentage")); +#ifdef FEAT_PRINTER EXTERN char e_missing_colon_3[] INIT(= N_("E550: Missing colon")); EXTERN char e_illegal_component[] INIT(= N_("E551: Illegal component")); EXTERN char e_digit_expected_2[] INIT(= N_("E552: digit expected")); +#endif +#ifdef FEAT_QUICKFIX EXTERN char e_no_more_items[] INIT(= N_("E553: No more items")); +#endif EXTERN char e_syntax_error_in_str_curlies[] INIT(= N_("E554: Syntax error in %s{...}")); EXTERN char e_at_bottom_of_tag_stack[] @@ -1302,8 +1394,11 @@ EXTERN char e_cannot_open_termcap_file[] INIT(= N_("E557: Cannot open termcap file")); EXTERN char e_terminal_entry_not_found_in_terminfo[] INIT(= N_("E558: Terminal entry not found in terminfo")); +#if defined(HAVE_TGETENT) && !defined(TERMINFO) EXTERN char e_terminal_entry_not_found_in_termcap[] INIT(= N_("E559: Terminal entry not found in termcap")); +#endif +#ifdef FEAT_CSCOPE EXTERN char e_usage_cscope_str[] INIT(= N_("E560: Usage: cs[cope] %s")); EXTERN char e_unknown_cscope_search_type[] @@ -1314,8 +1409,10 @@ EXTERN char e_stat_str_error_nr[] INIT(= N_("E563: stat(%s) error: %d")); EXTERN char e_str_is_not_directory_or_valid_cscope_database[] INIT(= N_("E564: %s is not a directory or a valid cscope database")); +#endif EXTERN char e_not_allowed_to_change_text_or_change_window[] INIT(= N_("E565: Not allowed to change text or change window")); +#ifdef FEAT_CSCOPE EXTERN char e_could_not_create_cscope_pipes[] INIT(= N_("E566: Could not create cscope pipes")); EXTERN char e_no_cscope_connections[] @@ -1325,14 +1422,20 @@ EXTERN char e_duplicate_cscope_database_not_added[] // E569 unused EXTERN char e_fatal_error_in_cs_manage_matches[] INIT(= N_("E570: fatal error in cs_manage_matches")); +#endif #ifdef DYNAMIC_TCL EXTERN char e_sorry_this_command_is_disabled_tcl_library_could_not_be_loaded[] INIT(= N_("E571: Sorry, this command is disabled: the Tcl library could not be loaded.")); #endif +#ifdef FEAT_TCL EXTERN char e_exit_code_nr[] INIT(= N_("E572: exit code %d")); +#endif +#ifdef FEAT_CLIENTSERVER EXTERN char e_invalid_server_id_used_str[] INIT(= N_("E573: Invalid server id used: %s")); +#endif +#ifdef FEAT_VIMINFO EXTERN char e_unknown_register_type_nr[] INIT(= N_("E574: Unknown register type %d")); // E575 @@ -1344,6 +1447,7 @@ EXTERN char e_nonr_missing_gt[] // E577 EXTERN char e_illegal_register_name[] INIT(= N_("Illegal register name")); +#endif EXTERN char e_not_allowed_to_change_text_here[] INIT(= N_("E578: Not allowed to change text here")); #ifdef FEAT_EVAL @@ -1374,8 +1478,10 @@ EXTERN char e_endfor_without_for[] #endif EXTERN char e_backupext_and_patchmode_are_equal[] INIT(= N_("E589: 'backupext' and 'patchmode' are equal")); +#ifdef FEAT_QUICKFIX EXTERN char e_preview_window_already_exists[] INIT(= N_("E590: A preview window already exists")); +#endif EXTERN char e_winheight_cannot_be_smaller_than_winminheight[] INIT(= N_("E591: 'winheight' cannot be smaller than 'winminheight'")); EXTERN char e_winwidth_cannot_be_smaller_than_winminwidth[] @@ -1384,16 +1490,24 @@ EXTERN char e_need_at_least_nr_lines[] INIT(= N_("E593: Need at least %d lines")); EXTERN char e_need_at_least_nr_columns[] INIT(= N_("E594: Need at least %d columns")); +#ifdef FEAT_LINEBREAK EXTERN char e_showbreak_contains_unprintable_or_wide_character[] INIT(= N_("E595: 'showbreak' contains unprintable or wide character")); +#endif +#ifdef FEAT_GUI EXTERN char e_invalid_fonts[] INIT(= N_("E596: Invalid font(s)")); +# ifdef FEAT_XFONTSET EXTERN char e_cant_select_fontset[] INIT(= N_("E597: can't select fontset")); EXTERN char e_invalid_fontset[] INIT(= N_("E598: Invalid fontset")); +# endif +#endif +#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) EXTERN char e_value_of_imactivatekey_is_invalid[] INIT(= N_("E599: Value of 'imactivatekey' is invalid")); +#endif #ifdef FEAT_EVAL EXTERN char e_missing_endtry[] INIT(= N_("E600: Missing :endtry")); @@ -1428,7 +1542,7 @@ EXTERN char e_using_special_as_number[] EXTERN char e_too_many_signs_defined[] INIT(= N_("E612: Too many signs defined")); #endif -#ifdef FEAT_PRINTER +#if defined(MSWIN) && defined(FEAT_PRINTER) EXTERN char e_unknown_printer_font_str[] INIT(= N_("E613: Unknown printer font: %s")); #endif @@ -1457,12 +1571,16 @@ EXTERN char e_str_resource_file_has_wrong_version[] #ifdef FEAT_CSCOPE EXTERN char e_could_not_fork_for_cscope[] INIT(= N_("E622: Could not fork for cscope")); +# ifndef UNIX EXTERN char e_could_not_spawn_cscope_process[] INIT(= N_("E623: Could not spawn cscope process")); +# endif #endif +#if defined(FEAT_PRINTER) && defined(FEAT_POSTSCRIPT) EXTERN char e_cant_open_file_str_3[] INIT(= N_("E624: Can't open file \"%s\"")); -#ifdef FEAT_CSCOPE +#endif +#if defined(FEAT_CSCOPE) && !defined(UNIX) EXTERN char e_cannot_open_cscope_database_str[] INIT(= N_("E625: cannot open cscope database: %s")); EXTERN char e_cannot_get_cscope_database_information[] @@ -1473,9 +1591,11 @@ EXTERN char e_missing_colon_str[] INIT(= "E627: missing colon: %s"); EXTERN char e_missing_bang_or_slash_in_str[] INIT(= "E628: missing ! or / in: %s"); +#ifdef NBDEBUG EXTERN char e_bad_return_from_nb_do_cmd[] INIT(= "E629: bad return from nb_do_cmd"); #endif +#endif #ifdef FEAT_JOB_CHANNEL EXTERN char e_str_write_while_not_connected[] INIT(= N_("E630: %s(): write while not connected")); @@ -1529,8 +1649,10 @@ EXTERN char e_invalid_buffer_identifier_in_getanno[] // E653 unused EXTERN char e_missing_delimiter_after_search_pattern_str[] INIT(= N_("E654: missing delimiter after search pattern: %s")); +#ifdef FEAT_EVAL EXTERN char e_too_many_symbolic_links_cycle[] INIT(= N_("E655: Too many symbolic links (cycle?)")); +#endif #ifdef FEAT_NETBEANS_INTG // E656 EXTERN char e_netbeans_disallows_writes_of_unmodified_buffers[] @@ -1563,8 +1685,10 @@ EXTERN char e_changelist_is_empty[] EXTERN char e_cannot_start_gui_no_valid_font_found[] INIT(= N_("E665: Cannot start GUI, no valid font found")); #endif +#ifdef FEAT_EVAL EXTERN char e_compiler_not_supported_str[] INIT(= N_("E666: compiler not supported: %s")); +#endif #ifdef HAVE_FSYNC EXTERN char e_fsync_failed[] INIT(= N_("E667: Fsync failed")); @@ -1583,28 +1707,36 @@ EXTERN char e_cannot_find_window_title_str[] EXTERN char e_unable_to_open_window_inside_mdi_application[] INIT(= N_("E672: Unable to open window inside MDI application")); #endif +#if defined(FEAT_PRINTER) && defined(FEAT_POSTSCRIPT) EXTERN char e_incompatible_multi_byte_encoding_and_character_set[] INIT(= N_("E673: Incompatible multi-byte encoding and character set")); EXTERN char e_printmbcharset_cannot_be_empty_with_multi_byte_encoding[] INIT(= N_("E674: printmbcharset cannot be empty with multi-byte encoding.")); EXTERN char e_no_default_font_specified_for_multi_byte_printing[] INIT(= N_("E675: No default font specified for multi-byte printing.")); +#endif EXTERN char e_no_matching_autocommands_for_acwrite_buffer[] INIT(= N_("E676: No matching autocommands for acwrite buffer")); +#ifdef FEAT_SYN_HL EXTERN char e_error_writing_temp_file[] INIT(= N_("E677: Error writing temp file")); +#endif EXTERN char e_invalid_character_after_str_2[] INIT(= N_("E678: Invalid character after %s%%[dxouU]")); +#ifdef FEAT_SYN_HL EXTERN char e_recursive_loop_loading_syncolor_vim[] INIT(= N_("E679: recursive loop loading syncolor.vim")); +#endif EXTERN char e_buffer_nr_invalid_buffer_number[] INIT(= N_("E680: : invalid buffer number")); +#ifdef FEAT_QUICKFIX EXTERN char e_buffer_is_not_loaded[] INIT(= N_("E681: Buffer is not loaded")); EXTERN char e_invalid_search_pattern_or_delimiter[] INIT(= N_("E682: Invalid search pattern or delimiter")); EXTERN char e_file_name_missing_or_invalid_pattern[] INIT(= N_("E683: File name missing or invalid pattern")); +#endif #ifdef FEAT_EVAL EXTERN char e_list_index_out_of_range_nr[] INIT(= N_("E684: list index out of range: %ld")); @@ -1787,8 +1919,10 @@ EXTERN char e_option_str_is_not_set[] EXTERN char e_spellfile_does_not_have_nr_entries[] INIT(= N_("E765: 'spellfile' does not have %d entries")); #endif +#ifdef FEAT_EVAL EXTERN char e_insufficient_arguments_for_printf[] INIT(= N_("E766: Insufficient arguments for printf()")); +#endif EXTERN char e_too_many_arguments_to_printf[] INIT(= N_("E767: Too many arguments for printf()")); EXTERN char e_swap_file_exists_str_silent_overrides[] @@ -1805,18 +1939,21 @@ EXTERN char e_spell_file_is_for_newer_version_of_vim[] #endif EXTERN char e_symlink_loop_for_str[] INIT(= N_("E773: Symlink loop for \"%s\"")); +#ifdef FEAT_EVAL EXTERN char e_operatorfunc_is_empty[] INIT(= N_("E774: 'operatorfunc' is empty")); -#ifndef FEAT_EVAL +#else EXTERN char e_eval_feature_not_available[] INIT(= N_("E775: Eval feature not available")); #endif #ifdef FEAT_QUICKFIX EXTERN char e_no_location_list[] INIT(= N_("E776: No location list")); -#endif +# ifdef FEAT_EVAL EXTERN char e_string_or_list_expected[] INIT(= N_("E777: String or List expected")); +# endif +#endif #ifdef FEAT_SPELL EXTERN char e_this_does_not_look_like_sug_file_str[] INIT(= N_("E778: This does not look like a .sug file: %s")); @@ -1833,22 +1970,34 @@ EXTERN char e_duplicate_char_in_map_entry[] #endif EXTERN char e_cannot_close_last_tab_page[] INIT(= N_("E784: Cannot close last tab page")); +#ifdef FEAT_EVAL +# ifdef FEAT_COMPL_FUNC EXTERN char e_complete_can_only_be_used_in_insert_mode[] INIT(= N_("E785: complete() can only be used in Insert mode")); +# endif EXTERN char e_range_not_allowed[] INIT(= N_("E786: Range not allowed")); +#endif +#ifdef FEAT_DIFF EXTERN char e_buffer_changed_unexpectedly[] INIT(= N_("E787: Buffer changed unexpectedly")); +#endif EXTERN char e_not_allowed_to_edit_another_buffer_now[] INIT(= N_("E788: Not allowed to edit another buffer now")); +#ifdef FEAT_SYN_HL EXTERN char e_error_missing_rsb_str[] INIT(= N_("E789: Missing ']': %s")); +#endif EXTERN char e_undojoin_is_not_allowed_after_undo[] INIT(= N_("E790: undojoin is not allowed after undo")); +#ifdef FEAT_KEYMAP EXTERN char e_empty_keymap_entry[] INIT(= N_("E791: Empty keymap entry")); +#endif +#ifdef FEAT_MENU EXTERN char e_empty_menu_name[] INIT(= N_("E792: Empty menu name")); +#endif #ifdef FEAT_DIFF EXTERN char e_no_other_buffer_in_diff_mode_is_modifiable[] INIT(= N_("E793: No other buffer in diff mode is modifiable")); @@ -1863,27 +2012,33 @@ EXTERN char e_cannot_delete_variable[] EXTERN char e_cannot_delete_variable_str[] INIT(= N_("E795: Cannot delete variable %s")); // E796 +# ifdef MSWIN EXTERN char e_writing_to_device_disabled_with_opendevice_option[] INIT(= N_("writing to device disabled with 'opendevice' option")); +# endif #endif #ifdef FEAT_SPELL EXTERN char e_spellfilemising_autocommand_deleted_buffer[] INIT(= N_("E797: SpellFileMissing autocommand deleted buffer")); #endif +#ifdef FEAT_SEARCH_EXTRA EXTERN char e_id_is_reserved_for_match_nr[] INIT(= N_("E798: ID is reserved for \":match\": %d")); EXTERN char e_invalid_id_nr_must_be_greater_than_or_equal_to_one_1[] INIT(= N_("E799: Invalid ID: %d (must be greater than or equal to 1)")); +#endif #ifndef FEAT_ARABIC EXTERN char e_arabic_cannot_be_used_not_enabled_at_compile_time[] INIT(= N_("E800: Arabic cannot be used: Not enabled at compile time\n")); #endif +#ifdef FEAT_SEARCH_EXTRA EXTERN char e_id_already_taken_nr[] INIT(= N_("E801: ID already taken: %d")); EXTERN char e_invalid_id_nr_must_be_greater_than_or_equal_to_one_2[] INIT(= N_("E802: Invalid ID: %d (must be greater than or equal to 1)")); EXTERN char e_id_not_found_nr[] INIT(= N_("E803: ID not found: %d")); +#endif #ifdef FEAT_EVAL EXTERN char e_cannot_use_percent_with_float[] INIT(= N_("E804: Cannot use '%' with Float")); @@ -1906,8 +2061,10 @@ EXTERN char e_number_or_float_required[] EXTERN char e_hashsmall_is_not_available_without_the_eval_feature[] INIT(= N_("E809: #< is not available without the +eval feature")); #endif +#ifdef FEAT_DIFF EXTERN char e_cannot_read_or_write_temp_files[] INIT(= N_("E810: Cannot read or write temp files")); +#endif EXTERN char e_not_allowed_to_change_buffer_information_now[] INIT(= N_("E811: Not allowed to change buffer information now")); EXTERN char e_autocommands_changed_buffer_or_buffer_name[] @@ -1920,8 +2077,11 @@ EXTERN char e_cannot_close_window_only_autocmd_window_would_remain[] EXTERN char e_sorry_this_command_is_disabled_the_mzscheme_libraries_could_not_be_loaded[] INIT(= N_("E815: Sorry, this command is disabled, the MzScheme libraries could not be loaded.")); #endif +#ifdef FEAT_DIFF EXTERN char e_cannot_read_patch_output[] INIT(= N_("E816: Cannot read patch output")); +#endif +#ifdef FEAT_CRYPT EXTERN char e_blowfish_big_little_endian_use_wrong[] INIT(= N_("E817: Blowfish big/little endian use wrong")); EXTERN char e_sha256_test_failed[] @@ -1932,6 +2092,8 @@ EXTERN char e_sizeof_uint32_isnot_four[] INIT(= N_("E820: sizeof(uint32_t) != 4")); EXTERN char e_file_is_encrypted_with_unknown_method[] INIT(= N_("E821: File is encrypted with unknown method")); +#endif +#ifdef FEAT_PERSISTENT_UNDO EXTERN char e_cannot_open_undo_file_for_reading_str[] INIT(= N_("E822: Cannot open undo file for reading: %s")); EXTERN char e_not_an_undo_file_str[] @@ -1940,31 +2102,42 @@ EXTERN char e_incompatible_undo_file_str[] INIT(= N_("E824: Incompatible undo file: %s")); EXTERN char e_corrupted_undo_file_str_str[] INIT(= N_("E825: Corrupted undo file (%s): %s")); +# ifdef FEAT_CRYPT EXTERN char e_undo_file_decryption_failed[] INIT(= N_("E826: Undo file decryption failed: %s")); +# else EXTERN char e_undo_file_is_encrypted_str[] INIT(= N_("E827: Undo file is encrypted: %s")); +# endif EXTERN char e_cannot_open_undo_file_for_writing_str[] INIT(= N_("E828: Cannot open undo file for writing: %s")); EXTERN char e_write_error_in_undo_file_str[] INIT(= N_("E829: write error in undo file: %s")); +#endif EXTERN char e_undo_number_nr_not_found[] INIT(= N_("E830: Undo number %ld not found")); +#ifdef FEAT_CRYPT EXTERN char e_bf_key_init_called_with_empty_password[] INIT(= N_("E831: bf_key_init() called with empty password")); +# ifdef FEAT_PERSISTENT_UNDO EXTERN char e_non_encrypted_file_has_encrypted_undo_file[] INIT(= N_("E832: Non-encrypted file has encrypted undo file: %s")); +# endif +#else EXTERN char e_str_is_encrypted_and_this_version_of_vim_does_not_support_encryption[] INIT(= N_("E833: %s is encrypted and this version of Vim does not support encryption")); +#endif EXTERN char e_conflicts_with_value_of_listchars[] INIT(= N_("E834: Conflicts with value of 'listchars'")); EXTERN char e_conflicts_with_value_of_fillchars[] INIT(= N_("E835: Conflicts with value of 'fillchars'")); +#ifdef DYNAMIC_PYTHON EXTERN char e_this_vim_cannot_execute_python_after_using_py3[] INIT(= N_("E836: This Vim cannot execute :python after using :py3")); EXTERN char e_this_vim_cannot_execute_py3_after_using_python[] INIT(= N_("E837: This Vim cannot execute :py3 after using :python")); -#ifdef FEAT_NETBEANS_INTG +#endif +#if defined(FEAT_NETBEANS_INTG) && defined(FEAT_GUI) EXTERN char e_netbeans_is_not_supported_with_this_GUI[] INIT(= N_("E838: netbeans is not supported with this GUI")); #endif @@ -1977,20 +2150,26 @@ EXTERN char e_reserved_name_cannot_be_used_for_user_defined_command[] INIT(= N_("E841: Reserved name, cannot be used for user defined command")); EXTERN char e_no_line_number_to_use_for_slnum[] INIT(= N_("E842: no line number to use for \"\"")); +#ifdef FEAT_CRYPT EXTERN char e_error_while_updating_swap_file_crypt[] INIT(= N_("E843: Error while updating swap file crypt")); +#endif +#ifdef FEAT_CONCEAL EXTERN char e_invalid_cchar_value[] INIT(= N_("E844: invalid cchar value")); +#endif #ifdef FEAT_SPELL EXTERN char e_insufficient_memory_word_list_will_be_incomplete[] INIT(= N_("E845: Insufficient memory, word list will be incomplete")); #endif EXTERN char e_key_code_not_set[] INIT(= N_("E846: Key code not set")); +#ifdef FEAT_SYN_HL EXTERN char e_too_many_syntax_includes[] INIT(= N_("E847: Too many syntax includes")); EXTERN char e_too_many_syntax_clusters[] INIT(= N_("E848: Too many syntax clusters")); +#endif EXTERN char e_too_many_highlight_and_syntax_groups[] INIT(= N_("E849: Too many highlight and syntax groups")); #ifndef FEAT_CLIPBOARD @@ -2003,8 +2182,10 @@ EXTERN char e_failed_to_create_new_process_for_GUI[] EXTERN char e_the_child_process_failed_to_start_GUI[] INIT(= N_("E852: The child process failed to start the GUI")); #endif +#ifdef FEAT_EVAL EXTERN char e_duplicate_argument_name_str[] INIT(= N_("E853: Duplicate argument name: %s")); +#endif EXTERN char e_path_too_long_for_completion[] INIT(= N_("E854: path too long for completion")); EXTERN char e_autocommands_caused_command_to_abort[] @@ -2021,14 +2202,22 @@ EXTERN char e_eval_did_not_return_valid_python_object[] EXTERN char e_failed_to_convert_returned_python_object_to_vim_value[] INIT(= N_("E859: Failed to convert returned python object to a Vim value")); #endif +#ifdef FEAT_PROP_POPUP EXTERN char e_need_id_and_type_with_both[] INIT(= N_("E860: Need 'id' and 'type' with 'both'")); +# ifdef FEAT_TERMINAL EXTERN char e_cannot_open_second_popup_with_terminal[] INIT(= N_("E861: Cannot open a second popup with a terminal")); +# endif +#endif +#ifdef FEAT_EVAL EXTERN char e_cannot_use_g_here[] INIT(= N_("E862: Cannot use g: here")); +#endif +#if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL) EXTERN char e_not_allowed_for_terminal_in_popup_window[] INIT(= N_("E863: Not allowed for a terminal in a popup window")); +#endif EXTERN char e_percent_hash_can_only_be_followed_by_zero_one_two_automatic_engine_will_be_used[] INIT(= N_("E864: \\%#= can only be followed by 0, 1, or 2. The automatic engine will be used")); EXTERN char e_nfa_regexp_end_encountered_prematurely[] @@ -2061,24 +2250,32 @@ EXTERN char e_nfa_regexp_invalid_character_class_nr[] INIT(= N_("E877: (NFA regexp) Invalid character class: %d")); EXTERN char e_nfa_regexp_could_not_allocate_memory_for_branch_traversal[] INIT(= N_("E878: (NFA regexp) Could not allocate memory for branch traversal!")); +#ifdef FEAT_SYN_HL EXTERN char e_nfa_regexp_too_many_z[] INIT(= N_("E879: (NFA regexp) Too many \\z(")); +#endif #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) EXTERN char e_cant_handle_systemexit_of_python_exception_in_vim[] INIT(= N_("E880: Can't handle SystemExit of python exception in vim")); #endif EXTERN char e_line_count_changed_unexpectedly[] INIT(= N_("E881: Line count changed unexpectedly")); +#ifdef FEAT_EVAL EXTERN char e_uniq_compare_function_failed[] INIT(= N_("E882: Uniq compare function failed")); EXTERN char e_search_pattern_and_expression_register_may_not_contain_two_or_more_lines[] INIT(= N_("E883: search pattern and expression register may not contain two or more lines")); EXTERN char e_function_name_cannot_contain_colon_str[] INIT(= N_("E884: Function name cannot contain a colon: %s")); +#endif +#ifdef FEAT_SIGNS EXTERN char e_not_possible_to_change_sign_str[] INIT(= N_("E885: Not possible to change sign %s")); +#endif +#ifdef FEAT_VIMINFO EXTERN char e_cant_rename_viminfo_file_to_str[] INIT(= N_("E886: Can't rename viminfo file to %s!")); +#endif EXTERN char e_sorry_this_command_is_disabled_python_side_module_could_not_be_loaded[] INIT(= N_("E887: Sorry, this command is disabled, the Python's site module could not be loaded.")); EXTERN char e_nfa_regexp_cannot_repeat_str[] @@ -2087,8 +2284,10 @@ EXTERN char e_nfa_regexp_cannot_repeat_str[] EXTERN char e_number_required[] INIT(= N_("E889: Number required")); #endif +#ifdef FEAT_SYN_HL EXTERN char e_trailing_char_after_rsb_str_str[] INIT(= N_("E890: trailing char after ']': %s]%s")); +#endif #ifdef FEAT_FLOAT EXTERN char e_using_funcref_as_float[] INIT(= N_("E891: Using a Funcref as a Float")); @@ -2109,17 +2308,23 @@ EXTERN char e_argument_of_str_must_be_list_dictionary_or_blob[] EXTERN char e_list_or_blob_required[] INIT(= N_("E897: List or Blob required")); #endif +#ifdef FEAT_JOB_CHANNEL EXTERN char e_socket_in_channel_connect[] INIT(= N_("E898: socket() in channel_connect()")); +#endif +#ifdef FEAT_EVAL EXTERN char e_argument_of_str_must_be_list_or_blob[] INIT(= N_("E899: Argument of %s must be a List or Blob")); EXTERN char e_maxdepth_must_be_non_negative_number[] INIT(= N_("E900: maxdepth must be non-negative number")); +#endif #ifdef FEAT_JOB_CHANNEL EXTERN char e_getaddrinfo_in_channel_open_str[] INIT(= N_("E901: getaddrinfo() in channel_open(): %s")); +# ifndef FEAT_IPV6 EXTERN char e_gethostbyname_in_channel_open[] INIT(= N_("E901: gethostbyname() in channel_open()")); +# endif EXTERN char e_cannot_connect_to_port[] INIT(= N_("E902: Cannot connect to port")); EXTERN char e_received_command_with_non_string_argument[] @@ -2154,42 +2359,53 @@ EXTERN char e_using_channel_as_number[] INIT(= N_("E913: Using a Channel as a Number")); EXTERN char e_using_channel_as_float[] INIT(= N_("E914: Using a Channel as a Float")); -#endif EXTERN char e_in_io_buffer_requires_in_buf_or_in_name_to_be_set[] INIT(= N_("E915: in_io buffer requires in_buf or in_name to be set")); - EXTERN char e_not_valid_job[] INIT(= N_("E916: not a valid job")); EXTERN char e_cannot_use_callback_with_str[] INIT(= N_("E917: Cannot use a callback with %s()")); EXTERN char e_buffer_must_be_loaded_str[] INIT(= N_("E918: buffer must be loaded: %s")); +#endif EXTERN char e_directory_not_found_in_str_str[] INIT(= N_("E919: Directory not found in '%s': \"%s\"")); +#ifdef FEAT_JOB_CHANNEL EXTERN char e_io_file_requires_name_to_be_set[] INIT(= N_("E920: _io file requires _name to be set")); +#endif +#ifdef FEAT_EVAL EXTERN char e_invalid_callback_argument[] INIT(= N_("E921: Invalid callback argument")); EXTERN char e_expected_dict[] INIT(= N_("E922: expected a dict")); EXTERN char e_second_argument_of_function_must_be_list_or_dict[] INIT(= N_("E923: Second argument of function() must be a list or a dict")); +#endif +#ifdef FEAT_QUICKFIX EXTERN char e_current_window_was_closed[] INIT(= N_("E924: Current window was closed")); EXTERN char e_current_quickfix_list_was_changed[] INIT(= N_("E925: Current quickfix list was changed")); EXTERN char e_current_location_list_was_changed[] INIT(= N_("E926: Current location list was changed")); +#endif +#ifdef FEAT_EVAL +# ifdef FEAT_QUICKFIX EXTERN char e_invalid_action_str_1[] INIT(= N_("E927: Invalid action: '%s'")); -#ifdef FEAT_EVAL +# endif EXTERN char e_string_required[] INIT(= N_("E928: String required")); #endif +#ifdef FEAT_VIMINFO EXTERN char e_too_many_viminfo_temp_files_like_str[] INIT(= N_("E929: Too many viminfo temp files, like %s!")); +#endif +#ifdef FEAT_EVAL EXTERN char e_cannot_use_redir_inside_execute[] INIT(= N_("E930: Cannot use :redir inside execute()")); +#endif EXTERN char e_buffer_cannot_be_registered[] INIT(= N_("E931: Buffer cannot be registered")); #ifdef FEAT_EVAL @@ -2198,35 +2414,44 @@ EXTERN char e_closure_function_should_not_be_at_top_level[] EXTERN char e_function_was_deleted_str[] INIT(= N_("E933: Function was deleted: %s")); #endif +#ifdef FEAT_SIGNS EXTERN char e_cannot_jump_to_buffer_that_does_not_have_name[] INIT(= N_("E934: Cannot jump to a buffer that does not have a name")); +#endif +#ifdef FEAT_EVAL EXTERN char e_invalid_submatch_number_nr[] INIT(= N_("E935: invalid submatch number: %d")); +#endif EXTERN char e_cannot_delete_current_group[] INIT(= N_("E936: Cannot delete the current group")); EXTERN char e_attempt_to_delete_buffer_that_is_in_use_str[] INIT(= N_("E937: Attempt to delete a buffer that is in use: %s")); +#ifdef FEAT_EVAL EXTERN char e_duplicate_key_in_json_str[] INIT(= N_("E938: Duplicate key in JSON: \"%s\"")); +#endif EXTERN char e_positive_count_required[] INIT(= N_("E939: Positive count required")); #ifdef FEAT_EVAL EXTERN char e_cannot_lock_or_unlock_variable_str[] INIT(= N_("E940: Cannot lock or unlock variable %s")); -#endif +# ifdef FEAT_CLIENTSERVER EXTERN char e_already_started_server[] INIT(= N_("E941: already started a server")); +# else EXTERN char e_clientserver_feature_not_available[] INIT(= N_("E942: +clientserver feature not available")); +# endif +#endif EXTERN char e_command_table_needs_to_be_updated_run_make_cmdidxs[] INIT(= N_("E943: Command table needs to be updated, run 'make cmdidxs'")); EXTERN char e_reverse_range_in_character_class[] INIT(= N_("E944: Reverse range in character class")); EXTERN char e_range_too_large_in_character_class[] INIT(= N_("E945: Range too large in character class")); +#ifdef FEAT_TERMINAL EXTERN char e_cannot_make_terminal_with_running_job_modifiable[] INIT(= N_("E946: Cannot make a terminal with running job modifiable")); -#ifdef FEAT_TERMINAL EXTERN char e_job_still_running_in_buffer_str[] INIT(= N_("E947: Job still running in buffer \"%s\"")); EXTERN char e_job_still_running[] @@ -2240,36 +2465,57 @@ EXTERN char e_cannot_convert_between_str_and_str[] INIT(= N_("E950: Cannot convert between %s and %s")); EXTERN char e_percent_value_too_large[] INIT(= N_("E951: \\% value too large")); +#if defined(FEAT_EVAL) && defined(FEAT_QUICKFIX) EXTERN char e_autocommand_caused_recursive_behavior[] INIT(= N_("E952: Autocommand caused recursive behavior")); +#endif +#ifdef FEAT_TERMINAL EXTERN char e_file_exists_str[] INIT(= N_("E953: File exists: %s")); +#endif +#if defined(FEAT_TERMGUICOLORS) && defined(FEAT_VTP) EXTERN char e_24_bit_colors_are_not_supported_on_this_environment[] INIT(= N_("E954: 24-bit colors are not supported on this environment")); +#endif +#ifdef FEAT_TERMINAL EXTERN char e_not_terminal_buffer[] INIT(= N_("E955: Not a terminal buffer")); +#endif EXTERN char e_cannot_use_pattern_recursively[] INIT(= N_("E956: Cannot use pattern recursively")); +#ifdef FEAT_EVAL EXTERN char e_invalid_window_number[] INIT(= N_("E957: Invalid window number")); +#endif +#ifdef FEAT_TERMINAL EXTERN char e_job_already_finished[] INIT(= N_("E958: Job already finished")); +#endif +#ifdef FEAT_DIFF EXTERN char e_invalid_diff_format[] INIT(= N_("E959: Invalid diff format.")); EXTERN char e_problem_creating_internal_diff[] INIT(= N_("E960: Problem creating the internal diff")); +#endif +#ifdef FEAT_EVAL EXTERN char e_no_line_number_to_use_for_sflnum[] INIT(= N_("E961: no line number to use for \"\"")); EXTERN char e_invalid_action_str_2[] INIT(= N_("E962: Invalid action: '%s'")); EXTERN char e_setting_str_to_value_with_wrong_type[] INIT(= N_("E963: setting %s to value with wrong type")); +#endif +#ifdef FEAT_PROP_POPUP EXTERN char_u e_invalid_column_number_nr[] INIT(= N_("E964: Invalid column number: %ld")); EXTERN char e_missing_property_type_name[] INIT(= N_("E965: missing property type name")); +#endif +#ifdef FEAT_EVAL EXTERN char_u e_invalid_line_number_nr[] INIT(= N_("E966: Invalid line number: %ld")); +#endif +#ifdef FEAT_PROP_POPUP EXTERN char e_text_property_info_corrupted[] INIT(= N_("E967: text property info corrupted")); EXTERN char e_need_at_least_one_of_id_or_type[] @@ -2280,30 +2526,37 @@ EXTERN char e_unknown_highlight_group_name_str[] INIT(= N_("E970: Unknown highlight group name: '%s'")); EXTERN char e_type_not_exist[] INIT(= N_("E971: Property type %s does not exist")); +#endif +#ifdef FEAT_EVAL EXTERN char e_blob_value_does_not_have_right_number_of_bytes[] INIT(= N_("E972: Blob value does not have the right number of bytes")); EXTERN char e_blob_literal_should_have_an_even_number_of_hex_characters[] INIT(= N_("E973: Blob literal should have an even number of hex characters")); EXTERN char e_using_blob_as_number[] INIT(= N_("E974: Using a Blob as a Number")); +# ifdef FEAT_FLOAT EXTERN char e_using_blob_as_float[] INIT(= N_("E975: Using a Blob as a Float")); +# endif EXTERN char e_using_blob_as_string[] INIT(= N_("E976: Using a Blob as a String")); EXTERN char e_can_only_compare_blob_with_blob[] INIT(= N_("E977: Can only compare Blob with Blob")); -#ifdef FEAT_EVAL EXTERN char e_invalid_operation_for_blob[] INIT(= N_("E978: Invalid operation for Blob")); EXTERN char e_blob_index_out_of_range_nr[] INIT(= N_("E979: Blob index out of range: %ld")); -#endif +# ifndef USE_INPUT_BUF EXTERN char e_lowlevel_input_not_supported[] INIT(= N_("E980: lowlevel input not supported")); +# endif +#endif EXTERN char e_command_not_allowed_in_rvim[] INIT(= N_("E981: Command not allowed in rvim")); +#if defined(FEAT_TERMINAL) && defined(MSWIN) EXTERN char e_conpty_is_not_available[] INIT(= N_("E982: ConPTY is not available")); +#endif EXTERN char e_duplicate_argument_str[] INIT(= N_("E983: Duplicate argument: %s")); EXTERN char e_scriptversion_used_outside_of_sourced_file[] @@ -2316,11 +2569,13 @@ EXTERN char e_cannot_modify_tag_stack_within_tagfunc[] EXTERN char e_invalid_return_value_from_tagfunc[] INIT(= N_("E987: invalid return value from tagfunc")); #endif +#ifdef GUI_MAY_SPAWN EXTERN char e_gui_cannot_be_used_cannot_execute_gvim_exe[] INIT(= N_("E988: GUI cannot be used. Cannot execute gvim.exe.")); +#endif +#ifdef FEAT_EVAL EXTERN char e_non_default_argument_follows_default_argument[] INIT(= N_("E989: Non-default argument follows default argument")); -#ifdef FEAT_EVAL EXTERN char e_missing_end_marker_str[] INIT(= N_("E990: Missing end marker '%s'")); EXTERN char e_cannot_use_heredoc_here[] @@ -2346,8 +2601,10 @@ EXTERN char e_cannot_lock_environment_variable[] EXTERN char e_cannot_lock_register[] INIT(= N_("E996: Cannot lock a register")); #endif +#ifdef FEAT_PROP_POPUP EXTERN char e_tabpage_not_found_nr[] INIT(= N_("E997: Tabpage not found: %d")); +#endif #ifdef FEAT_EVAL EXTERN char e_reduce_of_an_empty_str_with_no_initial_value[] INIT(= N_("E998: Reduce of an empty %s with no initial value")); @@ -2454,10 +2711,6 @@ EXTERN char e_invalid_command_after_export[] INIT(= N_("E1043: Invalid command after :export")); EXTERN char e_export_with_invalid_argument[] INIT(= N_("E1044: Export with invalid argument")); -EXTERN char e_missing_as_after_star[] - INIT(= N_("E1045: Missing \"as\" after *")); -EXTERN char e_missing_comma_in_import[] - INIT(= N_("E1046: Missing comma in import")); EXTERN char e_syntax_error_in_import_str[] INIT(= N_("E1047: Syntax error in import: %s")); EXTERN char e_item_not_found_in_script_str[] @@ -2505,8 +2758,6 @@ EXTERN char e_no_white_space_allowed_before_str_str[] INIT(= N_("E1068: No white space allowed before '%s': %s")); EXTERN char e_white_space_required_after_str_str[] INIT(= N_("E1069: White space required after '%s': %s")); -EXTERN char e_missing_from[] - INIT(= N_("E1070: Missing \"from\"")); EXTERN char e_invalid_string_for_import_str[] INIT(= N_("E1071: Invalid string for :import: %s")); EXTERN char e_cannot_compare_str_with_str[] @@ -2517,8 +2768,10 @@ EXTERN char e_no_white_space_allowed_after_dot[] INIT(= N_("E1074: No white space allowed after dot")); EXTERN char e_namespace_not_supported_str[] INIT(= N_("E1075: Namespace not supported: %s")); +#ifndef FEAT_FLOAT EXTERN char e_this_vim_is_not_compiled_with_float_support[] INIT(= N_("E1076: This Vim is not compiled with float support")); +#endif EXTERN char e_missing_argument_type_for_str[] INIT(= N_("E1077: Missing argument type for %s")); // E1078 unused @@ -2526,8 +2779,6 @@ EXTERN char e_missing_argument_type_for_str[] // E1080 unused EXTERN char e_cannot_unlet_str[] INIT(= N_("E1081: Cannot unlet %s")); -EXTERN char e_cannot_use_namespaced_variable[] - INIT(= N_("E1082: Cannot use a namespaced variable: %s")); EXTERN char e_missing_backtick[] INIT(= N_("E1083: Missing backtick")); EXTERN char e_cannot_delete_vim9_script_function_str[] @@ -2560,10 +2811,8 @@ EXTERN char e_string_list_or_blob_required[] INIT(= N_("E1098: String, List or Blob required")); EXTERN char e_unknown_error_while_executing_str[] INIT(= N_("E1099: Unknown error while executing %s")); -#endif EXTERN char e_command_not_supported_in_vim9_script_missing_var_str[] INIT(= N_("E1100: Command not supported in Vim9 script (missing :var?): %s")); -#ifdef FEAT_EVAL EXTERN char e_cannot_declare_script_variable_in_function[] INIT(= N_("E1101: Cannot declare a script variable in a function: %s")); EXTERN char e_lambda_function_not_found_str[] @@ -2641,6 +2890,7 @@ EXTERN char e_cmd_mapping_must_end_with_cr_before_second_cmd[] INIT(= N_("E1136: mapping must end with before second ")); EXTERN char e_cmd_maping_must_not_include_str_key[] INIT(= N_("E1137: mapping must not include %s key")); +#ifdef FEAT_EVAL EXTERN char e_using_bool_as_number[] INIT(= N_("E1138: Using a Bool as a Number")); EXTERN char e_missing_matching_bracket_after_dict_key[] @@ -2649,8 +2899,6 @@ EXTERN char e_for_argument_must_be_sequence_of_lists[] INIT(= N_("E1140: :for argument must be a sequence of lists")); EXTERN char e_indexable_type_required[] INIT(= N_("E1141: Indexable type required")); -EXTERN char e_non_empty_string_required[] - INIT(= N_("E1142: Non-empty string required")); EXTERN char e_empty_expression_str[] INIT(= N_("E1143: Empty expression: \"%s\"")); EXTERN char e_command_str_not_followed_by_white_space_str[] @@ -2675,16 +2923,20 @@ EXTERN char e_invalid_operation_for_str[] INIT(= N_("E1153: Invalid operation for %s")); EXTERN char e_divide_by_zero[] INIT(= N_("E1154: Divide by zero")); +#endif EXTERN char e_cannot_define_autocommands_for_all_events[] INIT(= N_("E1155: Cannot define autocommands for ALL events")); EXTERN char e_cannot_change_arglist_recursively[] INIT(= N_("E1156: Cannot change the argument list recursively")); +#ifdef FEAT_EVAL EXTERN char e_missing_return_type[] INIT(= N_("E1157: Missing return type")); EXTERN char e_cannot_use_flatten_in_vim9_script[] INIT(= N_("E1158: Cannot use flatten() in Vim9 script")); +#endif EXTERN char e_cannot_split_window_when_closing_buffer[] INIT(= N_("E1159: Cannot split a window when closing the buffer")); +#ifdef FEAT_EVAL EXTERN char e_cannot_use_default_for_variable_arguments[] INIT(= N_("E1160: Cannot use a default for variable arguments")); EXTERN char e_cannot_json_encode_str[] @@ -2695,8 +2947,10 @@ EXTERN char e_variable_nr_type_mismatch_expected_str_but_got_str[] INIT(= N_("E1163: Variable %d: type mismatch, expected %s but got %s")); EXTERN char e_variable_nr_type_mismatch_expected_str_but_got_str_in_str[] INIT(= N_("E1163: Variable %d: type mismatch, expected %s but got %s in %s")); +#endif EXTERN char e_vim9cmd_must_be_followed_by_command[] INIT(= N_("E1164: vim9cmd must be followed by a command")); +#ifdef FEAT_EVAL EXTERN char e_cannot_use_range_with_assignment_str[] INIT(= N_("E1165: Cannot use a range with an assignment: %s")); EXTERN char e_cannot_use_range_with_dictionary[] @@ -2725,8 +2979,12 @@ EXTERN char e_for_loop_on_str_not_supported[] INIT(= N_("E1177: For loop on %s not supported")); EXTERN char e_cannot_lock_unlock_local_variable[] INIT(= N_("E1178: Cannot lock or unlock a local variable")); +#endif +#ifdef FEAT_TERMINAL EXTERN char e_failed_to_extract_pwd_from_str_check_your_shell_config[] INIT(= N_("E1179: Failed to extract PWD from %s, check your shell's config related to OSC 7")); +#endif +#ifdef FEAT_EVAL EXTERN char e_variable_arguments_type_must_be_list_str[] INIT(= N_("E1180: Variable arguments type must be a list: %s")); EXTERN char e_cannot_use_underscore_here[] @@ -2735,6 +2993,8 @@ EXTERN char e_blob_required[] INIT(= N_("E1182: Blob required")); EXTERN char e_cannot_use_range_with_assignment_operator_str[] INIT(= N_("E1183: Cannot use a range with an assignment operator: %s")); +#endif +#ifdef FEAT_EVAL EXTERN char e_blob_not_set[] INIT(= N_("E1184: Blob not set")); EXTERN char e_cannot_nest_redir[] @@ -2743,10 +3003,14 @@ EXTERN char e_missing_redir_end[] INIT(= N_("E1185: Missing :redir END")); EXTERN char e_expression_does_not_result_in_value_str[] INIT(= N_("E1186: Expression does not result in a value: %s")); +#endif EXTERN char e_failed_to_source_defaults[] INIT(= N_("E1187: Failed to source defaults.vim")); +#if defined(FEAT_TERMINAL) && defined(FEAT_CMDWIN) EXTERN char e_cannot_open_terminal_from_command_line_window[] INIT(= N_("E1188: Cannot open a terminal from the command line window")); +#endif +#ifdef FEAT_EVAL EXTERN char e_cannot_use_legacy_with_command_str[] INIT(= N_("E1189: Cannot use :legacy with this command: %s")); EXTERN char e_one_argument_too_few[] @@ -2757,39 +3021,54 @@ EXTERN char e_call_to_function_that_failed_to_compile_str[] INIT(= N_("E1191: Call to function that failed to compile: %s")); EXTERN char e_empty_function_name[] INIT(= N_("E1192: Empty function name")); +#endif // libsodium +#ifdef FEAT_CRYPT +# ifndef FEAT_SODIUM EXTERN char e_libsodium_not_built_in[] INIT(= N_("E1193: cryptmethod xchacha20 not built into this Vim")); +# else +# if 0 EXTERN char e_libsodium_cannot_encrypt_header[] INIT(= N_("E1194: Cannot encrypt header, not enough space")); EXTERN char e_libsodium_cannot_encrypt_buffer[] INIT(= N_("E1195: Cannot encrypt buffer, not enough space")); EXTERN char e_libsodium_cannot_decrypt_header[] INIT(= N_("E1196: Cannot decrypt header, not enough space")); +# endif EXTERN char e_libsodium_cannot_allocate_buffer[] INIT(= N_("E1197: Cannot allocate_buffer for encryption")); EXTERN char e_libsodium_decryption_failed_header_incomplete[] INIT(= N_("E1198: Decryption failed: Header incomplete!")); +# if 0 EXTERN char e_libsodium_cannot_decrypt_buffer[] INIT(= N_("E1199: Cannot decrypt buffer, not enough space")); +# endif EXTERN char e_libsodium_decryption_failed[] INIT(= N_("E1200: Decryption failed!")); EXTERN char e_libsodium_decryption_failed_premature[] INIT(= N_("E1201: Decryption failed: pre-mature end of file!")); +# endif +#endif +#ifdef FEAT_EVAL EXTERN char e_no_white_space_allowed_after_str_str[] INIT(= N_("E1202: No white space allowed after '%s': %s")); EXTERN char e_dot_can_only_be_used_on_dictionary_str[] INIT(= N_("E1203: Dot can only be used on a dictionary: %s")); +#endif EXTERN char e_regexp_number_after_dot_pos_search[] INIT(= N_("E1204: No Number allowed after .: '\\%%%c'")); EXTERN char e_no_white_space_allowed_between_option_and[] INIT(= N_("E1205: No white space allowed between option and")); +#ifdef FEAT_EVAL EXTERN char e_dict_required_for_argument_nr[] INIT(= N_("E1206: Dictionary required for argument %d")); EXTERN char e_expression_without_effect_str[] INIT(= N_("E1207: Expression without an effect: %s")); +#endif EXTERN char e_complete_used_without_allowing_arguments[] INIT(= N_("E1208: -complete used without allowing arguments")); +#ifdef FEAT_EVAL EXTERN char e_invalid_value_for_line_number_str[] INIT(= N_("E1209: Invalid value for a line number: \"%s\"")); EXTERN char e_number_required_for_argument_nr[] @@ -2800,6 +3079,7 @@ EXTERN char e_bool_required_for_argument_nr[] INIT(= N_("E1212: Bool required for argument %d")); EXTERN char e_redefining_imported_item_str[] INIT(= N_("E1213: Redefining imported item \"%s\"")); +#endif #if defined(FEAT_DIGRAPHS) && defined(FEAT_EVAL) EXTERN char e_digraph_must_be_just_two_characters_str[] INIT(= N_("E1214: Digraph must be just two characters: %s")); @@ -2808,6 +3088,7 @@ EXTERN char e_digraph_argument_must_be_one_character_str[] EXTERN char e_digraph_setlist_argument_must_be_list_of_lists_with_two_items[] INIT(= N_("E1216: digraph_setlist() argument must be a list of lists with two items")); #endif +#ifdef FEAT_EVAL EXTERN char e_chan_or_job_required_for_argument_nr[] INIT(= N_("E1217: Channel or Job required for argument %d")); EXTERN char e_job_required_for_argument_nr[] @@ -2834,46 +3115,66 @@ EXTERN char e_list_dict_or_blob_required_for_argument_nr[] INIT(= N_("E1228: List, Dictionary or Blob required for argument %d")); EXTERN char e_expected_dictionary_for_using_key_str_but_got_str[] INIT(= N_("E1229: Expected dictionary for using key \"%s\", but got %s")); +#endif +#ifdef FEAT_SODIUM EXTERN char e_encryption_sodium_mlock_failed[] INIT(= N_("E1230: Encryption: sodium_mlock() failed")); +#endif EXTERN char e_cannot_use_bar_to_separate_commands_here_str[] INIT(= N_("E1231: Cannot use a bar to separate commands here: %s")); +#ifdef FEAT_EVAL EXTERN char e_argument_of_exists_compiled_must_be_literal_string[] INIT(= N_("E1232: Argument of exists_compiled() must be a literal string")); EXTERN char e_exists_compiled_can_only_be_used_in_def_function[] INIT(= N_("E1233: exists_compiled() can only be used in a :def function")); +#endif EXTERN char e_legacy_must_be_followed_by_command[] INIT(= N_("E1234: legacy must be followed by a command")); +#ifdef FEAT_EVAL EXTERN char e_function_reference_is_not_set[] INIT(= N_("E1235: Function reference is not set")); EXTERN char e_cannot_use_str_itself_it_is_imported[] INIT(= N_("E1236: Cannot use %s itself, it is imported")); +#endif EXTERN char e_no_such_user_defined_command_in_current_buffer_str[] INIT(= N_("E1237: No such user-defined command in current buffer: %s")); +#ifdef FEAT_EVAL EXTERN char e_blob_required_for_argument_nr[] INIT(= N_("E1238: Blob required for argument %d")); EXTERN char e_invalid_value_for_blob_nr[] INIT(= N_("E1239: Invalid value for blob: %d")); +#endif EXTERN char e_resulting_text_too_long[] INIT(= N_("E1240: Resulting text too long")); +#ifdef FEAT_EVAL EXTERN char e_separator_not_supported_str[] INIT(= N_("E1241: Separator not supported: %s")); EXTERN char e_no_white_space_allowed_before_separator_str[] INIT(= N_("E1242: No white space allowed before separator: %s")); +#endif +#ifdef FEAT_GUI_GTK EXTERN char e_ascii_code_not_in_range[] INIT(= N_("E1243: ASCII code not in 32-127 range")); +#endif +#ifdef FEAT_EVAL +# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) EXTERN char e_bad_color_string_str[] INIT(= N_("E1244: Bad color string: %s")); +# endif EXTERN char e_cannot_expand_sfile_in_vim9_function[] INIT(= N_("E1245: Cannot expand in a Vim9 function")); EXTERN char e_cannot_find_variable_to_unlock_str[] INIT(= N_("E1246: Cannot find variable to (un)lock: %s")); +#endif EXTERN char e_line_number_out_of_range[] INIT(= N_("E1247: Line number out of range")); +#ifdef FEAT_EVAL EXTERN char e_closure_called_from_invalid_context[] INIT(= N_("E1248: Closure called from invalid context")); +#endif EXTERN char e_highlight_group_name_too_long[] INIT(= N_("E1249: Highlight group name too long")); +#ifdef FEAT_EVAL EXTERN char e_argument_of_str_must_be_list_string_dictionary_or_blob[] INIT(= N_("E1250: Argument of %s must be a List, String, Dictionary or Blob")); EXTERN char e_list_dict_blob_or_string_required_for_argument_nr[] @@ -2884,8 +3185,10 @@ EXTERN char e_string_expected_for_argument_nr[] INIT(= N_("E1253: String expected for argument %d")); EXTERN char e_cannot_use_script_variable_in_for_loop[] INIT(= N_("E1254: Cannot use script variable in for loop")); +#endif EXTERN char e_cmd_mapping_must_end_with_cr[] INIT(= N_("E1255: mapping must end with ")); +#ifdef FEAT_EVAL EXTERN char e_string_or_function_required_for_argument_nr[] INIT(= N_("E1256: String or function required for argument %d")); EXTERN char e_imported_script_must_use_as_or_end_in_dot_vim_str[] @@ -2900,3 +3203,4 @@ EXTERN char e_cannot_import_dot_vim_without_using_as[] INIT(= N_("E1261: Cannot import .vim without using \"as\"")); EXTERN char e_cannot_import_same_script_twice_str[] INIT(= N_("E1262: Cannot import the same script twice: %s")); +#endif diff --git a/src/version.c b/src/version.c index f2845e2106..f33796393d 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4047, /**/ 4046, /**/ From c14f667626ba677a767d474324306e39096dc43e Mon Sep 17 00:00:00 2001 From: Dominique Pelle Date: Sun, 9 Jan 2022 12:57:48 +0000 Subject: [PATCH 26/28] patch 8.2.4048: gcc complains about use of "%p" in printf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: gcc complains about use of "%p" in printf. Solution: Add (void *) typecast. (Dominique PellĂ©, closes #9494) --- src/if_py_both.h | 12 ++++++------ src/version.c | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/if_py_both.h b/src/if_py_both.h index 8e349c55f8..6d7b9687ac 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -3789,14 +3789,14 @@ TabPageAttr(TabPageObject *self, char *name) TabPageRepr(TabPageObject *self) { if (self->tab == INVALID_TABPAGE_VALUE) - return PyString_FromFormat("", (self)); + return PyString_FromFormat("", (void *)self); else { int t = get_tab_number(self->tab); if (t == 0) return PyString_FromFormat("", - (self)); + (void *)self); else return PyString_FromFormat("", t - 1); } @@ -4125,14 +4125,14 @@ WindowSetattr(WindowObject *self, char *name, PyObject *valObject) WindowRepr(WindowObject *self) { if (self->win == INVALID_WINDOW_VALUE) - return PyString_FromFormat("", (self)); + return PyString_FromFormat("", (void *)self); else { int w = get_win_number(self->win, firstwin); if (w == 0) return PyString_FromFormat("", - (self)); + (void *)self); else return PyString_FromFormat("", w - 1); } @@ -5126,7 +5126,7 @@ RangeRepr(RangeObject *self) { if (self->buf->buf == INVALID_BUFFER_VALUE) return PyString_FromFormat("", - (self)); + (void *)self); else { char *name = (char *)self->buf->buf->b_fname; @@ -5378,7 +5378,7 @@ BufferRange(BufferObject *self, PyObject *args) BufferRepr(BufferObject *self) { if (self->buf == INVALID_BUFFER_VALUE) - return PyString_FromFormat("", self); + return PyString_FromFormat("", (void *)self); else { char *name = (char *)self->buf->b_fname; diff --git a/src/version.c b/src/version.c index f33796393d..be49f09e2b 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4048, /**/ 4047, /**/ From 5f25c3855071bd7e26255c68bf458b1b5cf92f39 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 9 Jan 2022 13:36:28 +0000 Subject: [PATCH 27/28] patch 8.2.4049: Vim9: reading before the start of the line with "$" Problem: Vim9: reading before the start of the line with "$" by itself. Solution: Do not subtract one when reporting the error. --- src/testdir/test_vim9_expr.vim | 1 + src/version.c | 2 ++ src/vim9expr.c | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index 01b4538508..52237e33fd 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -2853,6 +2853,7 @@ def Test_expr7_environment() CheckDefAndScriptSuccess(lines) CheckDefAndScriptFailure(["var x = $$$"], ['E1002:', 'E15:'], 1) + CheckDefAndScriptFailure(["$"], ['E1002:', 'E15:'], 1) enddef def Test_expr7_register() diff --git a/src/version.c b/src/version.c index be49f09e2b..cf0665c02c 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4049, /**/ 4048, /**/ diff --git a/src/vim9expr.c b/src/vim9expr.c index 83c68a9ffa..edaee50997 100644 --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -1233,7 +1233,7 @@ compile_get_env(char_u **arg, cctx_T *cctx) len = get_env_len(arg); if (len == 0) { - semsg(_(e_syntax_error_at_str), start - 1); + semsg(_(e_syntax_error_at_str), start); return FAIL; } From dc4451df61a6aa12a0661817b7094fb32f09e11d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 9 Jan 2022 21:36:37 +0000 Subject: [PATCH 28/28] patch 8.2.4050: Vim9: need to prefix every item in an autoload script Problem: Vim9: need to prefix every item in an autoload script. Solution: First step in supporting "vim9script autoload" and "import autoload". --- runtime/doc/repeat.txt | 3 +- runtime/doc/vim9.txt | 46 +++--- src/errors.h | 4 + src/eval.c | 4 +- src/evalvars.c | 6 +- src/proto/scriptfile.pro | 3 + src/proto/vim9compile.pro | 2 +- src/scriptfile.c | 276 ++++++++++++++++++++++++------- src/structs.h | 5 +- src/testdir/test_vim9_script.vim | 20 +++ src/userfunc.c | 7 +- src/version.c | 2 + src/vim9compile.c | 27 ++- src/vim9expr.c | 5 +- src/vim9script.c | 109 +++++++++--- 15 files changed, 402 insertions(+), 117 deletions(-) diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 25f375e6fc..407c23c239 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -365,11 +365,12 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. Vim version, or update Vim to a newer version. See |vimscript-version| for what changed between versions. -:vim9s[cript] [noclear] *:vim9s* *:vim9script* +:vim9s[cript] [noclear] [autoload] *:vim9s* *:vim9script* Marks a script file as containing |Vim9-script| commands. Also see |vim9-namespace|. Must be the first command in the file. For [noclear] see |vim9-reload|. + For [autoload] see |vim9-autoload|. Without the |+eval| feature this changes the syntax for some commands. See |:vim9cmd| for executing one command with Vim9 diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt index 0af6dff33d..8942466e39 100644 --- a/runtime/doc/vim9.txt +++ b/runtime/doc/vim9.txt @@ -1501,37 +1501,43 @@ result in undefined items. Import in an autoload script ~ - + *vim9-autoload* For optimal startup speed, loading scripts should be postponed until they are -actually needed. A recommended mechanism: +actually needed. Using the autoload mechanism is recommended: 1. In the plugin define user commands, functions and/or mappings that refer to - an autoload script. > - command -nargs=1 SearchForStuff searchfor#Stuff() + items imported from an autoload script. > + import autoload 'for/search.vim' + command -nargs=1 SearchForStuff search.Stuff() < This goes in .../plugin/anyname.vim. "anyname.vim" can be freely chosen. + The "SearchForStuff" command is now available to the user. -2. In the autoload script do the actual work. You can import items from - other files to split up functionality in appropriate pieces. > - vim9script - import "../import/someother.vim" as other - def searchfor#Stuff(arg: string) - var filtered = other.FilterFunc(arg) + The "autoload" argument to `:import` means that the script is not loaded + until one of the items is actually used. The script will be found under + the "autoload" directory in 'runtimepath' instead of the "import" + directory. + +2. In the autoload script put the bulk of the code. > + vim9script autoload + export def Stuff(arg: string) ... -< This goes in .../autoload/searchfor.vim. "searchfor" in the file name - must be exactly the same as the prefix for the function name, that is how - Vim finds the file. -3. Other functionality, possibly shared between plugins, contains the exported - items and any private items. > - vim9script - var localVar = 'local' - export def FilterFunc(arg: string): string - ... -< This goes in .../import/someother.vim. +< This goes in .../autoload/for/search.vim. + + Adding "autoload" to `:vim9script` has the effect that "for#search#" will + be prefixed to every exported item. The prefix is obtained from the file + name, as you would to manually in a legacy autoload script. Thus the + exported function can be found with "for#search#Stuff", but you would + normally use `import autoload` and not need to specify the prefix. + + You can split up the functionality and import other scripts from the + autoload script as you like. This way you can share code between plugins. When compiling a `:def` function and a function in an autoload script is encountered, the script is not loaded until the `:def` function is called. +This also means you get any errors only at runtime, since the argument and +return types are not known yet. Import in legacy Vim script ~ diff --git a/src/errors.h b/src/errors.h index d30b4b0f02..7059b28da3 100644 --- a/src/errors.h +++ b/src/errors.h @@ -3203,4 +3203,8 @@ EXTERN char e_cannot_import_dot_vim_without_using_as[] INIT(= N_("E1261: Cannot import .vim without using \"as\"")); EXTERN char e_cannot_import_same_script_twice_str[] INIT(= N_("E1262: Cannot import the same script twice: %s")); +EXTERN char e_using_autoload_in_script_not_under_autoload_directory[] + INIT(= N_("E1263: Using autoload in a script not under an autoload directory")); +EXTERN char e_autoload_import_cannot_use_absolute_or_relative_path[] + INIT(= N_("E1264: Autoload import cannot use absolute or relative path: %s")); #endif diff --git a/src/eval.c b/src/eval.c index 390bb58110..7a23876f9a 100644 --- a/src/eval.c +++ b/src/eval.c @@ -886,7 +886,9 @@ get_lval( if (*p == '.' && in_vim9script()) { - imported_T *import = find_imported(lp->ll_name, p - lp->ll_name, NULL); + imported_T *import = find_imported(lp->ll_name, p - lp->ll_name, + TRUE, NULL); + if (import != NULL) { ufunc_T *ufunc; diff --git a/src/evalvars.c b/src/evalvars.c index d93fed5b0e..1d5aedf4cc 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -2683,7 +2683,7 @@ eval_variable( char_u *p = STRNCMP(name, "s:", 2) == 0 ? name + 2 : name; if (sid == 0) - import = find_imported(p, 0, NULL); + import = find_imported(p, 0, TRUE, NULL); // imported variable from another script if (import != NULL || sid != 0) @@ -3015,7 +3015,7 @@ lookup_scriptitem( res = HASHITEM_EMPTY(hi) ? FAIL : OK; // if not script-local, then perhaps imported - if (res == FAIL && find_imported(p, 0, NULL) != NULL) + if (res == FAIL && find_imported(p, 0, FALSE, NULL) != NULL) res = OK; if (p != buffer) vim_free(p); @@ -3388,7 +3388,7 @@ set_var_const( if (di == NULL && var_in_vim9script) { - imported_T *import = find_imported(varname, 0, NULL); + imported_T *import = find_imported(varname, 0, FALSE, NULL); if (import != NULL) { diff --git a/src/proto/scriptfile.pro b/src/proto/scriptfile.pro index cbb9253c52..140d67bbbd 100644 --- a/src/proto/scriptfile.pro +++ b/src/proto/scriptfile.pro @@ -10,6 +10,7 @@ int do_in_path(char_u *path, char_u *name, int flags, void (*callback)(char_u *f int do_in_runtimepath(char_u *name, int flags, void (*callback)(char_u *fname, void *ck), void *cookie); int source_runtime(char_u *name, int flags); int source_in_path(char_u *path, char_u *name, int flags, int *ret_sid); +int find_script_in_rtp(char_u *name); void add_pack_start_dirs(void); void load_start_packages(void); void ex_packloadall(exarg_T *eap); @@ -36,6 +37,8 @@ void ex_scriptversion(exarg_T *eap); void ex_finish(exarg_T *eap); void do_finish(exarg_T *eap, int reanimate); int source_finished(char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie); +char_u *script_name_after_autoload(scriptitem_T *si); +char_u *may_prefix_autoload(char_u *name); char_u *autoload_name(char_u *name); int script_autoload(char_u *name, int reload); /* vim: set ft=c : */ diff --git a/src/proto/vim9compile.pro b/src/proto/vim9compile.pro index 98c40c86cb..cb95fdfb6b 100644 --- a/src/proto/vim9compile.pro +++ b/src/proto/vim9compile.pro @@ -7,7 +7,7 @@ int check_defined(char_u *p, size_t len, cctx_T *cctx, int is_arg); int need_type(type_T *actual, type_T *expected, int offset, int arg_idx, cctx_T *cctx, int silent, int actual_is_const); lvar_T *reserve_local(cctx_T *cctx, char_u *name, size_t len, int isConst, type_T *type); int get_script_item_idx(int sid, char_u *name, int check_writable, cctx_T *cctx); -imported_T *find_imported(char_u *name, size_t len, cctx_T *cctx); +imported_T *find_imported(char_u *name, size_t len, int load, cctx_T *cctx); char_u *may_peek_next_line(cctx_T *cctx, char_u *arg, char_u **nextp); char_u *peek_next_line_from_context(cctx_T *cctx); char_u *next_line_from_context(cctx_T *cctx, int skip_comment); diff --git a/src/scriptfile.c b/src/scriptfile.c index c10a82f2cb..c1ab41503f 100644 --- a/src/scriptfile.c +++ b/src/scriptfile.c @@ -239,6 +239,102 @@ source_callback(char_u *fname, void *cookie) (void)do_source(fname, FALSE, DOSO_NONE, cookie); } +#ifdef FEAT_EVAL +/* + * Find an already loaded script "name". + * If found returns its script ID. If not found returns -1. + */ + static int +find_script_by_name(char_u *name) +{ + int sid; + scriptitem_T *si; + + for (sid = script_items.ga_len; sid > 0; --sid) + { + // We used to check inode here, but that doesn't work: + // - If a script is edited and written, it may get a different + // inode number, even though to the user it is the same script. + // - If a script is deleted and another script is written, with a + // different name, the inode may be re-used. + si = SCRIPT_ITEM(sid); + if (si->sn_name != NULL && fnamecmp(si->sn_name, name) == 0) + return sid; + } + return -1; +} + +/* + * Add a new scriptitem with all items initialized. + * When running out of memory "error" is set to FAIL. + * Returns the script ID. + */ + static int +get_new_scriptitem(int *error) +{ + static scid_T last_current_SID = 0; + int sid = ++last_current_SID; + scriptitem_T *si; + + if (ga_grow(&script_items, (int)(sid - script_items.ga_len)) == FAIL) + { + *error = FAIL; + return sid; + } + while (script_items.ga_len < sid) + { + si = ALLOC_CLEAR_ONE(scriptitem_T); + if (si == NULL) + { + *error = FAIL; + return sid; + } + ++script_items.ga_len; + SCRIPT_ITEM(script_items.ga_len) = si; + si->sn_name = NULL; + si->sn_version = 1; + + // Allocate the local script variables to use for this script. + new_script_vars(script_items.ga_len); + ga_init2(&si->sn_var_vals, sizeof(svar_T), 10); + hash_init(&si->sn_all_vars.dv_hashtab); + ga_init2(&si->sn_imports, sizeof(imported_T), 10); + ga_init2(&si->sn_type_list, sizeof(type_T), 10); +# ifdef FEAT_PROFILE + si->sn_prof_on = FALSE; +# endif + } + + // Used to check script variable index is still valid. + si->sn_script_seq = current_sctx.sc_seq; + + return sid; +} + + static void +find_script_callback(char_u *fname, void *cookie) +{ + int sid; + int error = OK; + int *ret_sid = cookie; + + sid = find_script_by_name(fname); + if (sid < 0) + { + // script does not exist yet, create a new scriptitem + sid = get_new_scriptitem(&error); + if (error == OK) + { + scriptitem_T *si = SCRIPT_ITEM(sid); + + si->sn_name = vim_strsave(fname); + si->sn_state = SN_STATE_NOT_LOADED; + } + } + *ret_sid = sid; +} +#endif + /* * Find the file "name" in all directories in "path" and invoke * "callback(fname, cookie)". @@ -455,7 +551,8 @@ source_runtime(char_u *name, int flags) } /* - * Just like source_runtime(), but use "path" instead of 'runtimepath'. + * Just like source_runtime(), but use "path" instead of 'runtimepath' + * and return the script ID in "ret_sid". */ int source_in_path(char_u *path, char_u *name, int flags, int *ret_sid) @@ -463,9 +560,23 @@ source_in_path(char_u *path, char_u *name, int flags, int *ret_sid) return do_in_path_and_pp(path, name, flags, source_callback, ret_sid); } - #if defined(FEAT_EVAL) || defined(PROTO) +/* + * Find "name" in 'runtimepath'. If found a new scriptitem is created for it + * and it's script ID is returned. + * If not found returns -1. + */ + int +find_script_in_rtp(char_u *name) +{ + int sid = -1; + + (void)do_in_path_and_pp(p_rtp, name, DIP_NOAFTER, + find_script_callback, &sid); + return sid; +} + /* * Expand wildcards in "pat" and invoke do_source() for each match. */ @@ -1127,7 +1238,6 @@ do_source( int retval = FAIL; sctx_T save_current_sctx; #ifdef FEAT_EVAL - static scid_T last_current_SID = 0; static int last_current_SID_seq = 0; funccal_entry_T funccalp_entry; int save_debug_break_level = debug_break_level; @@ -1161,18 +1271,7 @@ do_source( estack_compiling = FALSE; // See if we loaded this script before. - for (sid = script_items.ga_len; sid > 0; --sid) - { - // We used to check inode here, but that doesn't work: - // - If a script is edited and written, it may get a different - // inode number, even though to the user it is the same script. - // - If a script is deleted and another script is written, with a - // different name, the inode may be re-used. - si = SCRIPT_ITEM(sid); - if (si->sn_name != NULL && fnamecmp(si->sn_name, fname_exp) == 0) - // Found it! - break; - } + sid = find_script_by_name(fname_exp); if (sid > 0 && ret_sid != NULL) { // Already loaded and no need to load again, return here. @@ -1318,54 +1417,44 @@ do_source( dictitem_T *di; // loading the same script again - si->sn_state = SN_STATE_RELOAD; current_sctx.sc_sid = sid; + si = SCRIPT_ITEM(sid); + if (si->sn_state == SN_STATE_NOT_LOADED) + { + // this script was found but not loaded yet + si->sn_state = SN_STATE_NEW; + } + else + { + si->sn_state = SN_STATE_RELOAD; - // Script-local variables remain but "const" can be set again. - // In Vim9 script variables will be cleared when "vim9script" is - // encountered without the "noclear" argument. - ht = &SCRIPT_VARS(sid); - todo = (int)ht->ht_used; - for (hi = ht->ht_array; todo > 0; ++hi) - if (!HASHITEM_EMPTY(hi)) - { - --todo; - di = HI2DI(hi); - di->di_flags |= DI_FLAGS_RELOAD; - } - // imports can be redefined once - mark_imports_for_reload(sid); + // Script-local variables remain but "const" can be set again. + // In Vim9 script variables will be cleared when "vim9script" is + // encountered without the "noclear" argument. + ht = &SCRIPT_VARS(sid); + todo = (int)ht->ht_used; + for (hi = ht->ht_array; todo > 0; ++hi) + if (!HASHITEM_EMPTY(hi)) + { + --todo; + di = HI2DI(hi); + di->di_flags |= DI_FLAGS_RELOAD; + } + // imports can be redefined once + mark_imports_for_reload(sid); - // reset version, "vim9script" may have been added or removed. - si->sn_version = 1; + // reset version, "vim9script" may have been added or removed. + si->sn_version = 1; + } } else { - // It's new, generate a new SID. - current_sctx.sc_sid = ++last_current_SID; - if (ga_grow(&script_items, - (int)(current_sctx.sc_sid - script_items.ga_len)) == FAIL) - goto almosttheend; - while (script_items.ga_len < current_sctx.sc_sid) - { - si = ALLOC_CLEAR_ONE(scriptitem_T); - if (si == NULL) - goto almosttheend; - ++script_items.ga_len; - SCRIPT_ITEM(script_items.ga_len) = si; - si->sn_name = NULL; - si->sn_version = 1; + int error = OK; - // Allocate the local script variables to use for this script. - new_script_vars(script_items.ga_len); - ga_init2(&si->sn_var_vals, sizeof(svar_T), 10); - hash_init(&si->sn_all_vars.dv_hashtab); - ga_init2(&si->sn_imports, sizeof(imported_T), 10); - ga_init2(&si->sn_type_list, sizeof(type_T), 10); -# ifdef FEAT_PROFILE - si->sn_prof_on = FALSE; -# endif - } + // It's new, generate a new SID and initialize the scriptitem. + current_sctx.sc_sid = get_new_scriptitem(&error); + if (error == FAIL) + goto almosttheend; si = SCRIPT_ITEM(current_sctx.sc_sid); si->sn_name = fname_exp; fname_exp = vim_strsave(si->sn_name); // used for autocmd @@ -1374,9 +1463,6 @@ do_source( // Remember the "is_vimrc" flag for when the file is sourced again. si->sn_is_vimrc = is_vimrc; - - // Used to check script variable index is still valid. - si->sn_script_seq = current_sctx.sc_seq; } # ifdef FEAT_PROFILE @@ -2030,6 +2116,78 @@ source_finished( fgetline, cookie))->finished); } +/* + * Find the path of a script below the "autoload" directory. + * Returns NULL if there is no "/autoload/" in the script name. + */ + char_u * +script_name_after_autoload(scriptitem_T *si) +{ + char_u *p = si->sn_name; + char_u *res = NULL; + + for (;;) + { + char_u *n = (char_u *)strstr((char *)p, "autoload"); + + if (n == NULL) + break; + if (n > p && vim_ispathsep(n[-1]) && vim_ispathsep(n[8])) + res = n + 9; + p = n + 8; + } + return res; +} + +/* + * If in a Vim9 autoload script return "name" with the autoload prefix for the + * script. If successful "name" is freed, the returned name is allocated. + * Otherwise it returns "name" unmodified. + */ + char_u * +may_prefix_autoload(char_u *name) +{ + if (SCRIPT_ID_VALID(current_sctx.sc_sid)) + { + scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid); + + if (si->sn_is_autoload) + { + char_u *p = script_name_after_autoload(si); + + if (p != NULL) + { + char_u *tail = vim_strsave(p); + + if (tail != NULL) + { + for (p = tail; *p != NUL; p += mb_ptr2len(p)) + { + if (vim_ispathsep(*p)) + *p = '#'; + else if (STRCMP(p, ".vim")) + { + size_t len = (p - tail) + STRLEN(name) + 2; + char_u *res = alloc(len); + + if (res == NULL) + break; + *p = NUL; + vim_snprintf((char *)res, len, "%s#%s", tail, name); + vim_free(name); + vim_free(tail); + return res; + } + } + } + // did not find ".vim" at the end + vim_free(tail); + } + } + } + return name; +} + /* * Return the autoload script name for a function or variable name. * Returns NULL when out of memory. diff --git a/src/structs.h b/src/structs.h index 9d5768175f..fd4be4fe95 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1827,6 +1827,7 @@ typedef struct { } imported_T; #define IMP_FLAGS_RELOAD 2 // script reloaded, OK to redefine +#define IMP_FLAGS_AUTOLOAD 4 // script still needs to be loaded /* * Info about an already sourced scripts. @@ -1863,6 +1864,7 @@ typedef struct int sn_state; // SN_STATE_ values char_u *sn_save_cpo; // 'cpo' value when :vim9script found char sn_is_vimrc; // .vimrc file, do not restore 'cpo' + char sn_is_autoload; // "vim9script autoload" # ifdef FEAT_PROFILE int sn_prof_on; // TRUE when script is/was profiled @@ -1886,7 +1888,8 @@ typedef struct } scriptitem_T; #define SN_STATE_NEW 0 // newly loaded script, nothing done -#define SN_STATE_RELOAD 1 // script loaded before, nothing done +#define SN_STATE_NOT_LOADED 1 // script located but not loaded +#define SN_STATE_RELOAD 2 // script loaded before, nothing done #define SN_STATE_HAD_COMMAND 9 // a command was executed // Struct passed through eval() functions. diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 8c7f85f167..97a51a51c6 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -3032,6 +3032,26 @@ def Test_vim9_autoload() writefile(lines, 'Xdir/autoload/Other.vim') assert_equal('other', g:Other#getOther()) + # using "vim9script autoload" prefix is not needed + lines =<< trim END + vim9script autoload + g:prefixed_loaded = 'yes' + export def Gettest(): string + return 'test' + enddef + export var name = 'name' + END + writefile(lines, 'Xdir/autoload/prefixed.vim') + + lines =<< trim END + vim9script + import autoload 'prefixed.vim' + assert_false(exists('g:prefixed_loaded')) + assert_equal('test', prefixed.Gettest()) + assert_equal('yes', g:prefixed_loaded) + END + CheckScriptSuccess(lines) + delete('Xdir', 'rf') &rtp = save_rtp enddef diff --git a/src/userfunc.c b/src/userfunc.c index b772913f15..ecd2e7c1ad 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -1608,7 +1608,7 @@ deref_func_name( p = name + 2; len -= 2; } - import = find_imported(p, len, NULL); + import = find_imported(p, len, FALSE, NULL); // imported function from another script if (import != NULL) @@ -4079,6 +4079,9 @@ define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free) else eap->skip = TRUE; } + +// if (is_export) +// name = may_prefix_autoload(name); } // An error in a function call during evaluation of an expression in magic @@ -4363,7 +4366,7 @@ define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free) { char_u *uname = untrans_function_name(name); - import = find_imported(uname == NULL ? name : uname, 0, NULL); + import = find_imported(uname == NULL ? name : uname, 0, FALSE, NULL); } if (fp != NULL || import != NULL) diff --git a/src/version.c b/src/version.c index cf0665c02c..a2ce58e4b4 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4050, /**/ 4049, /**/ diff --git a/src/vim9compile.c b/src/vim9compile.c index 11e3226451..993bb1c68d 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -268,7 +268,7 @@ variable_exists(char_u *name, size_t len, cctx_T *cctx) && (lookup_local(name, len, NULL, cctx) == OK || arg_exists(name, len, NULL, NULL, NULL, cctx) == OK)) || script_var_exists(name, len, cctx) == OK - || find_imported(name, len, cctx) != NULL; + || find_imported(name, len, FALSE, cctx) != NULL; } /* @@ -331,7 +331,7 @@ check_defined(char_u *p, size_t len, cctx_T *cctx, int is_arg) if ((cctx != NULL && (lookup_local(p, len, NULL, cctx) == OK || arg_exists(p, len, NULL, NULL, NULL, cctx) == OK)) - || find_imported(p, len, cctx) != NULL + || find_imported(p, len, FALSE, cctx) != NULL || (ufunc = find_func_even_dead(p, FALSE, cctx)) != NULL) { // A local or script-local function can shadow a global function. @@ -581,11 +581,13 @@ find_imported_in_script(char_u *name, size_t len, int sid) /* * Find "name" in imported items of the current script or in "cctx" if not * NULL. + * If "load" is TRUE and the script was not loaded yet, load it now. */ imported_T * -find_imported(char_u *name, size_t len, cctx_T *cctx) +find_imported(char_u *name, size_t len, int load, cctx_T *cctx) { int idx; + imported_T *ret = NULL; if (!SCRIPT_ID_VALID(current_sctx.sc_sid)) return NULL; @@ -598,10 +600,23 @@ find_imported(char_u *name, size_t len, cctx_T *cctx) if (len == 0 ? STRCMP(name, import->imp_name) == 0 : STRLEN(import->imp_name) == len && STRNCMP(name, import->imp_name, len) == 0) - return import; + { + ret = import; + break; + } } - return find_imported_in_script(name, len, current_sctx.sc_sid); + if (ret == NULL) + ret = find_imported_in_script(name, len, current_sctx.sc_sid); + + if (ret != NULL && load && ret->imp_flags == IMP_FLAGS_AUTOLOAD) + { + // script found before but not loaded yet + ret->imp_flags = 0; + (void)do_source(SCRIPT_ITEM(ret->imp_sid)->sn_name, FALSE, + DOSO_NONE, NULL); + } + return ret; } /* @@ -1326,7 +1341,7 @@ compile_lhs( : script_var_exists(var_start, lhs->lhs_varlen, cctx)) == OK; imported_T *import = - find_imported(var_start, lhs->lhs_varlen, cctx); + find_imported(var_start, lhs->lhs_varlen, FALSE, cctx); if (script_namespace || script_var || import != NULL) { diff --git a/src/vim9expr.c b/src/vim9expr.c index edaee50997..f12acf65a2 100644 --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -266,7 +266,7 @@ compile_load_scriptvar( return OK; } - import = end == NULL ? NULL : find_imported(name, 0, cctx); + import = end == NULL ? NULL : find_imported(name, 0, FALSE, cctx); if (import != NULL) { char_u *p = skipwhite(*end); @@ -275,6 +275,7 @@ compile_load_scriptvar( ufunc_T *ufunc; type_T *type; + // TODO: if this is an autoload import do something else. // Need to lookup the member. if (*p != '.') { @@ -474,7 +475,7 @@ compile_load( // "var" can be script-local even without using "s:" if it // already exists in a Vim9 script or when it's imported. if (script_var_exists(*arg, len, cctx) == OK - || find_imported(name, 0, cctx) != NULL) + || find_imported(name, 0, FALSE, cctx) != NULL) res = compile_load_scriptvar(cctx, name, *arg, &end, FALSE); // When evaluating an expression and the name starts with an diff --git a/src/vim9script.c b/src/vim9script.c index 3ebeab366a..a8b76bb6c4 100644 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -68,6 +68,9 @@ ex_vim9script(exarg_T *eap UNUSED) #ifdef FEAT_EVAL int sid = current_sctx.sc_sid; scriptitem_T *si; + int found_noclear = FALSE; + int found_autoload = FALSE; + char_u *p; if (!getline_equal(eap->getline, eap->cookie, getsourceline)) { @@ -81,12 +84,40 @@ ex_vim9script(exarg_T *eap UNUSED) emsg(_(e_vim9script_must_be_first_command_in_script)); return; } - if (!IS_WHITE_OR_NUL(*eap->arg) && STRCMP(eap->arg, "noclear") != 0) + + for (p = eap->arg; !IS_WHITE_OR_NUL(*p); p = skipwhite(skiptowhite(p))) { - semsg(_(e_invalid_argument_str), eap->arg); - return; + if (STRNCMP(p, "noclear", 7) == 0 && IS_WHITE_OR_NUL(p[7])) + { + if (found_noclear) + { + semsg(_(e_duplicate_argument_str), p); + return; + } + found_noclear = TRUE; + } + else if (STRNCMP(p, "autoload", 8) == 0 && IS_WHITE_OR_NUL(p[8])) + { + if (found_autoload) + { + semsg(_(e_duplicate_argument_str), p); + return; + } + found_autoload = TRUE; + if (script_name_after_autoload(si) == NULL) + { + emsg(_(e_using_autoload_in_script_not_under_autoload_directory)); + return; + } + } + else + { + semsg(_(e_invalid_argument_str), eap->arg); + return; + } } - if (si->sn_state == SN_STATE_RELOAD && IS_WHITE_OR_NUL(*eap->arg)) + + if (si->sn_state == SN_STATE_RELOAD && !found_noclear) { hashtab_T *ht = &SCRIPT_VARS(sid); @@ -101,6 +132,8 @@ ex_vim9script(exarg_T *eap UNUSED) } si->sn_state = SN_STATE_HAD_COMMAND; + si->sn_is_autoload = found_autoload; + current_sctx.sc_version = SCRIPT_VERSION_VIM9; si->sn_version = SCRIPT_VERSION_VIM9; @@ -366,6 +399,7 @@ handle_import( { char_u *arg = arg_start; char_u *nextarg; + int is_autoload = FALSE; int getnext; char_u *expr_end; int ret = FAIL; @@ -377,6 +411,12 @@ handle_import( garray_T *import_gap; int i; + if (STRNCMP(arg, "autoload", 8) == 0 && VIM_ISWHITE(arg[8])) + { + is_autoload = TRUE; + arg = skipwhite(arg + 8); + } + // The name of the file can be an expression, which must evaluate to a // string. ret = eval0_retarg(arg, &tv, NULL, evalarg, &expr_end); @@ -402,23 +442,48 @@ handle_import( char_u *tail = gettail(si->sn_name); char_u *from_name; - // Relative to current script: "./name.vim", "../../name.vim". - len = STRLEN(si->sn_name) - STRLEN(tail) + STRLEN(tv.vval.v_string) + 2; - from_name = alloc((int)len); - if (from_name == NULL) - goto erret; - vim_strncpy(from_name, si->sn_name, tail - si->sn_name); - add_pathsep(from_name); - STRCAT(from_name, tv.vval.v_string); - simplify_filename(from_name); + if (is_autoload) + res = FAIL; + else + { - res = do_source(from_name, FALSE, DOSO_NONE, &sid); - vim_free(from_name); + // Relative to current script: "./name.vim", "../../name.vim". + len = STRLEN(si->sn_name) - STRLEN(tail) + + STRLEN(tv.vval.v_string) + 2; + from_name = alloc((int)len); + if (from_name == NULL) + goto erret; + vim_strncpy(from_name, si->sn_name, tail - si->sn_name); + add_pathsep(from_name); + STRCAT(from_name, tv.vval.v_string); + simplify_filename(from_name); + + res = do_source(from_name, FALSE, DOSO_NONE, &sid); + vim_free(from_name); + } } else if (mch_isFullName(tv.vval.v_string)) { // Absolute path: "/tmp/name.vim" - res = do_source(tv.vval.v_string, FALSE, DOSO_NONE, &sid); + if (is_autoload) + res = FAIL; + else + res = do_source(tv.vval.v_string, FALSE, DOSO_NONE, &sid); + } + else if (is_autoload) + { + size_t len = 9 + STRLEN(tv.vval.v_string) + 1; + char_u *from_name; + + // Find file in "autoload" subdirs in 'runtimepath'. + from_name = alloc((int)len); + if (from_name == NULL) + goto erret; + vim_snprintf((char *)from_name, len, "autoload/%s", tv.vval.v_string); + // we need a scriptitem without loading the script + sid = find_script_in_rtp(from_name); + vim_free(from_name); + res = SCRIPT_ID_VALID(sid) ? OK : FAIL; } else { @@ -428,9 +493,7 @@ handle_import( // Find file in "import" subdirs in 'runtimepath'. from_name = alloc((int)len); if (from_name == NULL) - { goto erret; - } vim_snprintf((char *)from_name, len, "import/%s", tv.vval.v_string); res = source_in_path(p_rtp, from_name, DIP_NOAFTER, &sid); vim_free(from_name); @@ -438,7 +501,9 @@ handle_import( if (res == FAIL || sid <= 0) { - semsg(_(e_could_not_import_str), tv.vval.v_string); + semsg(_(is_autoload && sid <= 0 + ? e_autoload_import_cannot_use_absolute_or_relative_path + : e_could_not_import_str), tv.vval.v_string); goto erret; } @@ -451,7 +516,7 @@ handle_import( { if (import->imp_flags & IMP_FLAGS_RELOAD) { - // encountering same script first ime on a reload is OK + // encountering same script first time on a reload is OK import->imp_flags &= ~IMP_FLAGS_RELOAD; break; } @@ -513,7 +578,7 @@ handle_import( { imported_T *imported; - imported = find_imported(as_name, STRLEN(as_name), cctx); + imported = find_imported(as_name, FALSE, STRLEN(as_name), cctx); if (imported != NULL && imported->imp_sid != sid) { semsg(_(e_name_already_defined_str), as_name); @@ -529,6 +594,8 @@ handle_import( imported->imp_name = as_name; as_name = NULL; imported->imp_sid = sid; + if (is_autoload) + imported->imp_flags = IMP_FLAGS_AUTOLOAD; } erret: