Karsten Hopp f1181b
To: vim_dev@googlegroups.com
Karsten Hopp f1181b
Subject: Patch 7.4.709
Karsten Hopp f1181b
Fcc: outbox
Karsten Hopp f1181b
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp f1181b
Mime-Version: 1.0
Karsten Hopp f1181b
Content-Type: text/plain; charset=UTF-8
Karsten Hopp f1181b
Content-Transfer-Encoding: 8bit
Karsten Hopp f1181b
------------
Karsten Hopp f1181b
Karsten Hopp f1181b
Patch 7.4.709
Karsten Hopp f1181b
Problem:    ":tabmove" does not work as documented.
Karsten Hopp f1181b
Solution:   Make it work consistently.  Update documentation and add tests.
Karsten Hopp f1181b
            (Hirohito Higashi)
Karsten Hopp f1181b
Files:      src/window.c, runtime/doc/tabpage.txt, src/ex_docmd.c,
Karsten Hopp f1181b
            src/testdir/test62.in, src/testdir/test62.ok
Karsten Hopp f1181b
Karsten Hopp f1181b
Karsten Hopp f1181b
*** ../vim-7.4.708/src/window.c	2015-04-21 15:43:00.338397578 +0200
Karsten Hopp f1181b
--- src/window.c	2015-04-21 18:05:36.180477302 +0200
Karsten Hopp f1181b
***************
Karsten Hopp f1181b
*** 4120,4137 ****
Karsten Hopp f1181b
  }
Karsten Hopp f1181b
  
Karsten Hopp f1181b
  /*
Karsten Hopp f1181b
!  * Move the current tab page to before tab page "nr".
Karsten Hopp f1181b
   */
Karsten Hopp f1181b
      void
Karsten Hopp f1181b
  tabpage_move(nr)
Karsten Hopp f1181b
      int		nr;
Karsten Hopp f1181b
  {
Karsten Hopp f1181b
!     int		n = nr;
Karsten Hopp f1181b
!     tabpage_T	*tp;
Karsten Hopp f1181b
  
Karsten Hopp f1181b
      if (first_tabpage->tp_next == NULL)
Karsten Hopp f1181b
  	return;
Karsten Hopp f1181b
  
Karsten Hopp f1181b
      /* Remove the current tab page from the list of tab pages. */
Karsten Hopp f1181b
      if (curtab == first_tabpage)
Karsten Hopp f1181b
  	first_tabpage = curtab->tp_next;
Karsten Hopp f1181b
--- 4120,4146 ----
Karsten Hopp f1181b
  }
Karsten Hopp f1181b
  
Karsten Hopp f1181b
  /*
Karsten Hopp f1181b
!  * Move the current tab page to after tab page "nr".
Karsten Hopp f1181b
   */
Karsten Hopp f1181b
      void
Karsten Hopp f1181b
  tabpage_move(nr)
Karsten Hopp f1181b
      int		nr;
Karsten Hopp f1181b
  {
Karsten Hopp f1181b
!     int		n = 1;
Karsten Hopp f1181b
!     tabpage_T	*tp, *tp_dst;
Karsten Hopp f1181b
  
Karsten Hopp f1181b
      if (first_tabpage->tp_next == NULL)
Karsten Hopp f1181b
  	return;
Karsten Hopp f1181b
  
Karsten Hopp f1181b
+     for (tp = first_tabpage; tp->tp_next != NULL && n < nr; tp = tp->tp_next)
Karsten Hopp f1181b
+ 	++n;
Karsten Hopp f1181b
+ 
Karsten Hopp f1181b
+     if (tp == curtab || (nr > 0 && tp->tp_next != NULL
Karsten Hopp f1181b
+ 						    && tp->tp_next == curtab))
Karsten Hopp f1181b
+ 	return;
Karsten Hopp f1181b
+ 
Karsten Hopp f1181b
+     tp_dst = tp;
Karsten Hopp f1181b
+ 
Karsten Hopp f1181b
      /* Remove the current tab page from the list of tab pages. */
Karsten Hopp f1181b
      if (curtab == first_tabpage)
Karsten Hopp f1181b
  	first_tabpage = curtab->tp_next;
Karsten Hopp f1181b
***************
Karsten Hopp f1181b
*** 4146,4162 ****
Karsten Hopp f1181b
      }
Karsten Hopp f1181b
  
Karsten Hopp f1181b
      /* Re-insert it at the specified position. */
Karsten Hopp f1181b
!     if (n <= 0)
Karsten Hopp f1181b
      {
Karsten Hopp f1181b
  	curtab->tp_next = first_tabpage;
Karsten Hopp f1181b
  	first_tabpage = curtab;
Karsten Hopp f1181b
      }
Karsten Hopp f1181b
      else
Karsten Hopp f1181b
      {
Karsten Hopp f1181b
! 	for (tp = first_tabpage; tp->tp_next != NULL && n > 1; tp = tp->tp_next)
Karsten Hopp f1181b
! 	    --n;
Karsten Hopp f1181b
! 	curtab->tp_next = tp->tp_next;
Karsten Hopp f1181b
! 	tp->tp_next = curtab;
Karsten Hopp f1181b
      }
Karsten Hopp f1181b
  
Karsten Hopp f1181b
      /* Need to redraw the tabline.  Tab page contents doesn't change. */
Karsten Hopp f1181b
--- 4155,4169 ----
Karsten Hopp f1181b
      }
Karsten Hopp f1181b
  
Karsten Hopp f1181b
      /* Re-insert it at the specified position. */
Karsten Hopp f1181b
!     if (nr <= 0)
Karsten Hopp f1181b
      {
Karsten Hopp f1181b
  	curtab->tp_next = first_tabpage;
Karsten Hopp f1181b
  	first_tabpage = curtab;
Karsten Hopp f1181b
      }
Karsten Hopp f1181b
      else
Karsten Hopp f1181b
      {
Karsten Hopp f1181b
! 	curtab->tp_next = tp_dst->tp_next;
Karsten Hopp f1181b
! 	tp_dst->tp_next = curtab;
Karsten Hopp f1181b
      }
Karsten Hopp f1181b
  
Karsten Hopp f1181b
      /* Need to redraw the tabline.  Tab page contents doesn't change. */
Karsten Hopp f1181b
*** ../vim-7.4.708/runtime/doc/tabpage.txt	2015-01-07 16:52:53.506792420 +0100
Karsten Hopp f1181b
--- runtime/doc/tabpage.txt	2015-04-21 18:01:53.042846350 +0200
Karsten Hopp f1181b
***************
Karsten Hopp f1181b
*** 202,224 ****
Karsten Hopp f1181b
  		Move the current tab page to after tab page N.  Use zero to
Karsten Hopp f1181b
  		make the current tab page the first one.  Without N the tab
Karsten Hopp f1181b
  		page is made the last one. >
Karsten Hopp f1181b
  		    :-tabmove	" move the tab page to the left
Karsten Hopp f1181b
! 		    :tabmove	" move the tab page to the right
Karsten Hopp f1181b
! 		    :.tabmove	" as above
Karsten Hopp f1181b
! 		    :+tabmove	" as above
Karsten Hopp f1181b
  		    :0tabmove	" move the tab page to the beginning of the tab
Karsten Hopp f1181b
  				" list
Karsten Hopp f1181b
! 		    :$tabmove	" move the tab page to the end of the tab list
Karsten Hopp f1181b
! <
Karsten Hopp f1181b
  
Karsten Hopp f1181b
  :tabm[ove] +[N]
Karsten Hopp f1181b
  :tabm[ove] -[N]
Karsten Hopp f1181b
  		Move the current tab page N places to the right (with +) or to
Karsten Hopp f1181b
! 		the left (with -).
Karsten Hopp f1181b
  
Karsten Hopp f1181b
  Note that although it is possible to move a tab behind the N-th one by using
Karsten Hopp f1181b
! :Ntabmove, it is impossible to move it by N places by using :+Ntabmove. For
Karsten Hopp f1181b
! clarification what +N means in this context see |[range]|.
Karsten Hopp f1181b
  
Karsten Hopp f1181b
  
Karsten Hopp f1181b
  LOOPING OVER TAB PAGES:
Karsten Hopp f1181b
--- 202,230 ----
Karsten Hopp f1181b
  		Move the current tab page to after tab page N.  Use zero to
Karsten Hopp f1181b
  		make the current tab page the first one.  Without N the tab
Karsten Hopp f1181b
  		page is made the last one. >
Karsten Hopp f1181b
+ 		    :.tabmove	" do nothing
Karsten Hopp f1181b
  		    :-tabmove	" move the tab page to the left
Karsten Hopp f1181b
! 		    :+tabmove	" move the tab page to the right
Karsten Hopp f1181b
  		    :0tabmove	" move the tab page to the beginning of the tab
Karsten Hopp f1181b
  				" list
Karsten Hopp f1181b
! 		    :tabmove 0	" as above
Karsten Hopp f1181b
! 		    :tabmove	" move the tab page to the last
Karsten Hopp f1181b
! 		    :$tabmove	" as above
Karsten Hopp f1181b
! 		    :tabmove $	" as above
Karsten Hopp f1181b
  
Karsten Hopp f1181b
  :tabm[ove] +[N]
Karsten Hopp f1181b
  :tabm[ove] -[N]
Karsten Hopp f1181b
  		Move the current tab page N places to the right (with +) or to
Karsten Hopp f1181b
! 		the left (with -). >
Karsten Hopp f1181b
! 		    :tabmove -	" move the tab page to the left
Karsten Hopp f1181b
! 		    :tabmove -1	" as above
Karsten Hopp f1181b
! 		    :tabmove +	" move the tab page to the right
Karsten Hopp f1181b
! 		    :tabmove +1	" as above
Karsten Hopp f1181b
! 
Karsten Hopp f1181b
  
Karsten Hopp f1181b
  Note that although it is possible to move a tab behind the N-th one by using
Karsten Hopp f1181b
! :Ntabmove. And move it by N places by using :+Ntabmove. For clarification what
Karsten Hopp f1181b
! +N means in this context see |[range]|.
Karsten Hopp f1181b
  
Karsten Hopp f1181b
  
Karsten Hopp f1181b
  LOOPING OVER TAB PAGES:
Karsten Hopp f1181b
*** ../vim-7.4.708/src/ex_docmd.c	2015-04-13 12:35:50.180593380 +0200
Karsten Hopp f1181b
--- src/ex_docmd.c	2015-04-21 18:01:53.042846350 +0200
Karsten Hopp f1181b
***************
Karsten Hopp f1181b
*** 8145,8151 ****
Karsten Hopp f1181b
  ex_tabmove(eap)
Karsten Hopp f1181b
      exarg_T	*eap;
Karsten Hopp f1181b
  {
Karsten Hopp f1181b
!     int tab_number = 9999;
Karsten Hopp f1181b
  
Karsten Hopp f1181b
      if (eap->arg && *eap->arg != NUL)
Karsten Hopp f1181b
      {
Karsten Hopp f1181b
--- 8145,8151 ----
Karsten Hopp f1181b
  ex_tabmove(eap)
Karsten Hopp f1181b
      exarg_T	*eap;
Karsten Hopp f1181b
  {
Karsten Hopp f1181b
!     int tab_number;
Karsten Hopp f1181b
  
Karsten Hopp f1181b
      if (eap->arg && *eap->arg != NUL)
Karsten Hopp f1181b
      {
Karsten Hopp f1181b
***************
Karsten Hopp f1181b
*** 8166,8184 ****
Karsten Hopp f1181b
  	else
Karsten Hopp f1181b
  	    p = eap->arg;
Karsten Hopp f1181b
  
Karsten Hopp f1181b
! 	if (p == skipdigits(p))
Karsten Hopp f1181b
  	{
Karsten Hopp f1181b
! 	    /* No numbers as argument. */
Karsten Hopp f1181b
! 	    eap->errmsg = e_invarg;
Karsten Hopp f1181b
! 	    return;
Karsten Hopp f1181b
  	}
Karsten Hopp f1181b
- 
Karsten Hopp f1181b
- 	tab_number = getdigits(&p);
Karsten Hopp f1181b
- 	if (relative != 0)
Karsten Hopp f1181b
- 	    tab_number = tab_number * relative + tabpage_index(curtab) - 1;;
Karsten Hopp f1181b
      }
Karsten Hopp f1181b
      else if (eap->addr_count != 0)
Karsten Hopp f1181b
  	tab_number = eap->line2;
Karsten Hopp f1181b
  
Karsten Hopp f1181b
      tabpage_move(tab_number);
Karsten Hopp f1181b
  }
Karsten Hopp f1181b
--- 8166,8203 ----
Karsten Hopp f1181b
  	else
Karsten Hopp f1181b
  	    p = eap->arg;
Karsten Hopp f1181b
  
Karsten Hopp f1181b
! 	if (relative == 0)
Karsten Hopp f1181b
  	{
Karsten Hopp f1181b
! 	    if (STRCMP(p, "$") == 0)
Karsten Hopp f1181b
! 		tab_number = LAST_TAB_NR;
Karsten Hopp f1181b
! 	    else if (p == skipdigits(p))
Karsten Hopp f1181b
! 	    {
Karsten Hopp f1181b
! 		/* No numbers as argument. */
Karsten Hopp f1181b
! 		eap->errmsg = e_invarg;
Karsten Hopp f1181b
! 		return;
Karsten Hopp f1181b
! 	    }
Karsten Hopp f1181b
! 	    else
Karsten Hopp f1181b
! 		tab_number = getdigits(&p);
Karsten Hopp f1181b
! 	}
Karsten Hopp f1181b
! 	else
Karsten Hopp f1181b
! 	{
Karsten Hopp f1181b
! 	    if (*p != NUL)
Karsten Hopp f1181b
! 		tab_number = getdigits(&p);
Karsten Hopp f1181b
! 	    else
Karsten Hopp f1181b
! 		tab_number = 1;
Karsten Hopp f1181b
! 	    tab_number = tab_number * relative + tabpage_index(curtab);
Karsten Hopp f1181b
! 	    if (relative == -1)
Karsten Hopp f1181b
! 		--tab_number;
Karsten Hopp f1181b
  	}
Karsten Hopp f1181b
      }
Karsten Hopp f1181b
      else if (eap->addr_count != 0)
Karsten Hopp f1181b
+     {
Karsten Hopp f1181b
  	tab_number = eap->line2;
Karsten Hopp f1181b
+ 	if (**eap->cmdlinep == '-')
Karsten Hopp f1181b
+ 	    --tab_number;
Karsten Hopp f1181b
+     }
Karsten Hopp f1181b
+     else
Karsten Hopp f1181b
+ 	tab_number = LAST_TAB_NR;
Karsten Hopp f1181b
  
Karsten Hopp f1181b
      tabpage_move(tab_number);
Karsten Hopp f1181b
  }
Karsten Hopp f1181b
*** ../vim-7.4.708/src/testdir/test62.in	2015-01-07 15:57:13.145559792 +0100
Karsten Hopp f1181b
--- src/testdir/test62.in	2015-04-21 18:01:15.231247887 +0200
Karsten Hopp f1181b
***************
Karsten Hopp f1181b
*** 96,125 ****
Karsten Hopp f1181b
  :"
Karsten Hopp f1181b
  :for i in range(9) | tabnew | endfor
Karsten Hopp f1181b
  1gt
Karsten Hopp f1181b
! Go?=tabpagenr()

?
Karsten Hopp f1181b
  :tabmove 5
Karsten Hopp f1181b
! i?=tabpagenr()

?
Karsten Hopp f1181b
  :tabmove -2
Karsten Hopp f1181b
! i?=tabpagenr()

?
Karsten Hopp f1181b
  :tabmove +4
Karsten Hopp f1181b
! i?=tabpagenr()

?
Karsten Hopp f1181b
  :tabmove
Karsten Hopp f1181b
! i?=tabpagenr()

?
Karsten Hopp f1181b
  :tabmove -20
Karsten Hopp f1181b
! i?=tabpagenr()

?
Karsten Hopp f1181b
  :tabmove +20
Karsten Hopp f1181b
! i?=tabpagenr()

?
Karsten Hopp f1181b
  :3tabmove
Karsten Hopp f1181b
! i?=tabpagenr()

?
Karsten Hopp f1181b
  :7tabmove 5
Karsten Hopp f1181b
! i?=tabpagenr()

?
Karsten Hopp f1181b
  :let a='No error caught.'
Karsten Hopp f1181b
  :try
Karsten Hopp f1181b
  :tabmove foo
Karsten Hopp f1181b
  :catch E474
Karsten Hopp f1181b
  :let a='E474 caught.'
Karsten Hopp f1181b
  :endtry
Karsten Hopp f1181b
! i?=a
?
Karsten Hopp f1181b
  :"
Karsten Hopp f1181b
  :" Test autocommands
Karsten Hopp f1181b
  :tabonly!
Karsten Hopp f1181b
--- 96,139 ----
Karsten Hopp f1181b
  :"
Karsten Hopp f1181b
  :for i in range(9) | tabnew | endfor
Karsten Hopp f1181b
  1gt
Karsten Hopp f1181b
! :$put =tabpagenr()
Karsten Hopp f1181b
  :tabmove 5
Karsten Hopp f1181b
! :$put =tabpagenr()
Karsten Hopp f1181b
! :.tabmove
Karsten Hopp f1181b
! :$put =tabpagenr()
Karsten Hopp f1181b
! :tabmove -
Karsten Hopp f1181b
! :$put =tabpagenr()
Karsten Hopp f1181b
! :tabmove +
Karsten Hopp f1181b
! :$put =tabpagenr()
Karsten Hopp f1181b
  :tabmove -2
Karsten Hopp f1181b
! :$put =tabpagenr()
Karsten Hopp f1181b
  :tabmove +4
Karsten Hopp f1181b
! :$put =tabpagenr()
Karsten Hopp f1181b
  :tabmove
Karsten Hopp f1181b
! :$put =tabpagenr()
Karsten Hopp f1181b
  :tabmove -20
Karsten Hopp f1181b
! :$put =tabpagenr()
Karsten Hopp f1181b
  :tabmove +20
Karsten Hopp f1181b
! :$put =tabpagenr()
Karsten Hopp f1181b
! :0tabmove
Karsten Hopp f1181b
! :$put =tabpagenr()
Karsten Hopp f1181b
! :$tabmove
Karsten Hopp f1181b
! :$put =tabpagenr()
Karsten Hopp f1181b
! :tabmove 0
Karsten Hopp f1181b
! :$put =tabpagenr()
Karsten Hopp f1181b
! :tabmove $
Karsten Hopp f1181b
! :$put =tabpagenr()
Karsten Hopp f1181b
  :3tabmove
Karsten Hopp f1181b
! :$put =tabpagenr()
Karsten Hopp f1181b
  :7tabmove 5
Karsten Hopp f1181b
! :$put =tabpagenr()
Karsten Hopp f1181b
  :let a='No error caught.'
Karsten Hopp f1181b
  :try
Karsten Hopp f1181b
  :tabmove foo
Karsten Hopp f1181b
  :catch E474
Karsten Hopp f1181b
  :let a='E474 caught.'
Karsten Hopp f1181b
  :endtry
Karsten Hopp f1181b
! :$put =a
Karsten Hopp f1181b
  :"
Karsten Hopp f1181b
  :" Test autocommands
Karsten Hopp f1181b
  :tabonly!
Karsten Hopp f1181b
*** ../vim-7.4.708/src/testdir/test62.ok	2013-07-14 12:16:20.000000000 +0200
Karsten Hopp f1181b
--- src/testdir/test62.ok	2015-04-21 18:01:15.231247887 +0200
Karsten Hopp f1181b
***************
Karsten Hopp f1181b
*** 9,22 ****
Karsten Hopp f1181b
  tab drop 2: pass
Karsten Hopp f1181b
  tab drop 3: pass
Karsten Hopp f1181b
  1
Karsten Hopp f1181b
! 6
Karsten Hopp f1181b
  4
Karsten Hopp f1181b
! 8
Karsten Hopp f1181b
  10
Karsten Hopp f1181b
  1
Karsten Hopp f1181b
  10
Karsten Hopp f1181b
  4
Karsten Hopp f1181b
! 6
Karsten Hopp f1181b
  E474 caught.
Karsten Hopp f1181b
  === tab split ===
Karsten Hopp f1181b
  WinLeave
Karsten Hopp f1181b
--- 9,29 ----
Karsten Hopp f1181b
  tab drop 2: pass
Karsten Hopp f1181b
  tab drop 3: pass
Karsten Hopp f1181b
  1
Karsten Hopp f1181b
! 5
Karsten Hopp f1181b
! 5
Karsten Hopp f1181b
  4
Karsten Hopp f1181b
! 5
Karsten Hopp f1181b
! 3
Karsten Hopp f1181b
! 7
Karsten Hopp f1181b
! 10
Karsten Hopp f1181b
! 1
Karsten Hopp f1181b
! 10
Karsten Hopp f1181b
! 1
Karsten Hopp f1181b
  10
Karsten Hopp f1181b
  1
Karsten Hopp f1181b
  10
Karsten Hopp f1181b
  4
Karsten Hopp f1181b
! 5
Karsten Hopp f1181b
  E474 caught.
Karsten Hopp f1181b
  === tab split ===
Karsten Hopp f1181b
  WinLeave
Karsten Hopp f1181b
*** ../vim-7.4.708/src/version.c	2015-04-21 16:48:55.028917216 +0200
Karsten Hopp f1181b
--- src/version.c	2015-04-21 18:00:49.083525577 +0200
Karsten Hopp f1181b
***************
Karsten Hopp f1181b
*** 743,744 ****
Karsten Hopp f1181b
--- 743,746 ----
Karsten Hopp f1181b
  {   /* Add new patch number below this line */
Karsten Hopp f1181b
+ /**/
Karsten Hopp f1181b
+     709,
Karsten Hopp f1181b
  /**/
Karsten Hopp f1181b
Karsten Hopp f1181b
-- 
Karsten Hopp f1181b
BEDEVERE:        Why do you think she is a witch?
Karsten Hopp f1181b
SECOND VILLAGER: She turned me into a newt.
Karsten Hopp f1181b
BEDEVERE:        A newt?
Karsten Hopp f1181b
SECOND VILLAGER: (After looking at himself for some time) I got better.
Karsten Hopp f1181b
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp f1181b
Karsten Hopp f1181b
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp f1181b
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp f1181b
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp f1181b
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///