jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone

Blame SOURCES/7.4.310

3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.310
3ef2ca
Fcc: outbox
3ef2ca
From: Bram Moolenaar <Bram@moolenaar.net>
3ef2ca
Mime-Version: 1.0
3ef2ca
Content-Type: text/plain; charset=UTF-8
3ef2ca
Content-Transfer-Encoding: 8bit
3ef2ca
------------
3ef2ca
3ef2ca
Patch 7.4.310
3ef2ca
Problem:    getpos()/setpos() don't include curswant.
3ef2ca
Solution:   Add a fifth number when getting/setting the cursor.
3ef2ca
Files:	    src/eval.c, src/testdir/test_eval.in, src/testdir/test_eval.ok,
3ef2ca
	    runtime/doc/eval.txt
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.309/src/eval.c	2014-05-22 18:59:54.506169240 +0200
3ef2ca
--- src/eval.c	2014-05-28 14:23:37.608099523 +0200
3ef2ca
***************
3ef2ca
*** 764,770 ****
3ef2ca
  static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv));
3ef2ca
  static void f_xor __ARGS((typval_T *argvars, typval_T *rettv));
3ef2ca
  
3ef2ca
! static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump));
3ef2ca
  static pos_T *var2fpos __ARGS((typval_T *varp, int dollar_lnum, int *fnum));
3ef2ca
  static int get_env_len __ARGS((char_u **arg));
3ef2ca
  static int get_id_len __ARGS((char_u **arg));
3ef2ca
--- 764,770 ----
3ef2ca
  static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv));
3ef2ca
  static void f_xor __ARGS((typval_T *argvars, typval_T *rettv));
3ef2ca
  
3ef2ca
! static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump, colnr_T *curswantp));
3ef2ca
  static pos_T *var2fpos __ARGS((typval_T *varp, int dollar_lnum, int *fnum));
3ef2ca
  static int get_env_len __ARGS((char_u **arg));
3ef2ca
  static int get_id_len __ARGS((char_u **arg));
3ef2ca
***************
3ef2ca
*** 9799,9812 ****
3ef2ca
      if (argvars[1].v_type == VAR_UNKNOWN)
3ef2ca
      {
3ef2ca
  	pos_T	    pos;
3ef2ca
  
3ef2ca
! 	if (list2fpos(argvars, &pos, NULL) == FAIL)
3ef2ca
  	    return;
3ef2ca
  	line = pos.lnum;
3ef2ca
  	col = pos.col;
3ef2ca
  #ifdef FEAT_VIRTUALEDIT
3ef2ca
  	coladd = pos.coladd;
3ef2ca
  #endif
3ef2ca
      }
3ef2ca
      else
3ef2ca
      {
3ef2ca
--- 9799,9815 ----
3ef2ca
      if (argvars[1].v_type == VAR_UNKNOWN)
3ef2ca
      {
3ef2ca
  	pos_T	    pos;
3ef2ca
+ 	colnr_T	    curswant = -1;
3ef2ca
  
3ef2ca
! 	if (list2fpos(argvars, &pos, NULL, &curswant) == FAIL)
3ef2ca
  	    return;
3ef2ca
  	line = pos.lnum;
3ef2ca
  	col = pos.col;
3ef2ca
  #ifdef FEAT_VIRTUALEDIT
3ef2ca
  	coladd = pos.coladd;
3ef2ca
  #endif
3ef2ca
+ 	if (curswant >= 0)
3ef2ca
+ 	    curwin->w_curswant = curswant - 1;
3ef2ca
      }
3ef2ca
      else
3ef2ca
      {
3ef2ca
***************
3ef2ca
*** 11770,11775 ****
3ef2ca
--- 11773,11780 ----
3ef2ca
  				(fp != NULL) ? (varnumber_T)fp->coladd :
3ef2ca
  #endif
3ef2ca
  							      (varnumber_T)0);
3ef2ca
+ 	if (fp == &curwin->w_cursor)
3ef2ca
+ 	    list_append_number(l, (varnumber_T)curwin->w_curswant + 1);
3ef2ca
      }
3ef2ca
      else
3ef2ca
  	rettv->vval.v_number = FALSE;
3ef2ca
***************
3ef2ca
*** 16751,16762 ****
3ef2ca
      pos_T	pos;
3ef2ca
      int		fnum;
3ef2ca
      char_u	*name;
3ef2ca
  
3ef2ca
      rettv->vval.v_number = -1;
3ef2ca
      name = get_tv_string_chk(argvars);
3ef2ca
      if (name != NULL)
3ef2ca
      {
3ef2ca
! 	if (list2fpos(&argvars[1], &pos, &fnum) == OK)
3ef2ca
  	{
3ef2ca
  	    if (--pos.col < 0)
3ef2ca
  		pos.col = 0;
3ef2ca
--- 16756,16768 ----
3ef2ca
      pos_T	pos;
3ef2ca
      int		fnum;
3ef2ca
      char_u	*name;
3ef2ca
+     colnr_T	curswant = -1;
3ef2ca
  
3ef2ca
      rettv->vval.v_number = -1;
3ef2ca
      name = get_tv_string_chk(argvars);
3ef2ca
      if (name != NULL)
3ef2ca
      {
3ef2ca
! 	if (list2fpos(&argvars[1], &pos, &fnum, &curswant) == OK)
3ef2ca
  	{
3ef2ca
  	    if (--pos.col < 0)
3ef2ca
  		pos.col = 0;
3ef2ca
***************
3ef2ca
*** 16766,16771 ****
3ef2ca
--- 16772,16779 ----
3ef2ca
  		if (fnum == curbuf->b_fnum)
3ef2ca
  		{
3ef2ca
  		    curwin->w_cursor = pos;
3ef2ca
+ 		    if (curswant >= 0)
3ef2ca
+ 			curwin->w_curswant = curswant - 1;
3ef2ca
  		    check_cursor();
3ef2ca
  		    rettv->vval.v_number = 0;
3ef2ca
  		}
3ef2ca
***************
3ef2ca
*** 19532,19552 ****
3ef2ca
   * validity.
3ef2ca
   */
3ef2ca
      static int
3ef2ca
! list2fpos(arg, posp, fnump)
3ef2ca
      typval_T	*arg;
3ef2ca
      pos_T	*posp;
3ef2ca
      int		*fnump;
3ef2ca
  {
3ef2ca
      list_T	*l = arg->vval.v_list;
3ef2ca
      long	i = 0;
3ef2ca
      long	n;
3ef2ca
  
3ef2ca
!     /* List must be: [fnum, lnum, col, coladd], where "fnum" is only there
3ef2ca
!      * when "fnump" isn't NULL and "coladd" is optional. */
3ef2ca
      if (arg->v_type != VAR_LIST
3ef2ca
  	    || l == NULL
3ef2ca
  	    || l->lv_len < (fnump == NULL ? 2 : 3)
3ef2ca
! 	    || l->lv_len > (fnump == NULL ? 3 : 4))
3ef2ca
  	return FAIL;
3ef2ca
  
3ef2ca
      if (fnump != NULL)
3ef2ca
--- 19540,19561 ----
3ef2ca
   * validity.
3ef2ca
   */
3ef2ca
      static int
3ef2ca
! list2fpos(arg, posp, fnump, curswantp)
3ef2ca
      typval_T	*arg;
3ef2ca
      pos_T	*posp;
3ef2ca
      int		*fnump;
3ef2ca
+     colnr_T	*curswantp;
3ef2ca
  {
3ef2ca
      list_T	*l = arg->vval.v_list;
3ef2ca
      long	i = 0;
3ef2ca
      long	n;
3ef2ca
  
3ef2ca
!     /* List must be: [fnum, lnum, col, coladd, curswant], where "fnum" is only
3ef2ca
!      * there when "fnump" isn't NULL; "coladd" and "curswant" are optional. */
3ef2ca
      if (arg->v_type != VAR_LIST
3ef2ca
  	    || l == NULL
3ef2ca
  	    || l->lv_len < (fnump == NULL ? 2 : 3)
3ef2ca
! 	    || l->lv_len > (fnump == NULL ? 4 : 5))
3ef2ca
  	return FAIL;
3ef2ca
  
3ef2ca
      if (fnump != NULL)
3ef2ca
***************
3ef2ca
*** 19570,19582 ****
3ef2ca
      posp->col = n;
3ef2ca
  
3ef2ca
  #ifdef FEAT_VIRTUALEDIT
3ef2ca
!     n = list_find_nr(l, i, NULL);
3ef2ca
      if (n < 0)
3ef2ca
  	posp->coladd = 0;
3ef2ca
      else
3ef2ca
  	posp->coladd = n;
3ef2ca
  #endif
3ef2ca
  
3ef2ca
      return OK;
3ef2ca
  }
3ef2ca
  
3ef2ca
--- 19579,19594 ----
3ef2ca
      posp->col = n;
3ef2ca
  
3ef2ca
  #ifdef FEAT_VIRTUALEDIT
3ef2ca
!     n = list_find_nr(l, i, NULL);	/* off */
3ef2ca
      if (n < 0)
3ef2ca
  	posp->coladd = 0;
3ef2ca
      else
3ef2ca
  	posp->coladd = n;
3ef2ca
  #endif
3ef2ca
  
3ef2ca
+     if (curswantp != NULL)
3ef2ca
+ 	*curswantp = list_find_nr(l, i + 1, NULL);  /* curswant */
3ef2ca
+ 
3ef2ca
      return OK;
3ef2ca
  }
3ef2ca
  
3ef2ca
*** ../vim-7.4.309/src/testdir/test_eval.in	2014-04-29 17:41:18.351689927 +0200
3ef2ca
--- src/testdir/test_eval.in	2014-05-28 14:22:31.780098947 +0200
3ef2ca
***************
3ef2ca
*** 190,198 ****
3ef2ca
--- 190,207 ----
3ef2ca
  :$put =v:exception
3ef2ca
  :endtry
3ef2ca
  :"
3ef2ca
+ :$put ='{{{1 setpos/getpos'
3ef2ca
+ /^012345678
3ef2ca
+ 6l:let sp = getpos('.')
3ef2ca
+ 0:call setpos('.', sp)
3ef2ca
+ jyl:$put
3ef2ca
+ :"
3ef2ca
  :/^start:/+1,$wq! test.out
3ef2ca
  :" vim: et ts=4 isk-=\: fmr=???,???
3ef2ca
  :call getchar()
3ef2ca
  ENDTEST
3ef2ca
  
3ef2ca
+ 012345678
3ef2ca
+ 012345678
3ef2ca
+ 
3ef2ca
  start:
3ef2ca
*** ../vim-7.4.309/src/testdir/test_eval.ok	2014-04-29 17:41:18.351689927 +0200
3ef2ca
--- src/testdir/test_eval.ok	2014-05-28 14:19:31.836097372 +0200
3ef2ca
***************
3ef2ca
*** 346,348 ****
3ef2ca
--- 346,350 ----
3ef2ca
  Bar exists: 1
3ef2ca
  func Bar exists: 1
3ef2ca
  Vim(call):E116: Invalid arguments for function append
3ef2ca
+ {{{1 setpos/getpos
3ef2ca
+ 6
3ef2ca
*** ../vim-7.4.309/runtime/doc/eval.txt	2014-05-07 18:35:25.661216052 +0200
3ef2ca
--- runtime/doc/eval.txt	2014-05-28 14:04:40.928089573 +0200
3ef2ca
***************
3ef2ca
*** 2587,2595 ****
3ef2ca
  cursor({list})
3ef2ca
  		Positions the cursor at the column (byte count) {col} in the
3ef2ca
  		line {lnum}.  The first column is one.
3ef2ca
  		When there is one argument {list} this is used as a |List|
3ef2ca
! 		with two or three items {lnum}, {col} and {off}.  This is like
3ef2ca
! 		the return value of |getpos()|, but without the first item.
3ef2ca
  		Does not change the jumplist.
3ef2ca
  		If {lnum} is greater than the number of lines in the buffer,
3ef2ca
  		the cursor will be positioned at the last line in the buffer.
3ef2ca
--- 2587,2600 ----
3ef2ca
  cursor({list})
3ef2ca
  		Positions the cursor at the column (byte count) {col} in the
3ef2ca
  		line {lnum}.  The first column is one.
3ef2ca
+ 
3ef2ca
  		When there is one argument {list} this is used as a |List|
3ef2ca
! 		with two, three or four item:
3ef2ca
! 			[{lnum}, {col}, {off}]
3ef2ca
! 			[{lnum}, {col}, {off}, {curswant}]
3ef2ca
! 		This is like the return value of |getpos()|, but without the
3ef2ca
! 		first item.
3ef2ca
! 
3ef2ca
  		Does not change the jumplist.
3ef2ca
  		If {lnum} is greater than the number of lines in the buffer,
3ef2ca
  		the cursor will be positioned at the last line in the buffer.
3ef2ca
***************
3ef2ca
*** 4475,4482 ****
3ef2ca
  							*getpos()*
3ef2ca
  getpos({expr})	Get the position for {expr}.  For possible values of {expr}
3ef2ca
  		see |line()|.
3ef2ca
! 		The result is a |List| with four numbers:
3ef2ca
  		    [bufnum, lnum, col, off]
3ef2ca
  		"bufnum" is zero, unless a mark like '0 or 'A is used, then it
3ef2ca
  		is the buffer number of the mark.
3ef2ca
  		"lnum" and "col" are the position in the buffer.  The first
3ef2ca
--- 4490,4498 ----
3ef2ca
  							*getpos()*
3ef2ca
  getpos({expr})	Get the position for {expr}.  For possible values of {expr}
3ef2ca
  		see |line()|.
3ef2ca
! 		The result is a |List| with four or five numbers:
3ef2ca
  		    [bufnum, lnum, col, off]
3ef2ca
+ 		    [bufnum, lnum, col, off, curswant]
3ef2ca
  		"bufnum" is zero, unless a mark like '0 or 'A is used, then it
3ef2ca
  		is the buffer number of the mark.
3ef2ca
  		"lnum" and "col" are the position in the buffer.  The first
3ef2ca
***************
3ef2ca
*** 4485,4490 ****
3ef2ca
--- 4501,4511 ----
3ef2ca
  		it is the offset in screen columns from the start of the
3ef2ca
  		character.  E.g., a position within a <Tab> or after the last
3ef2ca
  		character.
3ef2ca
+ 		The "curswant" number is only added for getpos('.'), it is the
3ef2ca
+ 		preferred column when moving the cursor vertically.
3ef2ca
+ 		Note that for '< and '> Visual mode matters: when it is "V"
3ef2ca
+ 		(visual line mode) the column of '< is zero and the column of
3ef2ca
+ 		'> is a large number.
3ef2ca
  		This can be used to save and restore the cursor position: >
3ef2ca
  			let save_cursor = getpos(".")
3ef2ca
  			MoveTheCursorAround
3ef2ca
***************
3ef2ca
*** 5289,5296 ****
3ef2ca
  			.	the cursor
3ef2ca
  			'x	mark x
3ef2ca
  
3ef2ca
! 		{list} must be a |List| with four numbers:
3ef2ca
  		    [bufnum, lnum, col, off]
3ef2ca
  
3ef2ca
  		"bufnum" is the buffer number.	Zero can be used for the
3ef2ca
  		current buffer.  Setting the cursor is only possible for
3ef2ca
--- 5310,5318 ----
3ef2ca
  			.	the cursor
3ef2ca
  			'x	mark x
3ef2ca
  
3ef2ca
! 		{list} must be a |List| with four or five numbers:
3ef2ca
  		    [bufnum, lnum, col, off]
3ef2ca
+ 		    [bufnum, lnum, col, off, curswant]
3ef2ca
  
3ef2ca
  		"bufnum" is the buffer number.	Zero can be used for the
3ef2ca
  		current buffer.  Setting the cursor is only possible for
3ef2ca
***************
3ef2ca
*** 5308,5320 ****
3ef2ca
  		character.  E.g., a position within a <Tab> or after the last
3ef2ca
  		character.
3ef2ca
  
3ef2ca
  		Returns 0 when the position could be set, -1 otherwise.
3ef2ca
  		An error message is given if {expr} is invalid.
3ef2ca
  
3ef2ca
  		Also see |getpos()|
3ef2ca
  
3ef2ca
  		This does not restore the preferred column for moving
3ef2ca
! 		vertically.  See |winrestview()| for that.
3ef2ca
  
3ef2ca
  
3ef2ca
  setqflist({list} [, {action}])				*setqflist()*
3ef2ca
--- 5330,5355 ----
3ef2ca
  		character.  E.g., a position within a <Tab> or after the last
3ef2ca
  		character.
3ef2ca
  
3ef2ca
+ 		The "curswant" number is only used when setting the cursor
3ef2ca
+ 		position.  It sets the preferred column for when moving the
3ef2ca
+ 		cursor vertically.  When the "curswant" number is missing the
3ef2ca
+ 		preferred column is not set.  When it is present and setting a
3ef2ca
+ 		mark position it is not used.
3ef2ca
+ 
3ef2ca
+ 		Note that for '< and '> changing the line number may result in
3ef2ca
+ 		the marks to be effectively be swapped, so that '< is always
3ef2ca
+ 		before '>.
3ef2ca
+ 
3ef2ca
  		Returns 0 when the position could be set, -1 otherwise.
3ef2ca
  		An error message is given if {expr} is invalid.
3ef2ca
  
3ef2ca
  		Also see |getpos()|
3ef2ca
  
3ef2ca
  		This does not restore the preferred column for moving
3ef2ca
! 		vertically; if you set the cursor position with this, |j| and
3ef2ca
! 		|k| motions will jump to previous columns!  Use |cursor()| to
3ef2ca
! 		also set the preferred column.  Also see the "curswant" key in
3ef2ca
! 		|winrestview()|.
3ef2ca
  
3ef2ca
  
3ef2ca
  setqflist({list} [, {action}])				*setqflist()*
3ef2ca
*** ../vim-7.4.309/src/version.c	2014-05-28 13:42:59.884078184 +0200
3ef2ca
--- src/version.c	2014-05-28 14:27:20.132101471 +0200
3ef2ca
***************
3ef2ca
*** 736,737 ****
3ef2ca
--- 736,739 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     310,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
hundred-and-one symptoms of being an internet addict:
3ef2ca
218. Your spouse hands you a gift wrapped magnet with your PC's name
3ef2ca
     on it and you accuse him or her of genocide.
3ef2ca
3ef2ca
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3ef2ca
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3ef2ca
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3ef2ca
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///