aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/eval.c2
-rw-r--r--src/nvim/ex_cmds2.c2
-rw-r--r--src/nvim/getchar.c98
-rw-r--r--src/nvim/globals.h2
-rw-r--r--src/nvim/message.c2
-rw-r--r--src/nvim/testdir/test_put.vim13
6 files changed, 68 insertions, 51 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index e65a4d489c..d750a47588 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -11235,7 +11235,7 @@ void get_user_input(const typval_T *const argvars,
}
}
- int cmd_silent_save = cmd_silent;
+ const bool cmd_silent_save = cmd_silent;
cmd_silent = false; // Want to see the prompt.
// Only the part of the message after the last NL is considered as
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index f7da5b6c97..f5822535ba 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -123,7 +123,7 @@ void do_debug(char_u *cmd)
int save_msg_scroll = msg_scroll;
int save_State = State;
int save_did_emsg = did_emsg;
- int save_cmd_silent = cmd_silent;
+ const bool save_cmd_silent = cmd_silent;
int save_msg_silent = msg_silent;
int save_emsg_silent = emsg_silent;
int save_redir_off = redir_off;
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 0379b1cadb..df185f1a5b 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -448,7 +448,7 @@ void flush_buffers(int flush_typeahead)
}
typebuf.tb_maplen = 0;
typebuf.tb_silent = 0;
- cmd_silent = FALSE;
+ cmd_silent = false;
typebuf.tb_no_abbr_cnt = 0;
}
@@ -652,15 +652,13 @@ void stuffnumReadbuff(long n)
add_num_buff(&readbuf1, n);
}
-/*
- * Read a character from the redo buffer. Translates K_SPECIAL, CSI and
- * multibyte characters.
- * The redo buffer is left as it is.
- * If init is TRUE, prepare for redo, return FAIL if nothing to redo, OK
- * otherwise.
- * If old is TRUE, use old_redobuff instead of redobuff.
- */
-static int read_redo(int init, int old_redo)
+// Read a character from the redo buffer. Translates K_SPECIAL, CSI and
+// multibyte characters.
+// The redo buffer is left as it is.
+// If init is true, prepare for redo, return FAIL if nothing to redo, OK
+// otherwise.
+// If old_redo is true, use old_redobuff instead of redobuff.
+static int read_redo(bool init, bool old_redo)
{
static buffblock_T *bp;
static char_u *p;
@@ -713,38 +711,35 @@ static int read_redo(int init, int old_redo)
return c;
}
-/*
- * Copy the rest of the redo buffer into the stuff buffer (in a slow way).
- * If old_redo is TRUE, use old_redobuff instead of redobuff.
- * The escaped K_SPECIAL and CSI are copied without translation.
- */
-static void copy_redo(int old_redo)
+// Copy the rest of the redo buffer into the stuff buffer (in a slow way).
+// If old_redo is true, use old_redobuff instead of redobuff.
+// The escaped K_SPECIAL and CSI are copied without translation.
+static void copy_redo(bool old_redo)
{
int c;
- while ((c = read_redo(FALSE, old_redo)) != NUL) {
+ while ((c = read_redo(false, old_redo)) != NUL) {
add_char_buff(&readbuf2, c);
}
}
-/*
- * Stuff the redo buffer into readbuf2.
- * Insert the redo count into the command.
- * If "old_redo" is TRUE, the last but one command is repeated
- * instead of the last command (inserting text). This is used for
- * CTRL-O <.> in insert mode
- *
- * return FAIL for failure, OK otherwise
- */
-int start_redo(long count, int old_redo)
+// Stuff the redo buffer into readbuf2.
+// Insert the redo count into the command.
+// If "old_redo" is true, the last but one command is repeated
+// instead of the last command (inserting text). This is used for
+// CTRL-O <.> in insert mode
+//
+// return FAIL for failure, OK otherwise
+int start_redo(long count, bool old_redo)
{
int c;
- /* init the pointers; return if nothing to redo */
- if (read_redo(TRUE, old_redo) == FAIL)
+ // init the pointers; return if nothing to redo
+ if (read_redo(true, old_redo) == FAIL) {
return FAIL;
+ }
- c = read_redo(FALSE, old_redo);
+ c = read_redo(false, old_redo);
/* copy the buffer name, if present */
if (c == '"') {
@@ -755,22 +750,30 @@ int start_redo(long count, int old_redo)
if (c >= '1' && c < '9')
++c;
add_char_buff(&readbuf2, c);
- c = read_redo(FALSE, old_redo);
+
+ // the expression register should be re-evaluated
+ if (c == '=') {
+ add_char_buff(&readbuf2, CAR);
+ cmd_silent = true;
+ }
+
+ c = read_redo(false, old_redo);
}
if (c == 'v') { /* redo Visual */
VIsual = curwin->w_cursor;
- VIsual_active = TRUE;
- VIsual_select = FALSE;
- VIsual_reselect = TRUE;
- redo_VIsual_busy = TRUE;
- c = read_redo(FALSE, old_redo);
+ VIsual_active = true;
+ VIsual_select = false;
+ VIsual_reselect = true;
+ redo_VIsual_busy = true;
+ c = read_redo(false, old_redo);
}
- /* try to enter the count (in place of a previous count) */
+ // try to enter the count (in place of a previous count)
if (count) {
- while (ascii_isdigit(c)) /* skip "old" count */
- c = read_redo(FALSE, old_redo);
+ while (ascii_isdigit(c)) { // skip "old" count
+ c = read_redo(false, old_redo);
+ }
add_num_buff(&readbuf2, count);
}
@@ -789,12 +792,13 @@ int start_redo_ins(void)
{
int c;
- if (read_redo(TRUE, FALSE) == FAIL)
+ if (read_redo(true, false) == FAIL) {
return FAIL;
+ }
start_stuff();
- /* skip the count and the command character */
- while ((c = read_redo(FALSE, FALSE)) != NUL) {
+ // skip the count and the command character
+ while ((c = read_redo(false, false)) != NUL) {
if (vim_strchr((char_u *)"AaIiRrOo", c) != NULL) {
if (c == 'O' || c == 'o') {
add_buff(&readbuf2, NL_STR, -1L);
@@ -803,9 +807,9 @@ int start_redo_ins(void)
}
}
- /* copy the typed text from the redo buffer into the stuff buffer */
- copy_redo(FALSE);
- block_redo = TRUE;
+ // copy the typed text from the redo buffer into the stuff buffer
+ copy_redo(false);
+ block_redo = true;
return OK;
}
@@ -952,7 +956,7 @@ int ins_typebuf(char_u *str, int noremap, int offset, int nottyped, bool silent)
typebuf.tb_maplen += addlen;
if (silent || typebuf.tb_silent > offset) {
typebuf.tb_silent += addlen;
- cmd_silent = TRUE;
+ cmd_silent = true;
}
if (typebuf.tb_no_abbr_cnt && offset == 0) /* and not used for abbrev.s */
typebuf.tb_no_abbr_cnt += addlen;
@@ -1716,7 +1720,7 @@ static int vgetorpeek(int advance)
*typebuf.tb_buf = (char_u)c;
gotchars(typebuf.tb_buf, 1);
}
- cmd_silent = FALSE;
+ cmd_silent = false;
break;
} else if (typebuf.tb_len > 0) {
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index a31f6950e9..3bb18d2b5f 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -751,7 +751,7 @@ EXTERN cmdmod_T cmdmod; /* Ex command modifiers */
EXTERN int msg_silent INIT(= 0); // don't print messages
EXTERN int emsg_silent INIT(= 0); // don't print error messages
EXTERN bool emsg_noredir INIT(= false); // don't redirect error messages
-EXTERN int cmd_silent INIT(= false); // don't echo the command line
+EXTERN bool cmd_silent INIT(= false); // don't echo the command line
/* Values for swap_exists_action: what to do when swap file already exists */
#define SEA_NONE 0 /* don't use dialog */
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 4b0824c90f..e550bf0a37 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -541,7 +541,7 @@ int emsg(const char_u *s_)
// Reset msg_silent, an error causes messages to be switched back on.
msg_silent = 0;
- cmd_silent = FALSE;
+ cmd_silent = false;
if (global_busy) { // break :global command
global_busy++;
diff --git a/src/nvim/testdir/test_put.vim b/src/nvim/testdir/test_put.vim
index 38c812bc9c..0b8961c52b 100644
--- a/src/nvim/testdir/test_put.vim
+++ b/src/nvim/testdir/test_put.vim
@@ -34,3 +34,16 @@ func Test_put_char_block2()
bw!
call setreg('a', a[0], a[1])
endfunc
+
+func Test_put_expr()
+ new
+ call setline(1, repeat(['A'], 6))
+ exec "1norm! \"=line('.')\<cr>p"
+ norm! j0.
+ norm! j0.
+ exec "4norm! \"=\<cr>P"
+ norm! j0.
+ norm! j0.
+ call assert_equal(['A1','A2','A3','4A','5A','6A'], getline(1,'$'))
+ bw!
+endfunc