Blob Blame History Raw
To: vim-dev@vim.org
Subject: Patch 7.0.141
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.0.141
Problem:    When pasting a while line on the command line an extra CR is added
	    literally.
Solution:   Don't add the trailing CR when pasting with the mouse.
Files:	    src/ex_getln.c, src/proto/ops.pro, src/ops.c


*** ../vim-7.0.140/src/ex_getln.c	Thu Sep 14 11:27:12 2006
--- src/ex_getln.c	Sun Oct 15 16:17:20 2006
***************
*** 86,92 ****
  static void	draw_cmdline __ARGS((int start, int len));
  static void	save_cmdline __ARGS((struct cmdline_info *ccp));
  static void	restore_cmdline __ARGS((struct cmdline_info *ccp));
! static int	cmdline_paste __ARGS((int regname, int literally));
  #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
  static void	redrawcmd_preedit __ARGS((void));
  #endif
--- 86,92 ----
  static void	draw_cmdline __ARGS((int start, int len));
  static void	save_cmdline __ARGS((struct cmdline_info *ccp));
  static void	restore_cmdline __ARGS((struct cmdline_info *ccp));
! static int	cmdline_paste __ARGS((int regname, int literally, int remcr));
  #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
  static void	redrawcmd_preedit __ARGS((void));
  #endif
***************
*** 1116,1122 ****
  #endif
  		if (c != ESC)	    /* use ESC to cancel inserting register */
  		{
! 		    cmdline_paste(c, i == Ctrl_R);
  
  #ifdef FEAT_EVAL
  		    /* When there was a serious error abort getting the
--- 1116,1122 ----
  #endif
  		if (c != ESC)	    /* use ESC to cancel inserting register */
  		{
! 		    cmdline_paste(c, i == Ctrl_R, FALSE);
  
  #ifdef FEAT_EVAL
  		    /* When there was a serious error abort getting the
***************
*** 1231,1246 ****
  			goto cmdline_not_changed;   /* Ignore mouse */
  # ifdef FEAT_CLIPBOARD
  		if (clip_star.available)
! 		    cmdline_paste('*', TRUE);
  		else
  # endif
! 		    cmdline_paste(0, TRUE);
  		redrawcmd();
  		goto cmdline_changed;
  
  # ifdef FEAT_DND
  	case K_DROP:
! 		cmdline_paste('~', TRUE);
  		redrawcmd();
  		goto cmdline_changed;
  # endif
--- 1231,1246 ----
  			goto cmdline_not_changed;   /* Ignore mouse */
  # ifdef FEAT_CLIPBOARD
  		if (clip_star.available)
! 		    cmdline_paste('*', TRUE, TRUE);
  		else
  # endif
! 		    cmdline_paste(0, TRUE, TRUE);
  		redrawcmd();
  		goto cmdline_changed;
  
  # ifdef FEAT_DND
  	case K_DROP:
! 		cmdline_paste('~', TRUE, FALSE);
  		redrawcmd();
  		goto cmdline_changed;
  # endif
***************
*** 2890,2898 ****
   * return FAIL for failure, OK otherwise
   */
      static int
! cmdline_paste(regname, literally)
      int regname;
      int literally;	/* Insert text literally instead of "as typed" */
  {
      long		i;
      char_u		*arg;
--- 2890,2899 ----
   * return FAIL for failure, OK otherwise
   */
      static int
! cmdline_paste(regname, literally, remcr)
      int regname;
      int literally;	/* Insert text literally instead of "as typed" */
+     int remcr;		/* remove trailing CR */
  {
      long		i;
      char_u		*arg;
***************
*** 2968,2974 ****
  	return OK;
      }
  
!     return cmdline_paste_reg(regname, literally);
  }
  
  /*
--- 2969,2975 ----
  	return OK;
      }
  
!     return cmdline_paste_reg(regname, literally, remcr);
  }
  
  /*
*** ../vim-7.0.140/src/proto/ops.pro	Sun Apr 30 20:25:07 2006
--- src/proto/ops.pro	Tue Oct 17 16:24:08 2006
***************
*** 20,26 ****
  extern int do_execreg __ARGS((int regname, int colon, int addcr));
  extern int insert_reg __ARGS((int regname, int literally));
  extern int get_spec_reg __ARGS((int regname, char_u **argp, int *allocated, int errmsg));
! extern int cmdline_paste_reg __ARGS((int regname, int literally));
  extern void adjust_clip_reg __ARGS((int *rp));
  extern int op_delete __ARGS((oparg_T *oap));
  extern int op_replace __ARGS((oparg_T *oap, int c));
--- 20,26 ----
  extern int do_execreg __ARGS((int regname, int colon, int addcr));
  extern int insert_reg __ARGS((int regname, int literally));
  extern int get_spec_reg __ARGS((int regname, char_u **argp, int *allocated, int errmsg));
! extern int cmdline_paste_reg __ARGS((int regname, int literally, int remcr));
  extern void adjust_clip_reg __ARGS((int *rp));
  extern int op_delete __ARGS((oparg_T *oap));
  extern int op_replace __ARGS((oparg_T *oap, int c));
*** ../vim-7.0.140/src/ops.c	Fri Oct  6 23:33:22 2006
--- src/ops.c	Sun Oct 15 16:43:54 2006
***************
*** 1480,1488 ****
   * return FAIL for failure, OK otherwise
   */
      int
! cmdline_paste_reg(regname, literally)
      int regname;
      int literally;	/* Insert text literally instead of "as typed" */
  {
      long	i;
  
--- 1481,1490 ----
   * return FAIL for failure, OK otherwise
   */
      int
! cmdline_paste_reg(regname, literally, remcr)
      int regname;
      int literally;	/* Insert text literally instead of "as typed" */
+     int remcr;		/* don't add trailing CR */
  {
      long	i;
  
***************
*** 1494,1501 ****
      {
  	cmdline_paste_str(y_current->y_array[i], literally);
  
! 	/* insert ^M between lines and after last line if type is MLINE */
! 	if (y_current->y_type == MLINE || i < y_current->y_size - 1)
  	    cmdline_paste_str((char_u *)"\r", literally);
  
  	/* Check for CTRL-C, in case someone tries to paste a few thousand
--- 1496,1508 ----
      {
  	cmdline_paste_str(y_current->y_array[i], literally);
  
! 	/* Insert ^M between lines and after last line if type is MLINE.
! 	 * Don't do this when "remcr" is TRUE and the next line is empty. */
! 	if (y_current->y_type == MLINE
! 		|| (i < y_current->y_size - 1
! 		    && !(remcr
! 			&& i == y_current->y_size - 2
! 			&& *y_current->y_array[i + 1] == NUL)))
  	    cmdline_paste_str((char_u *)"\r", literally);
  
  	/* Check for CTRL-C, in case someone tries to paste a few thousand
*** ../vim-7.0.140/src/version.c	Tue Oct 17 15:17:41 2006
--- src/version.c	Tue Oct 17 16:22:55 2006
***************
*** 668,669 ****
--- 668,671 ----
  {   /* Add new patch number below this line */
+ /**/
+     141,
  /**/

-- 
ERROR 047: Keyboard not found.  Press RETURN to continue.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///