aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-03-12 12:10:27 +0800
committerGitHub <noreply@github.com>2023-03-12 12:10:27 +0800
commit172227a44642b67ec8af5b438e5373a3daf61fdb (patch)
tree3249c062a84ca4c9592d522b499c5834208bab09
parent1c4b3d41b538078234282cfba74e5cf07c42c916 (diff)
downloadrneovim-172227a44642b67ec8af5b438e5373a3daf61fdb.tar.gz
rneovim-172227a44642b67ec8af5b438e5373a3daf61fdb.tar.bz2
rneovim-172227a44642b67ec8af5b438e5373a3daf61fdb.zip
fix(screen): correctly draw background and eob with 'rightleft' (#22640)
-rw-r--r--src/nvim/grid.c3
-rw-r--r--src/nvim/screen.c17
-rw-r--r--test/functional/ui/float_spec.lua49
-rw-r--r--test/functional/ui/highlight_spec.lua16
4 files changed, 74 insertions, 11 deletions
diff --git a/src/nvim/grid.c b/src/nvim/grid.c
index efbeac4f3f..f20a9a847d 100644
--- a/src/nvim/grid.c
+++ b/src/nvim/grid.c
@@ -550,8 +550,7 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int cle
if (bg_attr) {
for (int c = col; c < endcol; c++) {
- linebuf_attr[off_from + (size_t)c] =
- hl_combine_attr(bg_attr, linebuf_attr[off_from + (size_t)c]);
+ linebuf_attr[c] = hl_combine_attr(bg_attr, linebuf_attr[c]);
}
}
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 43c7866180..8b0f8b58a7 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -111,14 +111,14 @@ static int win_fill_end(win_T *wp, int c1, int c2, int off, int width, int row,
int attr)
{
int nn = off + width;
+ const int endcol = wp->w_grid.cols;
- if (nn > wp->w_grid.cols) {
- nn = wp->w_grid.cols;
+ if (nn > endcol) {
+ nn = endcol;
}
if (wp->w_p_rl) {
- grid_fill(&wp->w_grid, row, endrow, W_ENDCOL(wp) - nn, W_ENDCOL(wp) - off,
- c1, c2, attr);
+ grid_fill(&wp->w_grid, row, endrow, endcol - nn, endcol - off, c1, c2, attr);
} else {
grid_fill(&wp->w_grid, row, endrow, off, nn, c1, c2, attr);
}
@@ -156,13 +156,12 @@ void win_draw_end(win_T *wp, int c1, int c2, bool draw_margin, int row, int endr
int attr = hl_combine_attr(win_bg_attr(wp), win_hl_attr(wp, (int)hl));
+ const int endcol = wp->w_grid.cols;
if (wp->w_p_rl) {
- grid_fill(&wp->w_grid, row, endrow, wp->w_wincol, W_ENDCOL(wp) - 1 - n,
- c2, c2, attr);
- grid_fill(&wp->w_grid, row, endrow, W_ENDCOL(wp) - 1 - n, W_ENDCOL(wp) - n,
- c1, c2, attr);
+ grid_fill(&wp->w_grid, row, endrow, 0, endcol - 1 - n, c2, c2, attr);
+ grid_fill(&wp->w_grid, row, endrow, endcol - 1 - n, endcol - n, c1, c2, attr);
} else {
- grid_fill(&wp->w_grid, row, endrow, n, wp->w_grid.cols, c1, c2, attr);
+ grid_fill(&wp->w_grid, row, endrow, n, endcol, c1, c2, attr);
}
}
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 6e67ec1f24..4e691512c1 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -9224,6 +9224,55 @@ describe('float window', function()
feed('<C-C>')
screen:expect_unchanged()
end)
+
+ it('with rightleft and border #22640', function()
+ local float_opts = {relative='editor', width=5, height=3, row=1, col=1, border='single'}
+ meths.open_win(meths.create_buf(false, false), true, float_opts)
+ command('setlocal rightleft')
+ feed('iabc<CR>def<Esc>')
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [3:----------------------------------------]|
+ ## grid 2
+ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ ## grid 3
+ |
+ ## grid 4
+ {5:┌─────┐}|
+ {5:│}{1: cba}{5:│}|
+ {5:│}{1: ^fed}{5:│}|
+ {5:│}{2: ~}{5:│}|
+ {5:└─────┘}|
+ ]], float_pos={
+ [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50};
+ }, win_viewport={
+ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
+ [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 2};
+ }}
+ else
+ screen:expect{grid=[[
+ |
+ {0:~}{5:┌─────┐}{0: }|
+ {0:~}{5:│}{1: cba}{5:│}{0: }|
+ {0:~}{5:│}{1: ^fed}{5:│}{0: }|
+ {0:~}{5:│}{2: ~}{5:│}{0: }|
+ {0:~}{5:└─────┘}{0: }|
+ |
+ ]]}
+ end
+ end)
end
describe('with ext_multigrid', function()
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index 288c2a214f..2bbc29b78f 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -1812,6 +1812,22 @@ describe("'winhighlight' highlight", function()
]])
end)
+ it('works for background color in rightleft window in vsplit #22640', function()
+ screen:try_resize(40, 6)
+ insert('aa')
+ command('setlocal rightleft')
+ command('botright vsplit')
+ command('setlocal winhl=Normal:Background1')
+ screen:expect([[
+ aa│{1: ^aa}|
+ {0: ~}│{2: ~}|
+ {0: ~}│{2: ~}|
+ {0: ~}│{2: ~}|
+ {4:[No Name] [+] }{3:[No Name] [+] }|
+ |
+ ]])
+ end)
+
it('handles undefined groups', function()
command("set winhl=Normal:Background1")
screen:expect([[