diff src/normal.c @ 10827:e366b968bf08 v8.0.0303

patch 8.0.0303: bracketed paste does not work in Visual mode commit https://github.com/vim/vim/commit/a1891848d970452cd775d35a4bccfdd9758a690a Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 4 21:34:31 2017 +0100 patch 8.0.0303: bracketed paste does not work in Visual mode Problem: Bracketed paste does not work in Visual mode. Solution: Delete the text before pasting
author Christian Brabandt <cb@256bit.org>
date Sat, 04 Feb 2017 21:45:04 +0100
parents 09eb5fd275e0
children 5362b4b6042c
line wrap: on
line diff
--- a/src/normal.c
+++ b/src/normal.c
@@ -9050,6 +9050,34 @@ nv_edit(cmdarg_T *cap)
 	    /* drop the pasted text */
 	    bracketed_paste(PASTE_INSERT, TRUE, NULL);
     }
+    else if (cap->cmdchar == K_PS && VIsual_active)
+    {
+	pos_T old_pos = curwin->w_cursor;
+	pos_T old_visual = VIsual;
+
+	/* In Visual mode the selected text is deleted. */
+	if (VIsual_mode == 'V' || curwin->w_cursor.lnum != VIsual.lnum)
+	{
+	    shift_delete_registers();
+	    cap->oap->regname = '1';
+	}
+	else
+	    cap->oap->regname = '-';
+	cap->cmdchar = 'd';
+	cap->nchar = NUL;
+	nv_operator(cap);
+	do_pending_operator(cap, 0, FALSE);
+	cap->cmdchar = K_PS;
+
+	/* When the last char in the line was deleted then append. Detect this
+	 * by checking if the cursor moved to before the Visual area. */
+	if (*ml_get_cursor() != NUL && lt(curwin->w_cursor, old_pos)
+					   && lt(curwin->w_cursor, old_visual))
+	    inc_cursor();
+
+	/* Insert to replace the deleted text with the pasted text. */
+	invoke_edit(cap, FALSE, cap->cmdchar, FALSE);
+    }
     else if (!checkclearopq(cap->oap))
     {
 	switch (cap->cmdchar)
@@ -9079,8 +9107,9 @@ nv_edit(cmdarg_T *cap)
 		    beginline(BL_WHITE|BL_FIX);
 		break;
 
-	    case K_PS:	/* Bracketed paste works like "a"ppend, unless the
-			   cursor is in the first column, then it inserts. */
+	    case K_PS:
+		/* Bracketed paste works like "a"ppend, unless the cursor is in
+		 * the first column, then it inserts. */
 		if (curwin->w_cursor.col == 0)
 		    break;
 		/*FALLTHROUGH*/