aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-18 22:25:55 +0800
committerGitHub <noreply@github.com>2024-03-18 22:25:55 +0800
commite3bd04f2aff738722c06276cc926d4bdd4501402 (patch)
tree2bd22e459f73952bc4e72a4e70af2d8069e07ca9 /src
parent5de0482d1abfdc0a4ede1b96f729dae38f1c7c56 (diff)
downloadrneovim-e3bd04f2aff738722c06276cc926d4bdd4501402.tar.gz
rneovim-e3bd04f2aff738722c06276cc926d4bdd4501402.tar.bz2
rneovim-e3bd04f2aff738722c06276cc926d4bdd4501402.zip
fix(pager): handle consecutive newlines properly (#27913)
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c10
-rw-r--r--src/nvim/message.c15
2 files changed, 16 insertions, 9 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index e4ee254193..f5f9c4f77b 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -8085,10 +8085,12 @@ void ex_echo(exarg_T *eap)
// Call msg_start() after eval1(), evaluating the expression
// may cause a message to appear.
if (eap->cmdidx == CMD_echo) {
- // Mark the saved text as finishing the line, so that what
- // follows is displayed on a new line when scrolling back
- // at the more prompt.
- msg_sb_eol();
+ if (!msg_didout) {
+ // Mark the saved text as finishing the line, so that what
+ // follows is displayed on a new line when scrolling back
+ // at the more prompt.
+ msg_sb_eol();
+ }
msg_start();
}
} else if (eap->cmdidx == CMD_echo) {
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 2725ad02c6..5a47908eb6 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -1191,7 +1191,7 @@ void wait_return(int redraw)
check_timestamps(false);
}
- hit_return_msg();
+ hit_return_msg(true);
do {
// Remember "got_int", if it is set vgetc() probably returns a
@@ -1240,7 +1240,7 @@ void wait_return(int redraw)
got_int = false;
} else if (c != K_IGNORE) {
c = K_IGNORE;
- hit_return_msg();
+ hit_return_msg(false);
}
} else if (msg_scrolled > Rows - 2
&& (c == 'j' || c == 'd' || c == 'f'
@@ -1313,14 +1313,19 @@ void wait_return(int redraw)
}
/// Write the hit-return prompt.
-static void hit_return_msg(void)
+///
+/// @param newline_sb if starting a new line, add it to the scrollback.
+static void hit_return_msg(bool newline_sb)
{
int save_p_more = p_more;
- p_more = false; // don't want to see this message when scrolling back
+ if (!newline_sb) {
+ p_more = false;
+ }
if (msg_didout) { // start on a new line
msg_putchar('\n');
}
+ p_more = false; // don't want to see this message when scrolling back
msg_ext_set_kind("return_prompt");
if (got_int) {
msg_puts(_("Interrupt: "));
@@ -2968,7 +2973,7 @@ void repeat_message(void)
msg_col = 0;
msg_clr_eos();
}
- hit_return_msg();
+ hit_return_msg(false);
msg_row = Rows - 1;
}
}