aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-10-13 21:43:06 +0800
committerGitHub <noreply@github.com>2023-10-13 21:43:06 +0800
commit9f32deba56ea867a8bb9b9ab7f44bcc5142e8bbc (patch)
tree93517964616f9ff14c4db8c0b43e174c5ae0c4ff
parentebe489d8f0edbb3538a59733289d8969d1ffea22 (diff)
downloadrneovim-9f32deba56ea867a8bb9b9ab7f44bcc5142e8bbc.tar.gz
rneovim-9f32deba56ea867a8bb9b9ab7f44bcc5142e8bbc.tar.bz2
rneovim-9f32deba56ea867a8bb9b9ab7f44bcc5142e8bbc.zip
fix(grid): add start column when getting char on line (#25627)
-rw-r--r--src/nvim/grid.c1
-rw-r--r--test/functional/editor/mode_insert_spec.lua34
2 files changed, 35 insertions, 0 deletions
diff --git a/src/nvim/grid.c b/src/nvim/grid.c
index 7c8823e0d4..9fe518e9fd 100644
--- a/src/nvim/grid.c
+++ b/src/nvim/grid.c
@@ -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];
diff --git a/test/functional/editor/mode_insert_spec.lua b/test/functional/editor/mode_insert_spec.lua
index 12f450520a..37651164f5 100644
--- a/test/functional/editor/mode_insert_spec.lua
+++ b/test/functional/editor/mode_insert_spec.lua
@@ -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 │β^jβ |
+ 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)