aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2022-05-18 13:51:59 +0200
committerbfredl <bjorn.linse@gmail.com>2022-05-18 20:16:18 +0200
commit17758fe7ad0d5db54dc43e364d53f637a148e73f (patch)
tree2b4925268f561dd176baf17bbf9d1d810407cd95
parentc28192e6f9c16de3add78c5ecf8e732c241f945a (diff)
downloadrneovim-17758fe7ad0d5db54dc43e364d53f637a148e73f.tar.gz
rneovim-17758fe7ad0d5db54dc43e364d53f637a148e73f.tar.bz2
rneovim-17758fe7ad0d5db54dc43e364d53f637a148e73f.zip
fix(ui): make winbar work with floats and multigrid
-rw-r--r--src/nvim/os/input.c2
-rw-r--r--src/nvim/screen.c6
-rw-r--r--src/nvim/window.c2
-rw-r--r--test/functional/ui/float_spec.lua47
-rw-r--r--test/functional/ui/multigrid_spec.lua40
5 files changed, 93 insertions, 4 deletions
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index e4a91d1416..7a50725461 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -183,7 +183,7 @@ void os_breakcheck(void)
// We do not want screen_resize() to redraw here.
// TODO(bfredl): we are already special casing redraw events, is this
// hack still needed?
- updating_screen++;
+ updating_screen = true;
loop_poll_events(&main_loop, 0);
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 8ca8c7985a..86dbf532a7 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -5324,8 +5324,10 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler)
use_sandbox = was_set_insecurely(wp, "tabline", 0);
} else if (draw_winbar) {
stl = (char_u *)((*wp->w_p_wbr != NUL) ? wp->w_p_wbr : p_wbr);
- row = wp->w_winrow;
- col = wp->w_wincol;
+ row = -1; // row zero is first row of text
+ col = 0;
+ grid = &wp->w_grid;
+ grid_adjust(&grid, &row, &col);
fillchar = wp->w_p_fcs_chars.wbr;
attr = (wp == curwin) ? HL_ATTR(HLF_WBR) : HL_ATTR(HLF_WBRNC);
maxwidth = wp->w_width_inner;
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 7e7c639a15..5cc24bbb5b 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -6296,7 +6296,7 @@ void win_set_inner_size(win_T *wp)
static int win_extra_height(win_T *wp)
{
- return wp->w_border_adj[0] + wp->w_border_adj[2];
+ return wp->w_border_adj[0] + wp->w_border_adj[2] + wp->w_winbar_height;
}
static int win_extra_width(win_T *wp)
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 7ab00e74d9..03170c79e6 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -7591,6 +7591,53 @@ describe('float window', function()
]]}
end
end)
+
+ it('can use winbar', function()
+ local buf = meths.create_buf(false,false)
+ local win1 = meths.open_win(buf, false, {relative='editor', width=15, height=3, row=1, col=5})
+ meths.win_set_option(win1, 'winbar', 'floaty bar')
+
+ 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
+ {3:floaty bar }|
+ {1: }|
+ {2:~ }|
+ ]], float_pos={
+ [4] = {{id = 1001}, "NW", 1, 1, 5, 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 = 2, curline = 0, curcol = 0, linecount = 1};
+ }}
+ else
+ screen:expect{grid=[[
+ ^ |
+ {0:~ }{3:floaty bar }{0: }|
+ {0:~ }{1: }{0: }|
+ {0:~ }{2:~ }{0: }|
+ {0:~ }|
+ {0:~ }|
+ |
+ ]]}
+ end
+ end)
end
describe('with ext_multigrid', function()
diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua
index 20e8821009..0fba55e76b 100644
--- a/test/functional/ui/multigrid_spec.lua
+++ b/test/functional/ui/multigrid_spec.lua
@@ -2369,4 +2369,44 @@ describe('ext_multigrid', function()
[2] = {win = {id = 1000}, topline = 6, botline = 12, curline = 10, curcol = 1, linecount = 11},
}}
end)
+
+ it('with winbar', function()
+ command 'split'
+ command 'setlocal winbar=very\\ bar'
+ screen:expect{grid=[[
+ ## grid 1
+ [4:-----------------------------------------------------]|
+ [4:-----------------------------------------------------]|
+ [4:-----------------------------------------------------]|
+ [4:-----------------------------------------------------]|
+ [4:-----------------------------------------------------]|
+ [4:-----------------------------------------------------]|
+ {11:[No Name] }|
+ [2:-----------------------------------------------------]|
+ [2:-----------------------------------------------------]|
+ [2:-----------------------------------------------------]|
+ [2:-----------------------------------------------------]|
+ [2:-----------------------------------------------------]|
+ {12:[No Name] }|
+ [3:-----------------------------------------------------]|
+ ## grid 2
+ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ ## grid 3
+ |
+ ## grid 4
+ {7:very bar }|
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ ]], win_viewport={
+ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
+ [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
+ }}
+ end)
end)