@@ -9050,6 +9050,34 @@ nv_edit(cmdarg_T *cap)
90509050 /* drop the pasted text */
90519051 bracketed_paste (PASTE_INSERT , TRUE, NULL );
90529052 }
9053+ else if (cap -> cmdchar == K_PS && VIsual_active )
9054+ {
9055+ pos_T old_pos = curwin -> w_cursor ;
9056+ pos_T old_visual = VIsual ;
9057+
9058+ /* In Visual mode the selected text is deleted. */
9059+ if (VIsual_mode == 'V' || curwin -> w_cursor .lnum != VIsual .lnum )
9060+ {
9061+ shift_delete_registers ();
9062+ cap -> oap -> regname = '1' ;
9063+ }
9064+ else
9065+ cap -> oap -> regname = '-' ;
9066+ cap -> cmdchar = 'd' ;
9067+ cap -> nchar = NUL ;
9068+ nv_operator (cap );
9069+ do_pending_operator (cap , 0 , FALSE);
9070+ cap -> cmdchar = K_PS ;
9071+
9072+ /* When the last char in the line was deleted then append. Detect this
9073+ * by checking if the cursor moved to before the Visual area. */
9074+ if (* ml_get_cursor () != NUL && lt (curwin -> w_cursor , old_pos )
9075+ && lt (curwin -> w_cursor , old_visual ))
9076+ inc_cursor ();
9077+
9078+ /* Insert to replace the deleted text with the pasted text. */
9079+ invoke_edit (cap , FALSE, cap -> cmdchar , FALSE);
9080+ }
90539081 else if (!checkclearopq (cap -> oap ))
90549082 {
90559083 switch (cap -> cmdchar )
@@ -9079,8 +9107,9 @@ nv_edit(cmdarg_T *cap)
90799107 beginline (BL_WHITE |BL_FIX );
90809108 break ;
90819109
9082- case K_PS : /* Bracketed paste works like "a"ppend, unless the
9083- cursor is in the first column, then it inserts. */
9110+ case K_PS :
9111+ /* Bracketed paste works like "a"ppend, unless the cursor is in
9112+ * the first column, then it inserts. */
90849113 if (curwin -> w_cursor .col == 0 )
90859114 break ;
90869115 /*FALLTHROUGH*/
0 commit comments