aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2024-12-22 15:42:48 +0100
committerGitHub <noreply@github.com>2024-12-22 06:42:48 -0800
commitd1e00a5f6dce9cf1fa80f613d4d27019966e5a79 (patch)
tree12e76eee3ff8ddaffcaace004d1cb28ce547341a
parentc7a4197a5c344f02241eed0761c86487ee5bbd96 (diff)
downloadrneovim-d1e00a5f6dce9cf1fa80f613d4d27019966e5a79.tar.gz
rneovim-d1e00a5f6dce9cf1fa80f613d4d27019966e5a79.tar.bz2
rneovim-d1e00a5f6dce9cf1fa80f613d4d27019966e5a79.zip
fix(messages): typo and unwanted truncation in msg_outtrans_long #31669
- Typo/bug in msg_outtrans_long passing string length as "hist" argument. - Avoid truncating message in msg_outtrans_long with ext_messages (followup to 1097d239c307a10a87fa995c4cfbe5987939e177). - Remove `_hl` from `msg_keep`, `smsg_keep` as there is no non-`_hl` variant. - `msg_printf_hl` is removed (identical to `smsg` except it sets `msg_scroll = true`, seemingly as a caveat to force a more prompt in cmdline mode). Move this logic to the only the only place this was used in ex_getln.c.
-rw-r--r--src/nvim/ex_getln.c3
-rw-r--r--src/nvim/message.c41
-rw-r--r--src/nvim/ops.c2
-rw-r--r--src/nvim/quickfix.c2
-rw-r--r--src/nvim/undo.c12
5 files changed, 20 insertions, 40 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 2c1653006c..09d4c88dcd 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -3142,8 +3142,9 @@ static bool color_cmdline(CmdlineInfo *colored_ccline)
#define PRINT_ERRMSG(...) \
do { \
+ msg_scroll = true; \
msg_putchar('\n'); \
- msg_printf_hl(HLF_E, __VA_ARGS__); \
+ smsg(HLF_E, __VA_ARGS__); \
printed_errmsg = true; \
} while (0)
bool ret = true;
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 1c46194a1c..a654395455 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -130,7 +130,7 @@ bool keep_msg_more = false; // keep_msg was set by msgmore()
// msg_scrolled How many lines the screen has been scrolled (because of
// messages). Used in update_screen() to scroll the screen
// back. Incremented each time the screen scrolls a line.
-// msg_scrolled_ign true when msg_scrolled is non-zero and msg_puts_hl_id()
+// msg_scrolled_ign true when msg_scrolled is non-zero and msg_puts_hl()
// writes something without scrolling should not make
// need_wait_return to be set. This is a hack to make ":ts"
// work without an extra prompt.
@@ -244,7 +244,7 @@ void msg_grid_validate(void)
int verb_msg(const char *s)
{
verbose_enter();
- int n = msg_hl_keep(s, 0, false, false);
+ int n = msg_keep(s, 0, false, false);
verbose_leave();
return n;
@@ -257,7 +257,7 @@ int verb_msg(const char *s)
bool msg(const char *s, const int hl_id)
FUNC_ATTR_NONNULL_ARG(1)
{
- return msg_hl_keep(s, hl_id, false, false);
+ return msg_keep(s, hl_id, false, false);
}
/// Similar to msg_outtrans_len, but support newlines and tabs.
@@ -309,7 +309,7 @@ void msg_multihl(HlMessage hl_msg, const char *kind, bool history)
}
/// @param keep set keep_msg if it doesn't scroll
-bool msg_hl_keep(const char *s, int hl_id, bool keep, bool multiline)
+bool msg_keep(const char *s, int hl_id, bool keep, bool multiline)
FUNC_ATTR_NONNULL_ALL
{
static int entered = 0;
@@ -514,7 +514,7 @@ int smsg(int hl_id, const char *s, ...)
return msg(IObuff, hl_id);
}
-int smsg_hl_keep(int hl_id, const char *s, ...)
+int smsg_keep(int hl_id, const char *s, ...)
FUNC_ATTR_PRINTF(2, 3)
{
va_list arglist;
@@ -522,7 +522,7 @@ int smsg_hl_keep(int hl_id, const char *s, ...)
va_start(arglist, s);
vim_vsnprintf(IObuff, IOSIZE, s, arglist);
va_end(arglist);
- return msg_hl_keep(IObuff, hl_id, true, false);
+ return msg_keep(IObuff, hl_id, true, false);
}
// Remember the last sourcing name/lnum used in an error message, so that it
@@ -767,7 +767,7 @@ bool emsg_multiline(const char *s, bool multiline)
// Display the error message itself.
msg_nowait = false; // Wait for this msg.
- return msg_hl_keep(s, hl_id, false, multiline);
+ return msg_keep(s, hl_id, false, multiline);
}
/// emsg() - display an error message
@@ -1193,7 +1193,7 @@ void ex_messages(exarg_T *eap)
if (kv_size(p->multihl)) {
msg_multihl(p->multihl, p->kind, false);
} else if (p->msg != NULL) {
- msg_hl_keep(p->msg, p->hl_id, false, p->multiline);
+ msg_keep(p->msg, p->hl_id, false, p->multiline);
}
}
msg_hist_off = false;
@@ -2103,12 +2103,12 @@ void msg_outtrans_long(const char *longstr, int hl_id)
int len = (int)strlen(longstr);
int slen = len;
int room = Columns - msg_col;
- if (len > room && room >= 20) {
+ if (!ui_has(kUIMessages) && len > room && room >= 20) {
slen = (room - 3) / 2;
msg_outtrans_len(longstr, slen, hl_id, false);
msg_puts_hl("...", HLF_8, false);
}
- msg_outtrans_len(longstr + len - slen, slen, hl_id, len);
+ msg_outtrans_len(longstr + len - slen, slen, hl_id, false);
}
/// Basic function for writing a message with highlight id.
@@ -2178,27 +2178,6 @@ void msg_puts_len(const char *const str, const ptrdiff_t len, int hl_id, bool hi
need_fileinfo = false;
}
-/// Print a formatted message
-///
-/// Message printed is limited by #IOSIZE. Must not be used from inside
-/// msg_puts_hl_id().
-///
-/// @param[in] hl_id Highlight id.
-/// @param[in] fmt Format string.
-void msg_printf_hl(const int hl_id, const char *const fmt, ...)
- FUNC_ATTR_NONNULL_ARG(2) FUNC_ATTR_PRINTF(2, 3)
-{
- static char msgbuf[IOSIZE];
-
- va_list ap;
- va_start(ap, fmt);
- const size_t len = (size_t)vim_vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
- va_end(ap);
-
- msg_scroll = true;
- msg_puts_len(msgbuf, (ptrdiff_t)len, hl_id, true);
-}
-
static void msg_ext_emit_chunk(void)
{
if (msg_ext_chunks == NULL) {
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 71a005bd24..b508c65662 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -258,7 +258,7 @@ void op_shift(oparg_T *oap, bool curs_top, int amount)
vim_snprintf(IObuff, IOSIZE,
NGETTEXT(msg_line_single, msg_line_plural, oap->line_count),
(int64_t)oap->line_count, op, amount);
- msg_hl_keep(IObuff, 0, true, false);
+ msg_keep(IObuff, 0, true, false);
}
if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 76c794b5a9..e9e0228ec4 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -2937,7 +2937,7 @@ static void qf_jump_print_msg(qf_info_T *qi, int qf_index, qfline_T *qf_ptr, buf
msg_scroll = false;
}
msg_ext_set_kind("quickfix");
- msg_hl_keep(gap->ga_data, 0, true, false);
+ msg_keep(gap->ga_data, 0, true, false);
msg_scroll = (int)i;
qfga_clear();
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index d523e55640..45401ca5e1 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -2596,12 +2596,12 @@ static void u_undo_end(bool did_undo, bool absolute, bool quiet)
check_pos(curbuf, &VIsual);
}
- smsg_hl_keep(0, _("%" PRId64 " %s; %s #%" PRId64 " %s"),
- u_oldcount < 0 ? (int64_t)-u_oldcount : (int64_t)u_oldcount,
- _(msgstr),
- did_undo ? _("before") : _("after"),
- uhp == NULL ? 0 : (int64_t)uhp->uh_seq,
- msgbuf);
+ smsg_keep(0, _("%" PRId64 " %s; %s #%" PRId64 " %s"),
+ u_oldcount < 0 ? (int64_t)-u_oldcount : (int64_t)u_oldcount,
+ _(msgstr),
+ did_undo ? _("before") : _("after"),
+ uhp == NULL ? 0 : (int64_t)uhp->uh_seq,
+ msgbuf);
}
/// Put the timestamp of an undo header in "buf[buflen]" in a nice format.