]> granicus.if.org Git - vim/commitdiff
patch 8.0.0868: cannot specify the terminal size on the command line v8.0.0868
authorBram Moolenaar <Bram@vim.org>
Sat, 5 Aug 2017 15:13:48 +0000 (17:13 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 5 Aug 2017 15:13:48 +0000 (17:13 +0200)
Problem:    Cannot specify the terminal size on the command line.
Solution:   Use the address range for the terminal size. (Yasuhiro Matsumoto,
            closes #1941)

src/terminal.c
src/testdir/test_terminal.vim
src/version.c

index f5cd2e0190aa16e82b7f95176dbb01d456dc3a43..1ce4db7e973e64d75cf55812252d9d496dc1bb69 100644 (file)
@@ -257,6 +257,17 @@ term_start(char_u *cmd, jobopt_T *opt)
     split_ea.cmdidx = CMD_new;
     split_ea.cmd = (char_u *)"new";
     split_ea.arg = (char_u *)"";
+    if (opt->jo_term_rows > 0 && !(cmdmod.split & WSP_VERT))
+    {
+       split_ea.line2 = opt->jo_term_rows;
+       split_ea.addr_count = 1;
+    }
+    if (opt->jo_term_cols > 0 && (cmdmod.split & WSP_VERT))
+    {
+       split_ea.line2 = opt->jo_term_cols;
+       split_ea.addr_count = 1;
+    }
+
     ex_splitview(&split_ea);
     if (curwin == old_curwin)
     {
@@ -267,6 +278,12 @@ term_start(char_u *cmd, jobopt_T *opt)
     term->tl_buffer = curbuf;
     curbuf->b_term = term;
 
+    /* only one size was taken care of with :new, do the other one */
+    if (opt->jo_term_rows > 0 && (cmdmod.split & WSP_VERT))
+       win_setheight(opt->jo_term_rows);
+    if (opt->jo_term_cols > 0 && !(cmdmod.split & WSP_VERT))
+       win_setwidth(opt->jo_term_cols);
+
     /* Link the new terminal in the list of active terminals. */
     term->tl_next = first_term;
     first_term = term;
@@ -338,7 +355,20 @@ ex_terminal(exarg_T *eap)
     jobopt_T opt;
 
     init_job_options(&opt);
-    /* TODO: get options from before the command */
+
+    if (eap->addr_count == 2)
+    {
+       opt.jo_term_rows = eap->line1;
+       opt.jo_term_cols = eap->line2;
+    }
+    else if (eap->addr_count == 1)
+    {
+       if (cmdmod.split & WSP_VERT)
+           opt.jo_term_cols = eap->line2;
+       else
+           opt.jo_term_rows = eap->line2;
+    }
+    /* TODO: get more options from before the command */
 
     term_start(eap->arg, &opt);
 }
index 8c14fa4d034bc674f8578b7a5c7796e747706dd7..863a784b9b74d021d93c2c16367316bad84a1694 100644 (file)
@@ -171,3 +171,29 @@ func Test_terminal_scrape()
   exe buf . 'bwipe'
   call delete('Xtext')
 endfunc
+
+func Test_terminal_size()
+  let cmd = Get_cat_cmd()
+
+  exe '5terminal ' . cmd
+  let size = term_getsize('')
+  bwipe!
+  call assert_equal(5, size[0])
+
+  vsplit
+  exe '5,33terminal ' . cmd
+  let size = term_getsize('')
+  bwipe!
+  call assert_equal([5, 33], size)
+
+  exe 'vertical 20terminal ' . cmd
+  let size = term_getsize('')
+  bwipe!
+  call assert_equal(20, size[1])
+
+  split
+  exe 'vertical 6,20terminal ' . cmd
+  let size = term_getsize('')
+  bwipe!
+  call assert_equal([6, 20], size)
+endfunc
index d3b3215fc065b8afc1e805d18f5deb3b6ebaa1c9..a721d42546d2669b09a0bfa3bf74917774460088 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    868,
 /**/
     867,
 /**/