mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 17:21:49 +00:00
fix(messages): list_cmd kind for buffer line messages (#33855)
Problem: Missing kind and separate event for each line for message containing buffer lines for e.g. `:print`. Solution: Set the `list_cmd` kind and only `msg_start()` for the first message, print a newline instead.
This commit is contained in:
@@ -1470,7 +1470,7 @@ void append_redir(char *const buf, const size_t buflen, const char *const opt,
|
||||
}
|
||||
}
|
||||
|
||||
void print_line_no_prefix(linenr_T lnum, int use_number, bool list)
|
||||
void print_line_no_prefix(linenr_T lnum, bool use_number, bool list)
|
||||
{
|
||||
char numbuf[30];
|
||||
|
||||
@@ -1483,7 +1483,7 @@ void print_line_no_prefix(linenr_T lnum, int use_number, bool list)
|
||||
}
|
||||
|
||||
/// Print a text line. Also in silent mode ("ex -s").
|
||||
void print_line(linenr_T lnum, int use_number, bool list)
|
||||
void print_line(linenr_T lnum, bool use_number, bool list, bool first)
|
||||
{
|
||||
bool save_silent = silent_mode;
|
||||
|
||||
@@ -1492,12 +1492,17 @@ void print_line(linenr_T lnum, int use_number, bool list)
|
||||
return;
|
||||
}
|
||||
|
||||
msg_start();
|
||||
silent_mode = false;
|
||||
info_message = true; // use stdout, not stderr
|
||||
if (first) {
|
||||
msg_start();
|
||||
msg_ext_set_kind("list_cmd");
|
||||
} else if (!save_silent) {
|
||||
msg_putchar('\n'); // don't want trailing newline with regular messaging
|
||||
}
|
||||
print_line_no_prefix(lnum, use_number, list);
|
||||
if (save_silent) {
|
||||
msg_putchar('\n');
|
||||
msg_putchar('\n'); // batch mode message should always end in newline
|
||||
silent_mode = save_silent;
|
||||
}
|
||||
info_message = false;
|
||||
@@ -3039,7 +3044,7 @@ void ex_z(exarg_T *eap)
|
||||
}
|
||||
}
|
||||
|
||||
print_line(i, eap->flags & EXFLAG_NR, eap->flags & EXFLAG_LIST);
|
||||
print_line(i, eap->flags & EXFLAG_NR, eap->flags & EXFLAG_LIST, i == start);
|
||||
|
||||
if (minus && i == lnum) {
|
||||
msg_putchar('\n');
|
||||
@@ -4259,7 +4264,7 @@ skip:
|
||||
global_need_beginline = true;
|
||||
}
|
||||
if (subflags.do_print) {
|
||||
print_line(curwin->w_cursor.lnum, subflags.do_number, subflags.do_list);
|
||||
print_line(curwin->w_cursor.lnum, subflags.do_number, subflags.do_list, true);
|
||||
}
|
||||
} else if (!global_busy) {
|
||||
if (got_int) {
|
||||
|
@@ -5129,14 +5129,13 @@ static void ex_print(exarg_T *eap)
|
||||
if (curbuf->b_ml.ml_flags & ML_EMPTY) {
|
||||
emsg(_(e_empty_buffer));
|
||||
} else {
|
||||
for (; !got_int; os_breakcheck()) {
|
||||
print_line(eap->line1,
|
||||
for (linenr_T line = eap->line1; line <= eap->line2 && !got_int; os_breakcheck()) {
|
||||
print_line(line,
|
||||
(eap->cmdidx == CMD_number || eap->cmdidx == CMD_pound
|
||||
|| (eap->flags & EXFLAG_NR)),
|
||||
eap->cmdidx == CMD_list || (eap->flags & EXFLAG_LIST));
|
||||
if (++eap->line1 > eap->line2) {
|
||||
break;
|
||||
}
|
||||
eap->cmdidx == CMD_list || (eap->flags & EXFLAG_LIST),
|
||||
line == eap->line1);
|
||||
line++;
|
||||
}
|
||||
setpcmark();
|
||||
// put cursor at last line
|
||||
@@ -6360,7 +6359,7 @@ void ex_may_print(exarg_T *eap)
|
||||
{
|
||||
if (eap->flags != 0) {
|
||||
print_line(curwin->w_cursor.lnum, (eap->flags & EXFLAG_NR),
|
||||
(eap->flags & EXFLAG_LIST));
|
||||
(eap->flags & EXFLAG_LIST), true);
|
||||
ex_no_reprint = true;
|
||||
}
|
||||
}
|
||||
|
@@ -522,6 +522,23 @@ describe('ui/ext_messages', function()
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
feed(':1,2p<CR>')
|
||||
screen:expect({
|
||||
grid = [[
|
||||
line 1 |
|
||||
^line |
|
||||
{1:~ }|*3
|
||||
]],
|
||||
cmdline = { { abort = false } },
|
||||
messages = {
|
||||
{
|
||||
content = { { 'line 1\nline ' } },
|
||||
history = false,
|
||||
kind = 'list_cmd',
|
||||
},
|
||||
},
|
||||
})
|
||||
end)
|
||||
|
||||
it(':echoerr', function()
|
||||
|
Reference in New Issue
Block a user