diff options
author | luukvbaal <luukvbaal@gmail.com> | 2024-12-22 15:42:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-22 06:42:48 -0800 |
commit | d1e00a5f6dce9cf1fa80f613d4d27019966e5a79 (patch) | |
tree | 12e76eee3ff8ddaffcaace004d1cb28ce547341a /src/nvim/message.c | |
parent | c7a4197a5c344f02241eed0761c86487ee5bbd96 (diff) | |
download | rneovim-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.
Diffstat (limited to 'src/nvim/message.c')
-rw-r--r-- | src/nvim/message.c | 41 |
1 files changed, 10 insertions, 31 deletions
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) { |