comparison src/normal.c @ 27428:3f8a57b8c7d8 v8.2.4242

patch 8.2.4242: put in Visual mode cannot be repeated Commit: https://github.com/vim/vim/commit/fb55207ed17918c8a2a6cadf5ad9d5fcf686a7ab Author: Shougo Matsushita <Shougo.Matsu@gmail.com> Date: Fri Jan 28 16:01:13 2022 +0000 patch 8.2.4242: put in Visual mode cannot be repeated 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)
author Bram Moolenaar <Bram@vim.org>
date Fri, 28 Jan 2022 17:15:03 +0100
parents 41e0dcf38521
children 4050f0554902
comparison
equal deleted inserted replaced
27427:9cf9ba0101f6 27428:3f8a57b8c7d8
4659 new_pos = curwin->w_cursor; 4659 new_pos = curwin->w_cursor;
4660 pos = &new_pos; 4660 pos = &new_pos;
4661 } 4661 }
4662 // found start/end of other method: go to match 4662 // found start/end of other method: go to match
4663 else if ((pos = findmatchlimit(cap->oap, findc, 4663 else if ((pos = findmatchlimit(cap->oap, findc,
4664 (cap->cmdchar == '[') ? FM_BACKWARD : FM_FORWARD, 4664 (cap->cmdchar == '[') ? FM_BACKWARD : FM_FORWARD,
4665 0)) == NULL) 4665 0)) == NULL)
4666 n = 0; 4666 n = 0;
4667 else 4667 else
4668 curwin->w_cursor = *pos; 4668 curwin->w_cursor = *pos;
4669 break; 4669 break;
4670 } 4670 }
7503 void *reg1 = NULL, *reg2 = NULL; 7503 void *reg1 = NULL, *reg2 = NULL;
7504 int empty = FALSE; 7504 int empty = FALSE;
7505 int was_visual = FALSE; 7505 int was_visual = FALSE;
7506 int dir; 7506 int dir;
7507 int flags = 0; 7507 int flags = 0;
7508 int save_unnamed = FALSE;
7509 yankreg_T *old_y_current, *old_y_previous;
7508 7510
7509 if (cap->oap->op_type != OP_NOP) 7511 if (cap->oap->op_type != OP_NOP)
7510 { 7512 {
7511 #ifdef FEAT_DIFF 7513 #ifdef FEAT_DIFF
7512 // "dp" is ":diffput" 7514 // "dp" is ":diffput"
7549 // text. First delete the selected text, then put the new text. 7551 // text. First delete the selected text, then put the new text.
7550 // Need to save and restore the registers that the delete 7552 // Need to save and restore the registers that the delete
7551 // overwrites if the old contents is being put. 7553 // overwrites if the old contents is being put.
7552 was_visual = TRUE; 7554 was_visual = TRUE;
7553 regname = cap->oap->regname; 7555 regname = cap->oap->regname;
7556 save_unnamed = cap->cmdchar == 'P';
7554 #ifdef FEAT_CLIPBOARD 7557 #ifdef FEAT_CLIPBOARD
7555 adjust_clip_reg(&regname); 7558 adjust_clip_reg(&regname);
7556 #endif 7559 #endif
7557 if (regname == 0 || regname == '"' 7560 if (regname == 0 || regname == '"'
7558 || VIM_ISDIGIT(regname) || regname == '-' 7561 || VIM_ISDIGIT(regname) || regname == '-'
7566 // put, save it first. 7569 // put, save it first.
7567 reg1 = get_register(regname, TRUE); 7570 reg1 = get_register(regname, TRUE);
7568 } 7571 }
7569 7572
7570 // Now delete the selected text. Avoid messages here. 7573 // Now delete the selected text. Avoid messages here.
7574 if (save_unnamed)
7575 {
7576 old_y_current = get_y_current();
7577 old_y_previous = get_y_previous();
7578 }
7571 cap->cmdchar = 'd'; 7579 cap->cmdchar = 'd';
7572 cap->nchar = NUL; 7580 cap->nchar = NUL;
7573 cap->oap->regname = NUL; 7581 cap->oap->regname = NUL;
7574 ++msg_silent; 7582 ++msg_silent;
7575 nv_operator(cap); 7583 nv_operator(cap);
7576 do_pending_operator(cap, 0, FALSE); 7584 do_pending_operator(cap, 0, FALSE);
7577 empty = (curbuf->b_ml.ml_flags & ML_EMPTY); 7585 empty = (curbuf->b_ml.ml_flags & ML_EMPTY);
7578 --msg_silent; 7586 --msg_silent;
7587
7588 if (save_unnamed)
7589 {
7590 set_y_current(old_y_current);
7591 set_y_previous(old_y_previous);
7592 }
7579 7593
7580 // delete PUT_LINE_BACKWARD; 7594 // delete PUT_LINE_BACKWARD;
7581 cap->oap->regname = regname; 7595 cap->oap->regname = regname;
7582 7596
7583 if (reg1 != NULL) 7597 if (reg1 != NULL)