Mercurial > vim
comparison src/userfunc.c @ 23426:c3c690c8fcbf v8.2.2256
patch 8.2.2256: Vim9: cannot use function( after line break in :def function
Commit: https://github.com/vim/vim/commit/adc8e4464563a2952c10362d396bb4a9f28cd12d
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Dec 31 18:28:18 2020 +0100
patch 8.2.2256: Vim9: cannot use function( after line break in :def function
Problem: Vim9: cannot use function( after line break in :def function.
Solution: Check for "(" after "function". (closes https://github.com/vim/vim/issues/7581)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 31 Dec 2020 18:30:04 +0100 |
parents | 42294d4d4f6e |
children | f00d6ff51046 |
comparison
equal
deleted
inserted
replaced
23425:a3c77a2e53b6 | 23426:c3c690c8fcbf |
---|---|
2920 return; | 2920 return; |
2921 } | 2921 } |
2922 } | 2922 } |
2923 } | 2923 } |
2924 } | 2924 } |
2925 } | |
2926 | |
2927 /* | |
2928 * Check if "*cmd" points to a function command and if so advance "*cmd" and | |
2929 * return TRUE. | |
2930 * Otherwise return FALSE; | |
2931 * Do not consider "function(" to be a command. | |
2932 */ | |
2933 static int | |
2934 is_function_cmd(char_u **cmd) | |
2935 { | |
2936 char_u *p = *cmd; | |
2937 | |
2938 if (checkforcmd(&p, "function", 2)) | |
2939 { | |
2940 if (*p == '(') | |
2941 return FALSE; | |
2942 *cmd = p; | |
2943 return TRUE; | |
2944 } | |
2945 return FALSE; | |
2925 } | 2946 } |
2926 | 2947 |
2927 /* | 2948 /* |
2928 * ":function" also supporting nested ":def". | 2949 * ":function" also supporting nested ":def". |
2929 * When "name_arg" is not NULL this is a nested function, using "name_arg" for | 2950 * When "name_arg" is not NULL this is a nested function, using "name_arg" for |
3424 | 3445 |
3425 // Check for defining a function inside this function. | 3446 // Check for defining a function inside this function. |
3426 // Only recognize "def" inside "def", not inside "function", | 3447 // Only recognize "def" inside "def", not inside "function", |
3427 // For backwards compatibility, see Test_function_python(). | 3448 // For backwards compatibility, see Test_function_python(). |
3428 c = *p; | 3449 c = *p; |
3429 if (checkforcmd(&p, "function", 2) | 3450 if (is_function_cmd(&p) |
3430 || (eap->cmdidx == CMD_def && checkforcmd(&p, "def", 3))) | 3451 || (eap->cmdidx == CMD_def && checkforcmd(&p, "def", 3))) |
3431 { | 3452 { |
3432 if (*p == '!') | 3453 if (*p == '!') |
3433 p = skipwhite(p + 1); | 3454 p = skipwhite(p + 1); |
3434 p += eval_fname_script(p); | 3455 p += eval_fname_script(p); |