fix(ui): command line issues with external messages (#21709)

* fix: don't truncate external messages
* fix: avoid resizing command line with external messages
This commit is contained in:
luukvbaal 2023-01-13 04:47:55 +01:00 committed by GitHub
parent 4876654d4c
commit 1097d239c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 10 deletions

View File

@ -919,9 +919,11 @@ char *msg_trunc_attr(char *s, bool force, int attr)
/// @note: May change the message by replacing a character with '<'. /// @note: May change the message by replacing a character with '<'.
char *msg_may_trunc(bool force, char *s) char *msg_may_trunc(bool force, char *s)
{ {
int room; if (ui_has(kUIMessages)) {
return s;
}
room = (Rows - cmdline_row - 1) * Columns + sc_col - 1; int room = (Rows - cmdline_row - 1) * Columns + sc_col - 1;
if ((force || (shortmess(SHM_TRUNC) && !exmode_active)) if ((force || (shortmess(SHM_TRUNC) && !exmode_active))
&& (int)strlen(s) - room > 0) { && (int)strlen(s) - room > 0) {
int size = vim_strsize(s); int size = vim_strsize(s);

View File

@ -5780,6 +5780,10 @@ static void frame_setheight(frame_T *curfrp, int height)
if (curfrp->fr_parent == NULL) { if (curfrp->fr_parent == NULL) {
// topframe: can only change the command line height // topframe: can only change the command line height
// Avoid doing so with external messages.
if (ui_has(kUIMessages)) {
return;
}
if (height > ROWS_AVAIL) { if (height > ROWS_AVAIL) {
// If height is greater than the available space, try to create space for // If height is greater than the available space, try to create space for
// the frame by reducing 'cmdheight' if possible, while making sure // the frame by reducing 'cmdheight' if possible, while making sure
@ -6115,13 +6119,13 @@ void win_setminwidth(void)
/// Status line of dragwin is dragged "offset" lines down (negative is up). /// Status line of dragwin is dragged "offset" lines down (negative is up).
void win_drag_status_line(win_T *dragwin, int offset) void win_drag_status_line(win_T *dragwin, int offset)
{ {
// If the user explicitly set 'cmdheight' to zero, then allow for dragging frame_T *fr = dragwin->w_frame;
// the status line making it zero again.
if (p_ch == 0) { // Avoid changing command line height with external messages.
p_ch_was_zero = true; if (fr->fr_next == NULL && ui_has(kUIMessages)) {
return;
} }
frame_T *fr = dragwin->w_frame;
frame_T *curfr = fr; frame_T *curfr = fr;
if (fr != topframe) { // more than one window if (fr != topframe) { // more than one window
fr = fr->fr_parent; fr = fr->fr_parent;

View File

@ -8,6 +8,7 @@ local exec = helpers.exec
local eval = helpers.eval local eval = helpers.eval
local eq = helpers.eq local eq = helpers.eq
local is_os = helpers.is_os local is_os = helpers.is_os
local meths = helpers.meths
local function new_screen(opt) local function new_screen(opt)
local screen = Screen.new(25, 5) local screen = Screen.new(25, 5)
@ -1387,17 +1388,20 @@ describe('cmdheight=0', function()
]]) ]])
end) end)
it("clears cmdline area when resized with external messages", function() it("cannot be resized at all with external messages", function()
clear() clear()
screen = new_screen({rgb=true, ext_messages=true}) screen = new_screen({rgb=true, ext_messages=true})
command('set laststatus=2 cmdheight=0') command('set laststatus=2 mouse=a')
command('resize -1') command('resize -1')
screen:expect([[ screen:expect([[
^ | ^ |
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
{1:~ }|
{3:[No Name] }| {3:[No Name] }|
|
]]) ]])
meths.input_mouse('left', 'press', '', 0, 6, 10)
meths.input_mouse('left', 'drag', '', 0, 5, 10)
screen:expect_unchanged()
end) end)
end) end)

View File

@ -908,6 +908,13 @@ stack traceback:
{1:~ }| {1:~ }|
]]} ]]}
end) end)
it('does not truncate messages', function()
command('write Xtest')
screen:expect({messages={
{content = { { '"Xtest" [New] 0L, 0B written' } }, kind = "" }
}})
end)
end) end)
describe('ui/builtin messages', function() describe('ui/builtin messages', function()