Skip to content

Commit cce713d

Browse files
committed
patch 8.1.0992: a :normal command resets the reg_executing() result
Problem: A :normal command while executing a register resets the reg_executing() result. Solution: Save and restore reg_executing. (closes #4066)
1 parent 975880b commit cce713d

4 files changed

Lines changed: 25 additions & 11 deletions

File tree

src/ex_docmd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10260,6 +10260,7 @@ save_current_state(save_state_T *sst)
1026010260
sst->save_insertmode = p_im;
1026110261
sst->save_finish_op = finish_op;
1026210262
sst->save_opcount = opcount;
10263+
sst->save_reg_executing = reg_executing;
1026310264

1026410265
msg_scroll = FALSE; /* no msg scrolling in Normal mode */
1026510266
restart_edit = 0; /* don't go to Insert mode */
@@ -10285,6 +10286,7 @@ restore_current_state(save_state_T *sst)
1028510286
p_im = sst->save_insertmode;
1028610287
finish_op = sst->save_finish_op;
1028710288
opcount = sst->save_opcount;
10289+
reg_executing = sst->save_reg_executing;
1028810290
msg_didout |= sst->save_msg_didout; /* don't reset msg_didout now */
1028910291

1029010292
/* Restore the state (needed when called from a function executed for

src/structs.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,19 +2625,19 @@ typedef struct w_line
26252625
*/
26262626
struct frame_S
26272627
{
2628-
char fr_layout; /* FR_LEAF, FR_COL or FR_ROW */
2628+
char fr_layout; // FR_LEAF, FR_COL or FR_ROW
26292629
int fr_width;
2630-
int fr_newwidth; /* new width used in win_equal_rec() */
2630+
int fr_newwidth; // new width used in win_equal_rec()
26312631
int fr_height;
2632-
int fr_newheight; /* new height used in win_equal_rec() */
2633-
frame_T *fr_parent; /* containing frame or NULL */
2634-
frame_T *fr_next; /* frame right or below in same parent, NULL
2635-
for first */
2636-
frame_T *fr_prev; /* frame left or above in same parent, NULL
2637-
for last */
2638-
/* fr_child and fr_win are mutually exclusive */
2639-
frame_T *fr_child; /* first contained frame */
2640-
win_T *fr_win; /* window that fills this frame */
2632+
int fr_newheight; // new height used in win_equal_rec()
2633+
frame_T *fr_parent; // containing frame or NULL
2634+
frame_T *fr_next; // frame right or below in same parent, NULL
2635+
// for last
2636+
frame_T *fr_prev; // frame left or above in same parent, NULL
2637+
// for first
2638+
// fr_child and fr_win are mutually exclusive
2639+
frame_T *fr_child; // first contained frame
2640+
win_T *fr_win; // window that fills this frame
26412641
};
26422642

26432643
#define FR_LEAF 0 /* frame is a leaf */
@@ -3527,6 +3527,7 @@ typedef struct {
35273527
int save_insertmode;
35283528
int save_finish_op;
35293529
int save_opcount;
3530+
int save_reg_executing;
35303531
tasave_T tabuf;
35313532
} save_state_T;
35323533

src/testdir/test_functions.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,15 @@ func Test_reg_executing_and_recording()
11371137
call feedkeys("q\"\"=s:save_reg_stat()\<CR>pq", 'xt')
11381138
call assert_equal('":', s:reg_stat)
11391139

1140+
" :normal command saves and restores reg_executing
1141+
let @q = ":call TestFunc()\<CR>:call s:save_reg_stat()\<CR>"
1142+
func TestFunc() abort
1143+
normal! ia
1144+
endfunc
1145+
call feedkeys("@q", 'xt')
1146+
call assert_equal(':q', s:reg_stat)
1147+
delfunc TestFunc
1148+
11401149
bwipe!
11411150
delfunc s:save_reg_stat
11421151
unlet s:reg_stat

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,8 @@ static char *(features[]) =
779779

780780
static int included_patches[] =
781781
{ /* Add new patch number below this line */
782+
/**/
783+
992,
782784
/**/
783785
991,
784786
/**/

0 commit comments

Comments
 (0)