comparison src/normal.c @ 16742:75b5d77bbbab v8.1.1373

patch 8.1.1373: "[p" in Visual mode puts in wrong line commit https://github.com/vim/vim/commit/0ab190c05706b1c72e6e2ca4d990febfa81cf886 Author: Bram Moolenaar <Bram@vim.org> Date: Thu May 23 23:27:36 2019 +0200 patch 8.1.1373: "[p" in Visual mode puts in wrong line Problem: "[p" in Visual mode puts in wrong line. Solution: Call nv_put() instead of duplicating the functionality. (closes #4408)
author Bram Moolenaar <Bram@vim.org>
date Thu, 23 May 2019 23:30:04 +0200
parents 7e733046db1d
children ce04ebdf26b8
comparison
equal deleted inserted replaced
16741:3dcc912c8fef 16742:75b5d77bbbab
141 static void nv_record(cmdarg_T *cap); 141 static void nv_record(cmdarg_T *cap);
142 static void nv_at(cmdarg_T *cap); 142 static void nv_at(cmdarg_T *cap);
143 static void nv_halfpage(cmdarg_T *cap); 143 static void nv_halfpage(cmdarg_T *cap);
144 static void nv_join(cmdarg_T *cap); 144 static void nv_join(cmdarg_T *cap);
145 static void nv_put(cmdarg_T *cap); 145 static void nv_put(cmdarg_T *cap);
146 static void nv_put_opt(cmdarg_T *cap, int fix_indent);
146 static void nv_open(cmdarg_T *cap); 147 static void nv_open(cmdarg_T *cap);
147 #ifdef FEAT_NETBEANS_INTG 148 #ifdef FEAT_NETBEANS_INTG
148 static void nv_nbcmd(cmdarg_T *cap); 149 static void nv_nbcmd(cmdarg_T *cap);
149 #endif 150 #endif
150 #ifdef FEAT_DND 151 #ifdef FEAT_DND
6581 /* 6582 /*
6582 * "[p", "[P", "]P" and "]p": put with indent adjustment 6583 * "[p", "[P", "]P" and "]p": put with indent adjustment
6583 */ 6584 */
6584 else if (cap->nchar == 'p' || cap->nchar == 'P') 6585 else if (cap->nchar == 'p' || cap->nchar == 'P')
6585 { 6586 {
6586 if (!checkclearop(cap->oap)) 6587 nv_put_opt(cap, TRUE);
6587 {
6588 int dir = (cap->cmdchar == ']' && cap->nchar == 'p')
6589 ? FORWARD : BACKWARD;
6590 int regname = cap->oap->regname;
6591 int was_visual = VIsual_active;
6592 int line_count = curbuf->b_ml.ml_line_count;
6593 pos_T start, end;
6594
6595 if (VIsual_active)
6596 {
6597 start = LTOREQ_POS(VIsual, curwin->w_cursor)
6598 ? VIsual : curwin->w_cursor;
6599 end = EQUAL_POS(start,VIsual) ? curwin->w_cursor : VIsual;
6600 curwin->w_cursor = (dir == BACKWARD ? start : end);
6601 }
6602 # ifdef FEAT_CLIPBOARD
6603 adjust_clip_reg(&regname);
6604 # endif
6605 prep_redo_cmd(cap);
6606
6607 do_put(regname, dir, cap->count1, PUT_FIXINDENT);
6608 if (was_visual)
6609 {
6610 VIsual = start;
6611 curwin->w_cursor = end;
6612 if (dir == BACKWARD)
6613 {
6614 /* adjust lines */
6615 VIsual.lnum += curbuf->b_ml.ml_line_count - line_count;
6616 curwin->w_cursor.lnum +=
6617 curbuf->b_ml.ml_line_count - line_count;
6618 }
6619
6620 VIsual_active = TRUE;
6621 if (VIsual_mode == 'V')
6622 {
6623 /* delete visually selected lines */
6624 cap->cmdchar = 'd';
6625 cap->nchar = NUL;
6626 cap->oap->regname = regname;
6627 nv_operator(cap);
6628 do_pending_operator(cap, 0, FALSE);
6629 }
6630 if (VIsual_active)
6631 {
6632 end_visual_mode();
6633 redraw_later(SOME_VALID);
6634 }
6635 }
6636 }
6637 } 6588 }
6638 6589
6639 /* 6590 /*
6640 * "['", "[`", "]'" and "]`": jump to next mark 6591 * "['", "[`", "]'" and "]`": jump to next mark
6641 */ 6592 */
9288 * "P", "gP", "p" and "gp" commands. 9239 * "P", "gP", "p" and "gp" commands.
9289 */ 9240 */
9290 static void 9241 static void
9291 nv_put(cmdarg_T *cap) 9242 nv_put(cmdarg_T *cap)
9292 { 9243 {
9244 nv_put_opt(cap, FALSE);
9245 }
9246
9247 /*
9248 * "P", "gP", "p" and "gp" commands.
9249 * "fix_indent" is TRUE for "[p", "[P", "]p" and "]P".
9250 */
9251 static void
9252 nv_put_opt(cmdarg_T *cap, int fix_indent)
9253 {
9293 int regname = 0; 9254 int regname = 0;
9294 void *reg1 = NULL, *reg2 = NULL; 9255 void *reg1 = NULL, *reg2 = NULL;
9295 int empty = FALSE; 9256 int empty = FALSE;
9296 int was_visual = FALSE; 9257 int was_visual = FALSE;
9297 int dir; 9258 int dir;
9316 clearopbeep(cap->oap); 9277 clearopbeep(cap->oap);
9317 } 9278 }
9318 #endif 9279 #endif
9319 else 9280 else
9320 { 9281 {
9321 dir = (cap->cmdchar == 'P' 9282 if (fix_indent)
9322 || (cap->cmdchar == 'g' && cap->nchar == 'P')) 9283 {
9284 dir = (cap->cmdchar == ']' && cap->nchar == 'p')
9285 ? FORWARD : BACKWARD;
9286 flags |= PUT_FIXINDENT;
9287 }
9288 else
9289 dir = (cap->cmdchar == 'P'
9290 || (cap->cmdchar == 'g' && cap->nchar == 'P'))
9323 ? BACKWARD : FORWARD; 9291 ? BACKWARD : FORWARD;
9324 prep_redo_cmd(cap); 9292 prep_redo_cmd(cap);
9325 if (cap->cmdchar == 'g') 9293 if (cap->cmdchar == 'g')
9326 flags |= PUT_CURSEND; 9294 flags |= PUT_CURSEND;
9327 9295