fix(grid): add start column when getting char on line (#25627)

This commit is contained in:
zeertzjq 2023-10-13 21:43:06 +08:00 committed by GitHub
parent ebe489d8f0
commit 9f32deba56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 0 deletions

View File

@ -352,6 +352,7 @@ void grid_line_start(ScreenGrid *grid, int row)
schar_T grid_line_getchar(int col, int *attr)
{
if (col < grid_line_maxcol) {
col += grid_line_coloff;
size_t off = grid_line_grid->line_offset[grid_line_row] + (size_t)col;
if (attr != NULL) {
*attr = grid_line_grid->attrs[off];

View File

@ -192,4 +192,38 @@ describe('insert-mode', function()
feed('i<C-S-V><C-J><C-S-V><C-@><C-S-V><C-[><C-S-V><C-S-M><C-S-V><M-C-I><C-S-V><C-D-J><Esc>')
expect('<C-J><C-@><C-[><C-S-M><M-C-I><C-D-J>')
end)
it('multi-char mapping updates screen properly #25626', function()
local screen = Screen.new(60, 6)
screen:set_default_attr_ids({
[0] = {bold = true, foreground = Screen.colors.Blue}; -- NonText
[1] = {bold = true, reverse = true}; -- StatusLine
[2] = {reverse = true}; -- StatusLineNC
[3] = {bold = true}; -- ModeMsg
})
screen:attach()
command('vnew')
insert('foo\nfoo\nfoo')
command('wincmd w')
command('set timeoutlen=10000')
command('inoremap jk <Esc>')
feed('i<CR>βββ<Left><Left>j')
screen:expect{grid=[[
foo |
foo β^ |
foo {0:~ }|
{0:~ }{0:~ }|
{2:[No Name] [+] }{1:[No Name] [+] }|
{3:-- INSERT --} |
]]}
feed('k')
screen:expect{grid=[[
foo |
foo ^βββ |
foo {0:~ }|
{0:~ }{0:~ }|
{2:[No Name] [+] }{1:[No Name] [+] }|
|
]]}
end)
end)