changeset 21755:3b312e56e2b8 v8.2.1427

patch 8.2.1427: Vim9: cannot use a range with marks in :def function Commit: https://github.com/vim/vim/commit/7c5ad34878a338f1db57337b5ca9f68c0c39424e Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 12 15:48:55 2020 +0200 patch 8.2.1427: Vim9: cannot use a range with marks in :def function Problem: Vim9: cannot use a range with marks in :def function. Solution: Parse range after colon. (closes https://github.com/vim/vim/issues/6686)
author Bram Moolenaar <Bram@vim.org>
date Wed, 12 Aug 2020 16:00:06 +0200
parents 02dadec5fe33
children 067db9f81e68
files src/testdir/test_vim9_disassemble.vim src/version.c src/vim9compile.c
diffstat 3 files changed, 34 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -83,20 +83,37 @@ enddef
 
 def Test_disassemble_exec_expr()
   let res = execute('disass s:EditExpand')
-  assert_match('<SNR>\d*_EditExpand.*' ..
-        ' let filename = "file".*' ..
-        '\d PUSHS "file".*' ..
-        '\d STORE $0.*' ..
-        ' let filenr = 123.*' ..
-        '\d STORE 123 in $1.*' ..
-        ' edit the`=filename``=filenr`.txt.*' ..
-        '\d PUSHS "edit the".*' ..
-        '\d LOAD $0.*' ..
-        '\d LOAD $1.*' ..
-        '\d 2STRING stack\[-1\].*' ..
-        '\d PUSHS ".txt".*' ..
-        '\d EXECCONCAT 4.*' ..
-        '\d PUSHNR 0.*' ..
+  assert_match('<SNR>\d*_EditExpand\_s*' ..
+        ' let filename = "file"\_s*' ..
+        '\d PUSHS "file"\_s*' ..
+        '\d STORE $0\_s*' ..
+        ' let filenr = 123\_s*' ..
+        '\d STORE 123 in $1\_s*' ..
+        ' edit the`=filename``=filenr`.txt\_s*' ..
+        '\d PUSHS "edit the"\_s*' ..
+        '\d LOAD $0\_s*' ..
+        '\d LOAD $1\_s*' ..
+        '\d 2STRING stack\[-1\]\_s*' ..
+        '\d\+ PUSHS ".txt"\_s*' ..
+        '\d\+ EXECCONCAT 4\_s*' ..
+        '\d\+ PUSHNR 0\_s*' ..
+        '\d\+ RETURN',
+        res)
+enddef
+
+def s:YankRange()
+  norm! m[jjm]
+  :'[,']yank
+enddef
+
+def Test_disassemble_yank_range()
+  let res = execute('disass s:YankRange')
+  assert_match('<SNR>\d*_YankRange.*' ..
+        ' norm! m\[jjm\]\_s*' ..
+        '\d EXEC   norm! m\[jjm\]\_s*' ..
+        '  :''\[,''\]yank\_s*' ..
+        '\d EXEC   :''\[,''\]yank\_s*' ..
+        '\d PUSHNR 0\_s*' ..
         '\d RETURN',
         res)
 enddef
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1427,
+/**/
     1426,
 /**/
     1425,
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -6567,7 +6567,7 @@ compile_def_function(ufunc_T *ufunc, int
 	 * 'text'->func() should not be confused with 'a mark
 	 */
 	cmd = ea.cmd;
-	if (*cmd != '\'')
+	if (*cmd != '\'' || starts_with_colon)
 	{
 	    ea.cmd = skip_range(ea.cmd, NULL);
 	    if (ea.cmd > cmd && !starts_with_colon)