]> granicus.if.org Git - vim/commitdiff
patch 8.2.1627: Vim9: cannot pass "true" to submatch/term_gettty/term_start v8.2.1627
authorBram Moolenaar <Bram@vim.org>
Sun, 6 Sep 2020 16:22:53 +0000 (18:22 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 6 Sep 2020 16:22:53 +0000 (18:22 +0200)
Problem:    Vim9: cannot pass "true" to submatch(), term_gettty() and
            term_start()
Solution:   Use tv_get_bool_chk(). (closes #6888, closes #6890, closes #6889)

src/evalfunc.c
src/job.c
src/terminal.c
src/testdir/test_vim9_func.vim
src/version.c

index e7683fc3dc2d5d8b13934b6dde13ef10b574bb68..e69f2939f941e69aaa9ec662de8a94b2127caea9 100644 (file)
@@ -8400,7 +8400,7 @@ f_submatch(typval_T *argvars, typval_T *rettv)
        return;
     }
     if (argvars[1].v_type != VAR_UNKNOWN)
-       retList = (int)tv_get_number_chk(&argvars[1], &error);
+       retList = (int)tv_get_bool_chk(&argvars[1], &error);
     if (error)
        return;
 
index 0e73b1cdbf8b16774514058b2c1a29dc30b16047..f55a8cd8139ea90da7f3f2b6e0b2a50a1d59927d 100644 (file)
--- a/src/job.c
+++ b/src/job.c
@@ -448,7 +448,7 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
                if (!(supported2 & JO2_CURWIN))
                    break;
                opt->jo_set2 |= JO2_CURWIN;
-               opt->jo_curwin = tv_get_number(item);
+               opt->jo_curwin = tv_get_bool(item);
            }
            else if (STRCMP(hi->hi_key, "bufnr") == 0)
            {
index cab9cb9c665e0d3b6bf778ae07b67326756a52ed..fe84a9fe7b99f03a29fa5ad919cf693b515608a5 100644 (file)
@@ -5768,7 +5768,7 @@ f_term_gettty(typval_T *argvars, typval_T *rettv)
     if (buf == NULL)
        return;
     if (argvars[1].v_type != VAR_UNKNOWN)
-       num = tv_get_number(&argvars[1]);
+       num = tv_get_bool(&argvars[1]);
 
     switch (num)
     {
index e31551714f5212b4d2b4eb807946a473eaa4f693..58003414ef813c887a619a17549bfe963647ec93 100644 (file)
@@ -1,6 +1,7 @@
 " Test various aspects of the Vim9 script language.
 
 source check.vim
+source term_util.vim
 source view_util.vim
 source vim9.vim
 source screendump.vim
@@ -1648,6 +1649,14 @@ def Test_strchars()
   strchars("A\u20dd", true)->assert_equal(1)
 enddef
 
+def Test_submatch()
+  let pat = 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)'
+  let Rep = {-> range(10)->map({_, v -> submatch(v, true)})->string()}
+  let actual = substitute('A123456789', pat, Rep, '')
+  let expected = "[['A123456789'], ['1'], ['2'], ['3'], ['4'], ['5'], ['6'], ['7'], ['8'], ['9']]"
+  assert_equal(expected, actual)
+enddef
+
 def Test_synID()
   new
   setline(1, "text")
@@ -1655,6 +1664,20 @@ def Test_synID()
   bwipe!
 enddef
 
+def Test_term_gettty()
+  let buf = Run_shell_in_terminal({})
+  assert_notequal('', term_gettty(buf, true))
+  StopShellInTerminal(buf)
+enddef
+
+def Test_term_start()
+  botright new
+  let winnr = winnr()
+  term_start(&shell, #{curwin: true})
+  assert_equal(winnr, winnr())
+  bwipe!
+enddef
+
 def Test_win_splitmove()
   split
   win_splitmove(1, 2, #{vertical: true, rightbelow: true})
index c6c111a31dea86b85ca92326f08cbdede526f224..b4d5769519843edd6a8385f4d25fbbfe4f532017 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1627,
 /**/
     1626,
 /**/