Compare commits

...

10 Commits

Author SHA1 Message Date
Bram Moolenaar
6e371ecb27 patch 8.2.3787: no proper formatting of a C line comment after a statement
Problem:    No proper formatting of a C line comment after a statement.
Solution:   Find the start of the line comment, insert the comment leader and
            indent the comment properly.
2021-12-12 14:16:39 +00:00
Bram Moolenaar
9a4ec5a626 Use text area for environment in the bug template. 2021-12-12 11:44:11 +00:00
Bram Moolenaar
4e30b5c3bc Update issue template. 2021-12-12 11:34:22 +00:00
Bram Moolenaar
4f16e9de98 patch 8.2.3786: test fails because of using Vim9 syntax in legacy function
Problem:    Test fails because of using Vim9 syntax in legacy function.
Solution:   Add "call".
2021-12-11 18:46:29 +00:00
ichizok
48c0196378 patch 8.2.3785: running CI on MacOS with gcc is not useful
Problem:    Running CI on MacOS with gcc is not useful.
Solution:   Only use clang. (Ozaki Kiichi, closes #9326)  Also build with
            normal features.
2021-12-11 17:34:19 +00:00
Bram Moolenaar
7b1463bca3 patch 8.2.3784: the help for options is outdated
Problem:    The help for options is outdated.
Solution:   Include all the recent changes.
2021-12-11 17:24:39 +00:00
Bram Moolenaar
2ef9156b42 patch 8.2.3783: confusing error for using a variable as a function
Problem:    Confusing error for using a variable as a function.
Solution:   If a function is not found but there is a variable, give a more
            useful error. (issue #9310)
2021-12-11 16:14:07 +00:00
Bram Moolenaar
052ff291d7 patch 8.2.3782: Vim9: no error if a function shadows a script variable
Problem:    Vim9: no error if a function shadows a script variable.
Solution:   Check the function doesn't shadow a variable. (closes #9310)
2021-12-11 13:54:46 +00:00
Bram Moolenaar
a416861c64 patch 8.2.3781: the option window script is outdated
Problem:    The option window script is outdated.
Solution:   Add several changes.
2021-12-11 12:33:52 +00:00
Bakudankun
29f3a45915 patch 8.2.3780: ":cd" works differently on MS-Windows
Problem:    ":cd" works differently on MS-Windows.
Solution:   Add the 'cdhome' option. (closes #9324)
2021-12-11 12:28:08 +00:00
32 changed files with 306 additions and 79 deletions

View File

@@ -26,18 +26,23 @@ body:
placeholder: A clear and concise description of what you expected to happen.
validations:
required: true
- type: input
attributes:
label: Operating system
description: >
Your operating system name, version and desktop environment.
validations:
required: true
- type: input
attributes:
label: Version of Vim
description: >
The name of your development environment, version. [e.g. GNOME Terminal (v0.0.0000)]
Including patch level, use ":version" to see it [e.g. 8.2.1234]
validations:
required: true
- type: textarea
attributes:
label: Environment
description: >
OS [e.g. Ubuntu 21.10], terminal [e.g. GNOME Terminal 3.38.1], value of $TERM, shell [e.g. bash 5.1.8]; anything that might matter
placeholder: |
Operating system:
Terminal:
Value of $TERM:
Shell:
validations:
required: true
- type: textarea

View File

@@ -255,7 +255,7 @@ jobs:
runs-on: macos-latest
env:
CC: ${{ matrix.compiler }}
CC: clang
TEST: test
SRCDIR: ./src
LEAK_CFLAGS: -DEXITFREE
@@ -264,8 +264,7 @@ jobs:
strategy:
fail-fast: false
matrix:
features: [tiny, huge]
compiler: [clang, gcc]
features: [tiny, normal, huge]
steps:
- uses: actions/checkout@v2
@@ -286,6 +285,8 @@ jobs:
echo "TEST=testtiny"
echo "CONFOPT=--disable-gui"
;;
normal)
;;
huge)
echo "CONFOPT=--enable-perlinterp --enable-python3interp --enable-rubyinterp --enable-luainterp --enable-tclinterp"
;;

View File

@@ -1298,11 +1298,12 @@ Changing directory fails when the current buffer is modified, the '.' flag is
present in 'cpoptions' and "!" is not used in the command.
*:cd* *E747* *E472*
:cd[!] On non-Unix systems: Print the current directory
name. On Unix systems: Change the current directory
to the home directory. Use |:pwd| to print the
current directory on all systems.
On Unix systems: clear any window-local directory.
:cd[!] On non-Unix systems when 'cdhome' is off: Print the
current directory name.
Otherwise: Change the current directory to the home
directory. Clear any window-local directory.
Use |:pwd| to print the current directory on all
systems.
:cd[!] {path} Change the current directory to {path}.
If {path} is relative, it is searched for in the

View File

@@ -1,4 +1,4 @@
*options.txt* For Vim version 8.2. Last change: 2021 Dec 03
*options.txt* For Vim version 8.2. Last change: 2021 Dec 11
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -391,7 +391,11 @@ lambda it will be converted to the name, e.g. "<lambda>123". Examples:
" set using a variable with lambda expression
let L = {a, b, c -> MyTagFunc(a, b , c)}
let &tagfunc = L
<
In Vim9 script, in a compiled function, you can use a lambda, but a
closured does not work, because the function will be called without the
context of where it was defined.
Setting the filetype
@@ -1489,6 +1493,15 @@ A jump table for the options with a short description can be found at |Q_op|.
case mapping, the current locale is not effective.
This probably only matters for Turkish.
*'cdhome'* *'cdh'*
'cdhome' 'cdh' boolean (default: off)
global
When on, |:cd|, |:tcd| and |:lcd| without an argument changes the
current working directory to the |$HOME| directory like in Unix.
When off, those commands just print the current directory name.
On Unix this option has no effect.
NOTE: This option is reset when 'compatible' is set.
*'cdpath'* *'cd'* *E344* *E346*
'cdpath' 'cd' string (default: equivalent to $CDPATH or ",,")
global
@@ -1830,6 +1843,7 @@ A jump table for the options with a short description can be found at |Q_op|.
'balloonexpr' + "" text to show in evaluation balloon
'breakindent' + off don't indent when wrapping lines
'cedit' - {unchanged} {set vim default only on resetting 'cp'}
'cdhome' + off ":cd" don't chdir to home on non-Unix
'cindent' + off no C code indentation
'compatible' - {unchanged} {set vim default only on resetting 'cp'}
'copyindent' + off don't copy indent structure

View File

@@ -635,6 +635,7 @@ Short explanation of each option: *option-list*
'buflisted' 'bl' whether the buffer shows up in the buffer list
'buftype' 'bt' special type of buffer
'casemap' 'cmp' specifies how case of letters is changed
'cdhome' 'cdh' change directory to the home directory by ":cd"
'cdpath' 'cd' list of directories searched with ":cd"
'cedit' key used to open the command-line window
'charconvert' 'ccv' expression for character encoding conversion

View File

@@ -1,7 +1,7 @@
" These commands create the option window.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2021 Oct 28
" Last Change: 2021 Dec 11
" If there already is an option window, jump to that one.
let buf = bufnr('option-window')
@@ -260,6 +260,10 @@ call <SID>OptionG("sect", &sect)
call <SID>AddOption("path", gettext("list of directory names used for file searching"))
call append("$", "\t" .. s:global_or_local)
call <SID>OptionG("pa", &pa)
if exists("+cdhome")
call <SID>AddOption("cdhome", gettext("change directory to the home directory by :cd"))
call <SID>BinOptionG("cdh", &cdh)
endif
call <SID>AddOption("cdpath", gettext("list of directory names used for :cd"))
call <SID>OptionG("cd", &cd)
if exists("+autochdir")

View File

@@ -1356,6 +1356,8 @@ del_bytes(
*
* "second_line_indent": indent for after ^^D in Insert mode or if flag
* OPENLINE_COM_LIST
* "did_do_comment" is set to TRUE when intentionally putting the comment
* leader in fromt of the new line.
*
* Return OK for success, FAIL for failure
*/
@@ -1363,7 +1365,8 @@ del_bytes(
open_line(
int dir, // FORWARD or BACKWARD
int flags,
int second_line_indent)
int second_line_indent,
int *did_do_comment UNUSED)
{
char_u *saved_line; // copy of the original line
char_u *next_line = NULL; // copy of the next line
@@ -1378,6 +1381,7 @@ open_line(
int retval = FAIL; // return value
int extra_len = 0; // length of p_extra string
int lead_len; // length of comment leader
int comment_start = 0; // start index of the comment leader
char_u *lead_flags; // position in 'comments' for comment leader
char_u *leader = NULL; // copy of comment leader
char_u *allocated = NULL; // allocated memory
@@ -1393,6 +1397,9 @@ open_line(
&& *curbuf->b_p_inde == NUL
# endif
);
#ifdef FEAT_CINDENT
int do_cindent;
#endif
int no_si = FALSE; // reset did_si afterwards
int first_char = NUL; // init for GCC
#endif
@@ -1632,12 +1639,43 @@ open_line(
did_ai = TRUE;
}
#ifdef FEAT_CINDENT
// May do indenting after opening a new line.
do_cindent = !p_paste && (curbuf->b_p_cin
# ifdef FEAT_EVAL
|| *curbuf->b_p_inde != NUL
# endif
)
&& in_cinkeys(dir == FORWARD
? KEY_OPEN_FORW
: KEY_OPEN_BACK, ' ', linewhite(curwin->w_cursor.lnum));
#endif
// Find out if the current line starts with a comment leader.
// This may then be inserted in front of the new line.
end_comment_pending = NUL;
if (flags & OPENLINE_DO_COM)
{
lead_len = get_leader_len(saved_line, &lead_flags,
dir == BACKWARD, TRUE);
#ifdef FEAT_CINDENT
if (lead_len == 0 && do_cindent)
{
comment_start = check_linecomment(saved_line);
if (comment_start != MAXCOL)
{
lead_len = get_leader_len(saved_line + comment_start,
&lead_flags, dir == BACKWARD, TRUE);
if (lead_len != 0)
{
lead_len += comment_start;
if (did_do_comment != NULL)
*did_do_comment = TRUE;
}
}
}
#endif
}
else
lead_len = 0;
if (lead_len > 0)
@@ -1799,8 +1837,15 @@ open_line(
lead_len = 0;
else
{
int li;
vim_strncpy(leader, saved_line, lead_len);
// TODO: handle multi-byte and double width chars
for (li = 0; li < comment_start; ++li)
if (!VIM_ISWHITE(leader[li]))
leader[li] = ' ';
// Replace leader with lead_repl, right or left adjusted
if (lead_repl != NULL)
{
@@ -2247,15 +2292,7 @@ open_line(
#endif
#ifdef FEAT_CINDENT
// May do indenting after opening a new line.
if (!p_paste
&& (curbuf->b_p_cin
# ifdef FEAT_EVAL
|| *curbuf->b_p_inde != NUL
# endif
)
&& in_cinkeys(dir == FORWARD
? KEY_OPEN_FORW
: KEY_OPEN_BACK, ' ', linewhite(curwin->w_cursor.lnum)))
if (do_cindent)
{
do_c_expr_indent();
ai_col = (colnr_T)getwhitecols_curline();

View File

@@ -2144,13 +2144,30 @@ get_c_indent(void)
// If we're inside a "//" comment and there is a "//" comment in a
// previous line, lineup with that one.
if (cin_islinecomment(theline)
&& (trypos = find_line_comment()) != NULL) // XXX
if (cin_islinecomment(theline))
{
// find how indented the line beginning the comment is
getvcol(curwin, trypos, &col, NULL, NULL);
amount = col;
goto theend;
pos_T linecomment_pos;
trypos = find_line_comment(); // XXX
if (trypos == NULL && curwin->w_cursor.lnum > 1)
{
// There may be a statement before the comment, search from the end
// of the line for a comment start.
linecomment_pos.col =
check_linecomment(ml_get(curwin->w_cursor.lnum - 1));
if (linecomment_pos.col != MAXCOL)
{
trypos = &linecomment_pos;
trypos->lnum = curwin->w_cursor.lnum - 1;
}
}
if (trypos != NULL)
{
// find how indented the line beginning the comment is
getvcol(curwin, trypos, &col, NULL, NULL);
amount = col;
goto theend;
}
}
// If we're inside a comment and not looking at the start of the

View File

@@ -5147,7 +5147,8 @@ ins_eol(int c)
AppendToRedobuff(NL_STR);
i = open_line(FORWARD,
has_format_option(FO_RET_COMS) ? OPENLINE_DO_COM : 0, old_indent);
has_format_option(FO_RET_COMS) ? OPENLINE_DO_COM : 0, old_indent,
NULL);
old_indent = 0;
#ifdef FEAT_CINDENT
can_cindent = TRUE;

View File

@@ -1988,6 +1988,7 @@ eval_func(
partial_T *partial;
int ret = OK;
type_T *type = NULL;
int found_var = FALSE;
if (!evaluate)
check_vars(s, len);
@@ -1995,7 +1996,7 @@ eval_func(
// If "s" is the name of a variable of type VAR_FUNC
// use its contents.
s = deref_func_name(s, &len, &partial,
in_vim9script() ? &type : NULL, !evaluate);
in_vim9script() ? &type : NULL, !evaluate, &found_var);
// Need to make a copy, in case evaluating the arguments makes
// the name invalid.
@@ -2014,6 +2015,7 @@ eval_func(
funcexe.partial = partial;
funcexe.basetv = basetv;
funcexe.check_type = type;
funcexe.fe_found_var = found_var;
ret = get_func_tv(s, len, rettv, arg, evalarg, &funcexe);
}
vim_free(s);

View File

@@ -2712,7 +2712,7 @@ eval_variable(
type = sv->sv_type;
}
}
else if (in_vim9script())
else if (in_vim9script() && (flags & EVAL_VAR_NO_FUNC) == 0)
{
ufunc_T *ufunc = find_func(name, FALSE, NULL);

View File

@@ -7402,9 +7402,13 @@ changedir_func(
else
prev_dir = pdir;
// For UNIX ":cd" means: go to home directory.
// On other systems too if 'cdhome' is set.
#if defined(UNIX) || defined(VMS)
// for UNIX ":cd" means: go to home directory
if (*new_dir == NUL)
#else
if (*new_dir == NUL && p_cdh)
#endif
{
// use NameBuff for home directory name
# ifdef VMS
@@ -7420,7 +7424,6 @@ changedir_func(
# endif
new_dir = NameBuff;
}
#endif
dir_differs = new_dir == NULL || pdir == NULL
|| pathcmp((char *)pdir, (char *)new_dir, -1) != 0;
if (new_dir == NULL || (dir_differs && vim_chdir(new_dir)))
@@ -7459,8 +7462,8 @@ ex_cd(exarg_T *eap)
new_dir = eap->arg;
#if !defined(UNIX) && !defined(VMS)
// for non-UNIX ":cd" means: print current directory
if (*new_dir == NUL)
// for non-UNIX ":cd" means: print current directory unless 'cdhome' is set
if (*new_dir == NUL && !p_cdh)
ex_pwd(NULL);
else
#endif

View File

@@ -6511,7 +6511,7 @@ n_opencmd(cmdarg_T *cap)
) == OK
&& open_line(cap->cmdchar == 'O' ? BACKWARD : FORWARD,
has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM : 0,
0) == OK)
0, NULL) == OK)
{
#ifdef FEAT_CONCEAL
if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum)

View File

@@ -1094,6 +1094,7 @@ EXTERN int p_write; // 'write'
EXTERN int p_wa; // 'writeany'
EXTERN int p_wb; // 'writebackup'
EXTERN long p_wd; // 'writedelay'
EXTERN int p_cdh; // 'cdhome'
/*
* "indir" values for buffer-local options.

View File

@@ -549,6 +549,10 @@ static struct vimoption options[] =
(char_u *)&p_cmp, PV_NONE,
{(char_u *)"internal,keepascii", (char_u *)0L}
SCTX_INIT},
{"cdhome", "cdh", P_BOOL|P_VI_DEF|P_VIM|P_SECURE,
(char_u *)&p_cdh, PV_NONE,
{(char_u *)FALSE, (char_u *)0L}
SCTX_INIT},
{"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE|P_COMMA|P_NODUP,
#ifdef FEAT_SEARCHPATH
(char_u *)&p_cdpath, PV_NONE,

View File

@@ -27,7 +27,7 @@ void ins_str(char_u *s);
int del_char(int fixpos);
int del_chars(long count, int fixpos);
int del_bytes(long count, int fixpos_arg, int use_delcombine);
int open_line(int dir, int flags, int second_line_indent);
int open_line(int dir, int flags, int second_line_indent, int *did_do_comment);
int truncate_line(int fixpos);
void del_lines(long nlines, int undo);
/* vim: set ft=c : */

View File

@@ -29,6 +29,7 @@ int search_for_exact_line(buf_T *buf, pos_T *pos, int dir, char_u *pat);
int searchc(cmdarg_T *cap, int t_cmd);
pos_T *findmatch(oparg_T *oap, int initc);
pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel);
int check_linecomment(char_u *line);
void showmatch(int c);
int current_search(long count, int forward);
int linewhite(linenr_T lnum);

View File

@@ -4,7 +4,7 @@ hashtab_T *func_tbl_get(void);
char_u *get_lambda_name(void);
char_u *register_cfunc(cfunc_T cb, cfunc_free_T cb_free, void *state);
int get_lambda_tv(char_u **arg, typval_T *rettv, int types_optional, evalarg_T *evalarg);
char_u *deref_func_name(char_u *name, int *lenp, partial_T **partialp, type_T **type, int no_autoload);
char_u *deref_func_name(char_u *name, int *lenp, partial_T **partialp, type_T **type, int no_autoload, int *found_var);
void emsg_funcname(char *ermsg, char_u *name);
int get_func_tv(char_u *name, int len, typval_T *rettv, char_u **arg, evalarg_T *evalarg, funcexe_T *funcexe);
char_u *fname_trans_sid(char_u *name, char_u *fname_buf, char_u **tofree, int *error);
@@ -30,7 +30,7 @@ int func_call(char_u *name, typval_T *args, partial_T *partial, dict_T *selfdict
int get_callback_depth(void);
int call_callback(callback_T *callback, int len, typval_T *rettv, int argcount, typval_T *argvars);
varnumber_T call_callback_retnr(callback_T *callback, int argcount, typval_T *argvars);
void user_func_error(int error, char_u *name);
void user_func_error(int error, char_u *name, funcexe_T *funcexe);
int call_func(char_u *funcname, int len, typval_T *rettv, int argcount_in, typval_T *argvars_in, funcexe_T *funcexe);
char_u *printable_func_name(ufunc_T *fp);
char_u *trans_function_name(char_u **pp, int *is_global, int skip, int flags, funcdict_T *fdp, partial_T **partial, type_T **type);

View File

@@ -16,7 +16,6 @@
static void set_vv_searchforward(void);
static int first_submatch(regmmatch_T *rp);
#endif
static int check_linecomment(char_u *line);
#ifdef FEAT_FIND_ID
static void show_pat_in_path(char_u *, int,
int, int, FILE *, linenr_T *, long);
@@ -2717,7 +2716,7 @@ findmatchlimit(
* Return MAXCOL if not, otherwise return the column.
* TODO: skip strings.
*/
static int
int
check_linecomment(char_u *line)
{
char_u *p;

View File

@@ -2001,6 +2001,8 @@ typedef struct {
dict_T *selfdict; // Dictionary for "self"
typval_T *basetv; // base for base->method()
type_T *check_type; // type from funcref or NULL
int fe_found_var; // if the function is not found then give an
// error that a variable is not callable.
} funcexe_T;
/*

View File

@@ -77,6 +77,9 @@ if has('reltime')
let s:start_time = reltime()
endif
" Always use forward slashes.
set shellslash
" Common with all tests on all systems.
source setup.vim
@@ -128,9 +131,6 @@ if has('gui_running') && exists('did_install_default_menus')
source $VIMRUNTIME/menu.vim
endif
" Always use forward slashes.
set shellslash
let s:srcdir = expand('%:p:h:h')
if has('win32')

View File

@@ -1694,9 +1694,9 @@ func Test_cindent_1()
#endif
int y; // comment
// comment
// comment
// comment
// comment
{
Constructor(int a,

View File

@@ -2234,6 +2234,12 @@ func Test_call()
call call(test_null_partial(), [])
call assert_fails('call test_null_function()()', 'E1192:')
call assert_fails('call test_null_partial()()', 'E117:')
let lines =<< trim END
let Time = 'localtime'
call Time()
END
call CheckScriptFailure(lines, 'E1085:')
endfunc
func Test_char2nr()

View File

@@ -1199,4 +1199,25 @@ func Test_opt_scrolljump()
bw
endfunc
" Test for the 'cdhome' option
func Test_opt_cdhome()
if has('unix') || has('vms')
throw 'Skipped: only works on non-Unix'
endif
set cdhome&
call assert_equal(0, &cdhome)
set cdhome
" This paragraph is copied from Test_cd_no_arg().
let path = getcwd()
cd
call assert_equal($HOME, getcwd())
call assert_notequal(path, getcwd())
exe 'cd ' .. fnameescape(path)
call assert_equal(path, getcwd())
set cdhome&
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -196,6 +196,36 @@ func Test_text_format()
enew!
endfunc
func Test_format_c_comment()
new
setl ai cindent tw=40 et fo=croql
let text =<< trim END
var = 2345; // asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf
END
call setline(1, text)
normal gql
let expected =<< trim END
var = 2345; // asdf asdf asdf asdf asdf
// asdf asdf asdf asdf asdf
END
call assert_equal(expected, getline(1, '$'))
%del
let text =<< trim END
var = 2345; // asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf
END
call setline(1, text)
normal gql
let expected =<< trim END
var = 2345; // asdf asdf asdf asdf asdf
// asdf asdf asdf asdf asdf
// asdf asdf
END
call assert_equal(expected, getline(1, '$'))
bwipe!
endfunc
" Tests for :right, :center and :left on text with embedded TAB.
func Test_format_align()
enew!

View File

@@ -1459,7 +1459,7 @@ endfunc
def Test_call_funcref()
g:SomeFunc('abc')->assert_equal(3)
assert_fails('NotAFunc()', 'E117:', '', 2, 'Test_call_funcref') # comment after call
assert_fails('g:NotAFunc()', 'E117:', '', 3, 'Test_call_funcref')
assert_fails('g:NotAFunc()', 'E1085:', '', 3, 'Test_call_funcref')
var lines =<< trim END
vim9script

View File

@@ -1896,6 +1896,17 @@ def Test_script_var_shadows_function()
CheckScriptFailure(lines, 'E1041:', 5)
enddef
def Test_function_shadows_script_var()
var lines =<< trim END
vim9script
var Func = 1
def Func(): number
return 123
enddef
END
CheckScriptFailure(lines, 'E1041:', 3)
enddef
def Test_script_var_shadows_command()
var lines =<< trim END
var undo = 1
@@ -1911,6 +1922,15 @@ def Test_script_var_shadows_command()
CheckDefAndScriptFailure(lines, 'E1207:', 2)
enddef
def Test_vim9script_call_wrong_type()
var lines =<< trim END
vim9script
var Time = 'localtime'
Time()
END
CheckScriptFailure(lines, 'E1085:')
enddef
def s:RetSome(): string
return 'some'
enddef
@@ -2198,7 +2218,7 @@ def Test_func_overrules_import_fails()
echo 'local to function'
enddef
END
CheckScriptFailure(lines, 'E1073:')
CheckScriptFailure(lines, 'E1041:')
lines =<< trim END
vim9script
@@ -2231,7 +2251,7 @@ def Test_func_redefine_fails()
vim9script
def Foo(): string
return 'foo'
enddef
enddef
def Func()
var Foo = {-> 'lambda'}
enddef

View File

@@ -89,6 +89,7 @@ internal_format(
colnr_T col;
colnr_T end_col;
int wcc; // counter for whitespace chars
int did_do_comment = FALSE;
virtcol = get_nolist_virtcol()
+ char2cells(c != NUL ? c : gchar_cursor());
@@ -352,10 +353,16 @@ internal_format(
+ (fo_white_par ? OPENLINE_KEEPTRAIL : 0)
+ (do_comments ? OPENLINE_DO_COM : 0)
+ ((flags & INSCHAR_COM_LIST) ? OPENLINE_COM_LIST : 0)
, ((flags & INSCHAR_COM_LIST) ? second_indent : old_indent));
, ((flags & INSCHAR_COM_LIST) ? second_indent : old_indent),
&did_do_comment);
if (!(flags & INSCHAR_COM_LIST))
old_indent = 0;
// If a comment leader was inserted, may also do this on a following
// line.
if (did_do_comment)
no_leader = FALSE;
replace_offset = 0;
if (first_line)
{

View File

@@ -1544,6 +1544,7 @@ errret:
* "partialp".
* If "type" is not NULL and a Vim9 script-local variable is found look up the
* type of the variable.
* If "found_var" is not NULL and a variable was found set it to TRUE.
*/
char_u *
deref_func_name(
@@ -1551,7 +1552,8 @@ deref_func_name(
int *lenp,
partial_T **partialp,
type_T **type,
int no_autoload)
int no_autoload,
int *found_var)
{
dictitem_T *v;
typval_T *tv = NULL;
@@ -1609,6 +1611,8 @@ deref_func_name(
if (tv != NULL)
{
if (found_var != NULL)
*found_var = TRUE;
if (tv->v_type == VAR_FUNC)
{
if (tv->vval.v_string == NULL)
@@ -3199,12 +3203,15 @@ call_callback_retnr(
* Nothing if "error" is FCERR_NONE.
*/
void
user_func_error(int error, char_u *name)
user_func_error(int error, char_u *name, funcexe_T *funcexe)
{
switch (error)
{
case FCERR_UNKNOWN:
emsg_funcname(e_unknownfunc, name);
if (funcexe->fe_found_var)
semsg(_(e_not_callable_type_str), name);
else
emsg_funcname(e_unknownfunc, name);
break;
case FCERR_NOTMETHOD:
emsg_funcname(
@@ -3448,7 +3455,7 @@ theend:
*/
if (!aborting())
{
user_func_error(error, (name != NULL) ? name : funcname);
user_func_error(error, (name != NULL) ? name : funcname, funcexe);
}
// clear the copies made from the partial
@@ -3677,7 +3684,7 @@ trans_function_name(
{
len = (int)STRLEN(lv.ll_exp_name);
name = deref_func_name(lv.ll_exp_name, &len, partial, type,
flags & TFN_NO_AUTOLOAD);
flags & TFN_NO_AUTOLOAD, NULL);
if (name == lv.ll_exp_name)
name = NULL;
}
@@ -3685,7 +3692,7 @@ trans_function_name(
{
len = (int)(end - *pp);
name = deref_func_name(*pp, &len, partial, type,
flags & TFN_NO_AUTOLOAD);
flags & TFN_NO_AUTOLOAD, NULL);
if (name == *pp)
name = NULL;
}
@@ -4134,19 +4141,41 @@ define_function(exarg_T *eap, char_u *name_arg)
|| (fudi.fd_di->di_tv.v_type != VAR_FUNC
&& fudi.fd_di->di_tv.v_type != VAR_PARTIAL)))
{
char_u *name_base = arg;
int i;
if (*arg == K_SPECIAL)
j = 3;
else
j = 0;
while (arg[j] != NUL && (j == 0 ? eval_isnamec1(arg[j])
: eval_isnamec(arg[j])))
++j;
if (arg[j] != NUL)
{
name_base = vim_strchr(arg, '_');
if (name_base == NULL)
name_base = arg + 3;
else
++name_base;
}
for (i = 0; name_base[i] != NUL && (i == 0
? eval_isnamec1(name_base[i])
: eval_isnamec(name_base[i])); ++i)
;
if (name_base[i] != NUL)
emsg_funcname((char *)e_invarg2, arg);
// In Vim9 script a function cannot have the same name as a
// variable.
if (vim9script && *arg == K_SPECIAL
&& eval_variable(name_base, STRLEN(name_base), NULL, NULL,
EVAL_VAR_NOAUTOLOAD + EVAL_VAR_IMPORT
+ EVAL_VAR_NO_FUNC) == OK)
{
semsg(_(e_redefining_script_item_str), name_base);
goto ret_free;
}
}
// Disallow using the g: dict.
if (fudi.fd_dict != NULL && fudi.fd_dict->dv_scope == VAR_DEF_SCOPE)
{
emsg(_("E862: Cannot use g: here"));
goto ret_free;
}
}
// This may get more lines and make the pointers into the first line
@@ -4982,6 +5011,7 @@ ex_call(exarg_T *eap)
partial_T *partial = NULL;
evalarg_T evalarg;
type_T *type = NULL;
int found_var = FALSE;
fill_evalarg_from_eap(&evalarg, eap, eap->skip);
if (eap->skip)
@@ -5018,7 +5048,7 @@ ex_call(exarg_T *eap)
// from trans_function_name().
len = (int)STRLEN(tofree);
name = deref_func_name(tofree, &len, partial != NULL ? NULL : &partial,
in_vim9script() && type == NULL ? &type : NULL, FALSE);
in_vim9script() && type == NULL ? &type : NULL, FALSE, &found_var);
// Skip white space to allow ":call func ()". Not good, but required for
// backward compatibility.
@@ -5074,6 +5104,7 @@ ex_call(exarg_T *eap)
funcexe.partial = partial;
funcexe.selfdict = fudi.fd_dict;
funcexe.check_type = type;
funcexe.fe_found_var = found_var;
rettv.v_type = VAR_UNKNOWN; // clear_tv() uses this
if (get_func_tv(name, -1, &rettv, &arg, &evalarg, &funcexe) == FAIL)
{

View File

@@ -753,6 +753,22 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3787,
/**/
3786,
/**/
3785,
/**/
3784,
/**/
3783,
/**/
3782,
/**/
3781,
/**/
3780,
/**/
3779,
/**/

View File

@@ -2782,6 +2782,7 @@ long elapsed(DWORD start_tick);
#define EVAL_VAR_VERBOSE 1 // may give error message
#define EVAL_VAR_NOAUTOLOAD 2 // do not use script autoloading
#define EVAL_VAR_IMPORT 4 // may return special variable for import
#define EVAL_VAR_NO_FUNC 8 // do not look for a function
// Maximum number of characters that can be fuzzy matched
#define MAX_FUZZY_MATCHES 256

View File

@@ -890,7 +890,7 @@ call_ufunc(
if (error != FCERR_NONE)
{
user_func_error(error, ufunc->uf_name);
user_func_error(error, ufunc->uf_name, &funcexe);
return FAIL;
}
if (did_emsg > did_emsg_before)
@@ -2343,7 +2343,8 @@ exec_instructions(ectx_T *ectx)
long n = 0;
char_u *s = NULL;
char *msg;
callback_T cb = {NULL, NULL, 0};
char_u numbuf[NUMBUFLEN];
char_u *tofree = NULL;
--ectx->ec_stack.ga_len;
tv = STACK_TV_BOT(0);
@@ -2356,28 +2357,29 @@ exec_instructions(ectx_T *ectx)
else if (iptr->isn_type == ISN_STOREFUNCOPT)
{
SOURCING_LNUM = iptr->isn_lnum;
cb = get_callback(tv);
if (cb.cb_name == NULL || *cb.cb_name == NUL)
// If the option can be set to a function reference or
// a lambda and the passed value is a function
// reference, then convert it to the name (string) of
// the function reference.
s = tv2string(tv, &tofree, numbuf, 0);
if (s == NULL || *s == NUL)
{
clear_tv(tv);
free_callback(&cb);
goto on_error;
}
s = cb.cb_name;
}
else
// must be VAR_NUMBER, CHECKTYPE makes sure
n = tv->vval.v_number;
msg = set_option_value(opt_name, n, s, opt_flags);
clear_tv(tv);
vim_free(tofree);
if (msg != NULL)
{
SOURCING_LNUM = iptr->isn_lnum;
emsg(_(msg));
goto on_error;
}
if (cb.cb_name != NULL)
free_callback(&cb);
}
break;