mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06: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:
parent
c7a4197a5c
commit
d1e00a5f6d
@ -3142,8 +3142,9 @@ static bool color_cmdline(CmdlineInfo *colored_ccline)
|
|||||||
|
|
||||||
#define PRINT_ERRMSG(...) \
|
#define PRINT_ERRMSG(...) \
|
||||||
do { \
|
do { \
|
||||||
|
msg_scroll = true; \
|
||||||
msg_putchar('\n'); \
|
msg_putchar('\n'); \
|
||||||
msg_printf_hl(HLF_E, __VA_ARGS__); \
|
smsg(HLF_E, __VA_ARGS__); \
|
||||||
printed_errmsg = true; \
|
printed_errmsg = true; \
|
||||||
} while (0)
|
} while (0)
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
@ -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
|
// msg_scrolled How many lines the screen has been scrolled (because of
|
||||||
// messages). Used in update_screen() to scroll the screen
|
// messages). Used in update_screen() to scroll the screen
|
||||||
// back. Incremented each time the screen scrolls a line.
|
// 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
|
// writes something without scrolling should not make
|
||||||
// need_wait_return to be set. This is a hack to make ":ts"
|
// need_wait_return to be set. This is a hack to make ":ts"
|
||||||
// work without an extra prompt.
|
// work without an extra prompt.
|
||||||
@ -244,7 +244,7 @@ void msg_grid_validate(void)
|
|||||||
int verb_msg(const char *s)
|
int verb_msg(const char *s)
|
||||||
{
|
{
|
||||||
verbose_enter();
|
verbose_enter();
|
||||||
int n = msg_hl_keep(s, 0, false, false);
|
int n = msg_keep(s, 0, false, false);
|
||||||
verbose_leave();
|
verbose_leave();
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
@ -257,7 +257,7 @@ int verb_msg(const char *s)
|
|||||||
bool msg(const char *s, const int hl_id)
|
bool msg(const char *s, const int hl_id)
|
||||||
FUNC_ATTR_NONNULL_ARG(1)
|
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.
|
/// 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
|
/// @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
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
static int entered = 0;
|
static int entered = 0;
|
||||||
@ -514,7 +514,7 @@ int smsg(int hl_id, const char *s, ...)
|
|||||||
return msg(IObuff, hl_id);
|
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)
|
FUNC_ATTR_PRINTF(2, 3)
|
||||||
{
|
{
|
||||||
va_list arglist;
|
va_list arglist;
|
||||||
@ -522,7 +522,7 @@ int smsg_hl_keep(int hl_id, const char *s, ...)
|
|||||||
va_start(arglist, s);
|
va_start(arglist, s);
|
||||||
vim_vsnprintf(IObuff, IOSIZE, s, arglist);
|
vim_vsnprintf(IObuff, IOSIZE, s, arglist);
|
||||||
va_end(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
|
// 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.
|
// Display the error message itself.
|
||||||
msg_nowait = false; // Wait for this msg.
|
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
|
/// emsg() - display an error message
|
||||||
@ -1193,7 +1193,7 @@ void ex_messages(exarg_T *eap)
|
|||||||
if (kv_size(p->multihl)) {
|
if (kv_size(p->multihl)) {
|
||||||
msg_multihl(p->multihl, p->kind, false);
|
msg_multihl(p->multihl, p->kind, false);
|
||||||
} else if (p->msg != NULL) {
|
} 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;
|
msg_hist_off = false;
|
||||||
@ -2103,12 +2103,12 @@ void msg_outtrans_long(const char *longstr, int hl_id)
|
|||||||
int len = (int)strlen(longstr);
|
int len = (int)strlen(longstr);
|
||||||
int slen = len;
|
int slen = len;
|
||||||
int room = Columns - msg_col;
|
int room = Columns - msg_col;
|
||||||
if (len > room && room >= 20) {
|
if (!ui_has(kUIMessages) && len > room && room >= 20) {
|
||||||
slen = (room - 3) / 2;
|
slen = (room - 3) / 2;
|
||||||
msg_outtrans_len(longstr, slen, hl_id, false);
|
msg_outtrans_len(longstr, slen, hl_id, false);
|
||||||
msg_puts_hl("...", HLF_8, 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.
|
/// 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;
|
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)
|
static void msg_ext_emit_chunk(void)
|
||||||
{
|
{
|
||||||
if (msg_ext_chunks == NULL) {
|
if (msg_ext_chunks == NULL) {
|
||||||
|
@ -258,7 +258,7 @@ void op_shift(oparg_T *oap, bool curs_top, int amount)
|
|||||||
vim_snprintf(IObuff, IOSIZE,
|
vim_snprintf(IObuff, IOSIZE,
|
||||||
NGETTEXT(msg_line_single, msg_line_plural, oap->line_count),
|
NGETTEXT(msg_line_single, msg_line_plural, oap->line_count),
|
||||||
(int64_t)oap->line_count, op, amount);
|
(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) {
|
if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
|
||||||
|
@ -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_scroll = false;
|
||||||
}
|
}
|
||||||
msg_ext_set_kind("quickfix");
|
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;
|
msg_scroll = (int)i;
|
||||||
|
|
||||||
qfga_clear();
|
qfga_clear();
|
||||||
|
@ -2596,12 +2596,12 @@ static void u_undo_end(bool did_undo, bool absolute, bool quiet)
|
|||||||
check_pos(curbuf, &VIsual);
|
check_pos(curbuf, &VIsual);
|
||||||
}
|
}
|
||||||
|
|
||||||
smsg_hl_keep(0, _("%" PRId64 " %s; %s #%" PRId64 " %s"),
|
smsg_keep(0, _("%" PRId64 " %s; %s #%" PRId64 " %s"),
|
||||||
u_oldcount < 0 ? (int64_t)-u_oldcount : (int64_t)u_oldcount,
|
u_oldcount < 0 ? (int64_t)-u_oldcount : (int64_t)u_oldcount,
|
||||||
_(msgstr),
|
_(msgstr),
|
||||||
did_undo ? _("before") : _("after"),
|
did_undo ? _("before") : _("after"),
|
||||||
uhp == NULL ? 0 : (int64_t)uhp->uh_seq,
|
uhp == NULL ? 0 : (int64_t)uhp->uh_seq,
|
||||||
msgbuf);
|
msgbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Put the timestamp of an undo header in "buf[buflen]" in a nice format.
|
/// Put the timestamp of an undo header in "buf[buflen]" in a nice format.
|
||||||
|
Loading…
Reference in New Issue
Block a user