Mercurial > vim
comparison src/normal.c @ 28714:5eea8a249f86 v8.2.4881
patch 8.2.4881: "P" in Visual mode still changes some registers
Commit: https://github.com/vim/vim/commit/509142ab7a9db32114b6d0949722b9133c9c22f2
Author: Shougo Matsushita <Shougo.Matsu@gmail.com>
Date: Fri May 6 11:45:09 2022 +0100
patch 8.2.4881: "P" in Visual mode still changes some registers
Problem: "P" in Visual mode still changes some registers.
Solution: Make "P" in Visual mode not change any register. (Shougo
Matsushita, closes #10349)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 06 May 2022 13:00:03 +0200 |
parents | 9a2fb96475ed |
children | d770568e6c98 |
comparison
equal
deleted
inserted
replaced
28713:f608d3f98e0e | 28714:5eea8a249f86 |
---|---|
7234 void *reg1 = NULL, *reg2 = NULL; | 7234 void *reg1 = NULL, *reg2 = NULL; |
7235 int empty = FALSE; | 7235 int empty = FALSE; |
7236 int was_visual = FALSE; | 7236 int was_visual = FALSE; |
7237 int dir; | 7237 int dir; |
7238 int flags = 0; | 7238 int flags = 0; |
7239 int save_unnamed = FALSE; | 7239 int keep_registers = FALSE; |
7240 yankreg_T *old_y_current, *old_y_previous; | |
7241 | 7240 |
7242 if (cap->oap->op_type != OP_NOP) | 7241 if (cap->oap->op_type != OP_NOP) |
7243 { | 7242 { |
7244 #ifdef FEAT_DIFF | 7243 #ifdef FEAT_DIFF |
7245 // "dp" is ":diffput" | 7244 // "dp" is ":diffput" |
7282 // text. First delete the selected text, then put the new text. | 7281 // text. First delete the selected text, then put the new text. |
7283 // Need to save and restore the registers that the delete | 7282 // Need to save and restore the registers that the delete |
7284 // overwrites if the old contents is being put. | 7283 // overwrites if the old contents is being put. |
7285 was_visual = TRUE; | 7284 was_visual = TRUE; |
7286 regname = cap->oap->regname; | 7285 regname = cap->oap->regname; |
7287 save_unnamed = cap->cmdchar == 'P'; | 7286 keep_registers = cap->cmdchar == 'P'; |
7288 #ifdef FEAT_CLIPBOARD | 7287 #ifdef FEAT_CLIPBOARD |
7289 adjust_clip_reg(®name); | 7288 adjust_clip_reg(®name); |
7290 #endif | 7289 #endif |
7291 if (regname == 0 || regname == '"' | 7290 if (regname == 0 || regname == '"' |
7292 || VIM_ISDIGIT(regname) || regname == '-' | 7291 || VIM_ISDIGIT(regname) || regname == '-' |
7300 // put, save it first. | 7299 // put, save it first. |
7301 reg1 = get_register(regname, TRUE); | 7300 reg1 = get_register(regname, TRUE); |
7302 } | 7301 } |
7303 | 7302 |
7304 // Now delete the selected text. Avoid messages here. | 7303 // Now delete the selected text. Avoid messages here. |
7305 if (save_unnamed) | |
7306 { | |
7307 old_y_current = get_y_current(); | |
7308 old_y_previous = get_y_previous(); | |
7309 } | |
7310 cap->cmdchar = 'd'; | 7304 cap->cmdchar = 'd'; |
7311 cap->nchar = NUL; | 7305 cap->nchar = NUL; |
7312 cap->oap->regname = NUL; | 7306 cap->oap->regname = keep_registers ? '_' : NUL; |
7313 ++msg_silent; | 7307 ++msg_silent; |
7314 nv_operator(cap); | 7308 nv_operator(cap); |
7315 do_pending_operator(cap, 0, FALSE); | 7309 do_pending_operator(cap, 0, FALSE); |
7316 empty = (curbuf->b_ml.ml_flags & ML_EMPTY); | 7310 empty = (curbuf->b_ml.ml_flags & ML_EMPTY); |
7317 --msg_silent; | 7311 --msg_silent; |
7318 | |
7319 if (save_unnamed) | |
7320 { | |
7321 set_y_current(old_y_current); | |
7322 set_y_previous(old_y_previous); | |
7323 } | |
7324 | 7312 |
7325 // delete PUT_LINE_BACKWARD; | 7313 // delete PUT_LINE_BACKWARD; |
7326 cap->oap->regname = regname; | 7314 cap->oap->regname = regname; |
7327 | 7315 |
7328 if (reg1 != NULL) | 7316 if (reg1 != NULL) |