0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

patch 8.2.1322: Vim9: method on double quoted string doesn't work

Problem:    Vim9: method on double quoted string doesn't work.
Solution:   Recognize double quoted string. (closes #6562)
This commit is contained in:
Bram Moolenaar
2020-07-29 20:00:38 +02:00
parent 7b7f78f51d
commit 1040956292
4 changed files with 17 additions and 3 deletions

View File

@@ -3277,7 +3277,7 @@ find_ex_command(
char_u *pskip = (*eap->cmd == '&' || *eap->cmd == '$' char_u *pskip = (*eap->cmd == '&' || *eap->cmd == '$'
|| *eap->cmd == '@') ? eap->cmd + 1 : eap->cmd; || *eap->cmd == '@') ? eap->cmd + 1 : eap->cmd;
if (vim_strchr((char_u *)"{('[", *p) != NULL if (vim_strchr((char_u *)"{('[\"", *p) != NULL
|| ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL)) || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL))
{ {
int oplen; int oplen;
@@ -3293,6 +3293,8 @@ find_ex_command(
*eap->cmd == '{' *eap->cmd == '{'
// "'string'->func()" is an expression. // "'string'->func()" is an expression.
|| *eap->cmd == '\'' || *eap->cmd == '\''
// '"string"->func()' is an expression.
|| *eap->cmd == '"'
// "g:varname" is an expression. // "g:varname" is an expression.
|| eap->cmd[1] == ':' || eap->cmd[1] == ':'
) )

View File

@@ -1638,8 +1638,9 @@ enddef
def Test_expr7_method_call() def Test_expr7_method_call()
new new
setline(1, ['first', 'last']) setline(1, ['first', 'last'])
eval 'second'->append(1) 'second'->append(1)
assert_equal(['first', 'second', 'last'], getline(1, '$')) "third"->append(2)
assert_equal(['first', 'second', 'third', 'last'], getline(1, '$'))
bwipe! bwipe!
let bufnr = bufnr() let bufnr = bufnr()

View File

@@ -502,8 +502,11 @@ def Test_vim9script_call()
assert_equal('some', var) assert_equal('some', var)
# line starting with single quote is not a mark # line starting with single quote is not a mark
# line starting with double quote can be a method call
'asdfasdf'->MyFunc() 'asdfasdf'->MyFunc()
assert_equal('asdfasdf', var) assert_equal('asdfasdf', var)
"xyz"->MyFunc()
assert_equal('xyz', var)
def UseString() def UseString()
'xyork'->MyFunc() 'xyork'->MyFunc()
@@ -511,6 +514,12 @@ def Test_vim9script_call()
UseString() UseString()
assert_equal('xyork', var) assert_equal('xyork', var)
def UseString2()
"knife"->MyFunc()
enddef
UseString2()
assert_equal('knife', var)
# prepending a colon makes it a mark # prepending a colon makes it a mark
new new
setline(1, ['aaa', 'bbb', 'ccc']) setline(1, ['aaa', 'bbb', 'ccc'])

View File

@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1322,
/**/ /**/
1321, 1321,
/**/ /**/