mirror of
https://github.com/neovim/neovim.git
synced 2025-10-16 23:06:14 +00:00
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
1097d239c3
).
- 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.
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user