To: vim_dev@googlegroups.com Subject: Patch 8.2.4242 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4242 Problem: Put in Visual mode cannot be repeated. Solution: Use "P" to put without yanking the deleted text into the unnamed register. (Shougo Matsushita, closes #9591) Files: runtime/doc/visual.txt, src/normal.c, src/register.c, src/testdir/test_visual.vim *** ../vim-8.2.4241/runtime/doc/visual.txt 2022-01-20 15:25:59.309844687 +0000 --- runtime/doc/visual.txt 2022-01-28 15:54:09.562159935 +0000 *************** *** 265,270 **** --- 265,271 ---- X delete (2) |v_X| Y yank (2) |v_Y| p put |v_p| + P put without unnamed register overwrite |v_P| J join (1) |v_J| U make uppercase |v_U| u make lowercase |v_u| *** ../vim-8.2.4241/src/normal.c 2022-01-28 15:28:00.208927722 +0000 --- src/normal.c 2022-01-28 15:59:34.561421255 +0000 *************** *** 4661,4668 **** } // found start/end of other method: go to match else if ((pos = findmatchlimit(cap->oap, findc, ! (cap->cmdchar == '[') ? FM_BACKWARD : FM_FORWARD, ! 0)) == NULL) n = 0; else curwin->w_cursor = *pos; --- 4661,4668 ---- } // found start/end of other method: go to match else if ((pos = findmatchlimit(cap->oap, findc, ! (cap->cmdchar == '[') ? FM_BACKWARD : FM_FORWARD, ! 0)) == NULL) n = 0; else curwin->w_cursor = *pos; *************** *** 7505,7510 **** --- 7505,7512 ---- int was_visual = FALSE; int dir; int flags = 0; + int save_unnamed = FALSE; + yankreg_T *old_y_current, *old_y_previous; if (cap->oap->op_type != OP_NOP) { *************** *** 7551,7556 **** --- 7553,7559 ---- // overwrites if the old contents is being put. was_visual = TRUE; regname = cap->oap->regname; + save_unnamed = cap->cmdchar == 'P'; #ifdef FEAT_CLIPBOARD adjust_clip_reg(®name); #endif *************** *** 7568,7573 **** --- 7571,7581 ---- } // Now delete the selected text. Avoid messages here. + if (save_unnamed) + { + old_y_current = get_y_current(); + old_y_previous = get_y_previous(); + } cap->cmdchar = 'd'; cap->nchar = NUL; cap->oap->regname = NUL; *************** *** 7577,7582 **** --- 7585,7596 ---- empty = (curbuf->b_ml.ml_flags & ML_EMPTY); --msg_silent; + if (save_unnamed) + { + set_y_current(old_y_current); + set_y_previous(old_y_previous); + } + // delete PUT_LINE_BACKWARD; cap->oap->regname = regname; *** ../vim-8.2.4241/src/register.c 2022-01-28 15:28:00.212927659 +0000 --- src/register.c 2022-01-28 15:59:46.705243352 +0000 *************** *** 54,90 **** } #endif - #if defined(FEAT_CLIPBOARD) || defined(FEAT_VIMINFO) || defined(FEAT_EVAL) || defined(PROTO) yankreg_T * get_y_current(void) { return y_current; } - #endif - #if defined(FEAT_CLIPBOARD) || defined(FEAT_VIMINFO) || defined(PROTO) yankreg_T * get_y_previous(void) { return y_previous; } - #endif - #if defined(FEAT_CLIPBOARD) || defined(PROTO) void set_y_current(yankreg_T *yreg) { y_current = yreg; } - #endif - #if defined(FEAT_CLIPBOARD) || defined(FEAT_VIMINFO) || defined(PROTO) void set_y_previous(yankreg_T *yreg) { y_previous = yreg; } - #endif void reset_y_append(void) --- 54,82 ---- *** ../vim-8.2.4241/src/testdir/test_visual.vim 2022-01-25 21:26:13.743440874 +0000 --- src/testdir/test_visual.vim 2022-01-28 15:54:09.562159935 +0000 *************** *** 1358,1365 **** --- 1358,1389 ---- exe "normal ggvjfxO" undo normal gNU + bwipe! endfunc + func Test_visual_paste() + new + + " v_p overwrites unnamed register. + call setline(1, ['xxxx']) + call setreg('"', 'foo') + call setreg('-', 'bar') + normal 1Gvp + call assert_equal(@", 'x') + call assert_equal(@-, 'x') + + if has('clipboard') + " v_P does not overwrite unnamed register. + call setline(1, ['xxxx']) + call setreg('"', 'foo') + call setreg('-', 'bar') + normal 1GvP + call assert_equal(@", 'foo') + call assert_equal(@-, 'x') + endif + + bwipe! + endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.4241/src/version.c 2022-01-28 15:28:00.216927600 +0000 --- src/version.c 2022-01-28 15:56:08.012438711 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4242, /**/ -- SOLDIER: What? Ridden on a horse? ARTHUR: Yes! SOLDIER: You're using coconuts! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///