]> granicus.if.org Git - vim/commitdiff
patch 8.2.4971: Vim9: interpolated string seen as range v8.2.4971
authorBram Moolenaar <Bram@vim.org>
Tue, 17 May 2022 12:14:23 +0000 (13:14 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 17 May 2022 12:14:23 +0000 (13:14 +0100)
Problem:    Vim9: interpolated string seen as range.
Solution:   Recognize an interpolated string at the start of a command line.
            (closes #10434)

src/ex_docmd.c
src/testdir/test_vim9_expr.vim
src/version.c

index a865f65d198335954438d3bd0fab9aa5087112d3..6cf77155cacdba9272326936884c22b0a36fe8a4 100644 (file)
@@ -3551,7 +3551,8 @@ find_ex_command(
            char_u  *swp;
 
            if (*eap->cmd == '&'
-                   || *eap->cmd == '$'
+                   || (eap->cmd[0] == '$'
+                                 && eap->cmd[1] != '\'' && eap->cmd[1] != '"')
                    || (eap->cmd[0] == '@'
                                        && (valid_yank_reg(eap->cmd[1], FALSE)
                                                       || eap->cmd[1] == '@')))
@@ -3590,9 +3591,13 @@ find_ex_command(
                            // "'string'->func()" is an expression.
                         || *eap->cmd == '\''
                            // '"string"->func()' is an expression.
-                        || (eap->cmd[0] == '0' && eap->cmd[1] == 'z')
-                           // '"string"->func()' is an expression.
                         || *eap->cmd == '"'
+                           // '$"string"->func()' is an expression.
+                           // "$'string'->func()" is an expression.
+                        || (eap->cmd[0] == '$'
+                            && (eap->cmd[1] == '\'' || eap->cmd[1] == '"'))
+                           // '0z1234->func()' is an expression.
+                        || (eap->cmd[0] == '0' && eap->cmd[1] == 'z')
                            // "g:varname" is an expression.
                         || eap->cmd[1] == ':'
                            )
index 5370a92326a838da5a625fb5a9c0d8c5c73a4c0a..e43eba73abb43d7ed6c05cdb7c4adfd222360bae 100644 (file)
@@ -3572,7 +3572,9 @@ def Test_expr8_method_call()
       setline(1, ['first', 'last'])
       'second'->append(1)
       "third"->append(2)
-      assert_equal(['first', 'second', 'third', 'last'], getline(1, '$'))
+      $"fourth"->append(3)
+      $'fifth'->append(4)
+      assert_equal(['first', 'second', 'third', 'fourth', 'fifth', 'last'], getline(1, '$'))
       bwipe!
 
       var bufnr = bufnr()
index 7bdf346336482b19ad22695d943acfcb43db8fd7..10804ecaa96292d2f4f658d25209b95013da8499 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4971,
 /**/
     4970,
 /**/