aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-28 14:12:54 +0800
committerGitHub <noreply@github.com>2024-03-28 14:12:54 +0800
commita0cbf1d8d5a65190874a14cfd9105aaecc1c7568 (patch)
tree0e7d066d84252633b414c6bcba5f42a2293f847c
parent981301d11f83f5e9b7425cd383e59bbe0d7afdd5 (diff)
downloadrneovim-a0cbf1d8d5a65190874a14cfd9105aaecc1c7568.tar.gz
rneovim-a0cbf1d8d5a65190874a14cfd9105aaecc1c7568.tar.bz2
rneovim-a0cbf1d8d5a65190874a14cfd9105aaecc1c7568.zip
fix(plines): cursor position with 'showbreak' and resized grid (#28067)
-rw-r--r--src/nvim/plines.c2
-rw-r--r--test/functional/ui/multigrid_spec.lua74
2 files changed, 65 insertions, 11 deletions
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index 1d5b043907..dae9de48c6 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -236,7 +236,7 @@ CharSize charsize_regular(CharsizeArg *csarg, char *const cur, colnr_T const vco
wcol += col_off_prev;
}
- if (wcol + size > wp->w_width) {
+ if (wcol + size > wp->w_width_inner) {
// cells taken by 'showbreak'/'breakindent' halfway current char
int head_mid = csarg->indent_width;
if (head_mid == INT_MIN) {
diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua
index c1d3af085f..4b11a881ed 100644
--- a/test/functional/ui/multigrid_spec.lua
+++ b/test/functional/ui/multigrid_spec.lua
@@ -412,9 +412,23 @@ describe('ext_multigrid', function()
end)
describe('grid of smaller inner size', function()
+ before_each(function()
+ screen:try_resize_grid(2, 20, 5)
+ end)
+
it('is rendered correctly', function()
+ screen:expect{grid=[[
+ ## grid 1
+ [2:-----------------------------------------------------]|*12
+ {11:[No Name] }|
+ [3:-----------------------------------------------------]|
+ ## grid 2
+ ^ |
+ {1:~ }|*4
+ ## grid 3
+ |
+ ]]}
screen:try_resize_grid(2, 8, 5)
-
screen:expect{grid=[[
## grid 1
[2:-----------------------------------------------------]|*12
@@ -427,12 +441,43 @@ describe('ext_multigrid', function()
|
]]}
end)
+
+ it("cursor draws correctly with double-width char and 'showbreak'", function()
+ insert(('a'):rep(19) .. '哦bbbb')
+ command('setlocal showbreak=++')
+ screen:expect{grid=[[
+ ## grid 1
+ [2:-----------------------------------------------------]|*12
+ {11:[No Name] [+] }|
+ [3:-----------------------------------------------------]|
+ ## grid 2
+ aaaaaaaaaaaaaaaaaaa{1:>}|
+ {1:++}哦bbb^b |
+ {1:~ }|*3
+ ## grid 3
+ |
+ ]]}
+ end)
end)
describe('grid of bigger inner size', function()
+ before_each(function()
+ screen:try_resize_grid(2, 60, 20)
+ end)
+
it('is rendered correctly', function()
+ screen:expect{grid=[[
+ ## grid 1
+ [2:-----------------------------------------------------]|*12
+ {11:[No Name] }|
+ [3:-----------------------------------------------------]|
+ ## grid 2
+ ^ |
+ {1:~ }|*19
+ ## grid 3
+ |
+ ]]}
screen:try_resize_grid(2, 80, 20)
-
screen:expect{grid=[[
## grid 1
[2:-----------------------------------------------------]|*12
@@ -445,13 +490,6 @@ describe('ext_multigrid', function()
|
]]}
end)
- end)
-
-
- describe('with resized grid', function()
- before_each(function()
- screen:try_resize_grid(2, 60, 20)
- end)
it('winwidth() winheight() getwininfo() return inner width and height #19743', function()
eq(60, fn.winwidth(0))
@@ -483,7 +521,7 @@ describe('ext_multigrid', function()
]]}
end)
- it('"g$" works correctly with double-width characters and no wrapping', function()
+ it('g$ works correctly with double-width chars and no wrapping', function()
command('set nowrap')
insert(('a'):rep(58) .. ('哦'):rep(3))
feed('0')
@@ -543,6 +581,22 @@ describe('ext_multigrid', function()
## grid 3
|
]]}
+ command('setlocal breakindent breakindentopt=shift:8')
+ feed('g$')
+ screen:expect{grid=[[
+ ## grid 1
+ [2:-----------------------------------------------------]|*12
+ {11:[No Name] [+] }|
+ [3:-----------------------------------------------------]|
+ ## grid 2
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
+ {23:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb^b}|
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb |
+ |
+ {1:~ }|*16
+ ## grid 3
+ |
+ ]]}
end)
it('displays messages with default grid width', function()