mirror of
https://github.com/neovim/neovim
synced 2025-07-17 09:41:46 +00:00
fix(showcmd): clear the rest properly (#28420)
This commit is contained in:
@ -436,9 +436,8 @@ int grid_line_puts(int col, const char *text, int textlen, int attr)
|
|||||||
? utfc_ptr2schar_len(ptr, (int)((text + len) - ptr), &firstc)
|
? utfc_ptr2schar_len(ptr, (int)((text + len) - ptr), &firstc)
|
||||||
: utfc_ptr2schar(ptr, &firstc);
|
: utfc_ptr2schar(ptr, &firstc);
|
||||||
int mbyte_cells = utf_char2cells(firstc);
|
int mbyte_cells = utf_char2cells(firstc);
|
||||||
if (mbyte_cells > 2) {
|
if (mbyte_cells > 2 || schar == 0) {
|
||||||
mbyte_cells = 1;
|
mbyte_cells = 1;
|
||||||
|
|
||||||
schar = schar_from_char(0xFFFD);
|
schar = schar_from_char(0xFFFD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2043,8 +2043,7 @@ void pop_showcmd(void)
|
|||||||
|
|
||||||
static void display_showcmd(void)
|
static void display_showcmd(void)
|
||||||
{
|
{
|
||||||
int len = vim_strsize(showcmd_buf);
|
showcmd_is_clear = (showcmd_buf[0] == NUL);
|
||||||
showcmd_is_clear = (len == 0);
|
|
||||||
|
|
||||||
if (*p_sloc == 's') {
|
if (*p_sloc == 's') {
|
||||||
if (showcmd_is_clear) {
|
if (showcmd_is_clear) {
|
||||||
@ -2069,7 +2068,7 @@ static void display_showcmd(void)
|
|||||||
if (ui_has(kUIMessages)) {
|
if (ui_has(kUIMessages)) {
|
||||||
MAXSIZE_TEMP_ARRAY(content, 1);
|
MAXSIZE_TEMP_ARRAY(content, 1);
|
||||||
MAXSIZE_TEMP_ARRAY(chunk, 2);
|
MAXSIZE_TEMP_ARRAY(chunk, 2);
|
||||||
if (len > 0) {
|
if (!showcmd_is_clear) {
|
||||||
// placeholder for future highlight support
|
// placeholder for future highlight support
|
||||||
ADD_C(chunk, INTEGER_OBJ(0));
|
ADD_C(chunk, INTEGER_OBJ(0));
|
||||||
ADD_C(chunk, CSTR_AS_OBJ(showcmd_buf));
|
ADD_C(chunk, CSTR_AS_OBJ(showcmd_buf));
|
||||||
@ -2086,8 +2085,9 @@ static void display_showcmd(void)
|
|||||||
int showcmd_row = Rows - 1;
|
int showcmd_row = Rows - 1;
|
||||||
grid_line_start(&msg_grid_adj, showcmd_row);
|
grid_line_start(&msg_grid_adj, showcmd_row);
|
||||||
|
|
||||||
|
int len = 0;
|
||||||
if (!showcmd_is_clear) {
|
if (!showcmd_is_clear) {
|
||||||
grid_line_puts(sc_col, showcmd_buf, -1, HL_ATTR(HLF_MSG));
|
len = grid_line_puts(sc_col, showcmd_buf, -1, HL_ATTR(HLF_MSG));
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear the rest of an old message by outputting up to SHOWCMD_COLS spaces
|
// clear the rest of an old message by outputting up to SHOWCMD_COLS spaces
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
-- Normal mode tests.
|
-- Normal mode tests.
|
||||||
|
|
||||||
local t = require('test.functional.testutil')()
|
local t = require('test.functional.testutil')()
|
||||||
|
local Screen = require('test.functional.ui.screen')
|
||||||
local clear = t.clear
|
local clear = t.clear
|
||||||
local feed = t.feed
|
local feed = t.feed
|
||||||
local fn = t.fn
|
local fn = t.fn
|
||||||
@ -19,4 +20,23 @@ describe('Normal mode', function()
|
|||||||
feed('k')
|
feed('k')
|
||||||
eq(pos, fn.getcurpos())
|
eq(pos, fn.getcurpos())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('&showcmd does not crash with :startinsert #28419', function()
|
||||||
|
local screen = Screen.new(60, 17)
|
||||||
|
screen:attach()
|
||||||
|
fn.termopen(
|
||||||
|
{ t.nvim_prog, '--clean', '--cmd', 'startinsert' },
|
||||||
|
{ env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } }
|
||||||
|
)
|
||||||
|
screen:expect({
|
||||||
|
grid = [[
|
||||||
|
^ |
|
||||||
|
~ |*13
|
||||||
|
[No Name] 0,1 All|
|
||||||
|
-- INSERT -- |
|
||||||
|
|
|
||||||
|
]],
|
||||||
|
attr_ids = {},
|
||||||
|
})
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user