aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-09-19 18:45:11 +0800
committerGitHub <noreply@github.com>2023-09-19 18:45:11 +0800
commitc5abf487f19e45fe96a001b28b9e7981f43eed7d (patch)
tree925a0fe21f642091f307b7f8f1ff33083a73ca41
parent1db45a9c1fd68e57611829a9363212a39f3c55d6 (diff)
downloadrneovim-c5abf487f19e45fe96a001b28b9e7981f43eed7d.tar.gz
rneovim-c5abf487f19e45fe96a001b28b9e7981f43eed7d.tar.bz2
rneovim-c5abf487f19e45fe96a001b28b9e7981f43eed7d.zip
fix(float): make "fixed" work with relative=win (#25243)
-rw-r--r--src/nvim/window.c6
-rw-r--r--test/functional/ui/float_spec.lua98
2 files changed, 42 insertions, 62 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 10334083ce..1208494eaf 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -1009,10 +1009,8 @@ void ui_ext_win_position(win_T *wp, bool validate)
comp_row += grid->comp_row;
comp_col += grid->comp_col;
comp_row = MAX(MIN(comp_row, Rows - wp->w_height_outer - (p_ch > 0 ? 1 : 0)), 0);
- comp_col = MAX(MIN(comp_col, Columns - wp->w_width_outer), 0);
- int right_extra = Columns - (int)c.col - wp->w_width - (c.border_chars[2][0] != 0);
- if (!(c.anchor & kFloatAnchorEast) && c.fixed && right_extra < 0) {
- comp_col = (int)c.col;
+ if (!c.fixed || east) {
+ comp_col = MAX(MIN(comp_col, Columns - wp->w_width_outer), 0);
}
wp->w_winrow = comp_row;
wp->w_wincol = comp_col;
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index fcda0dad74..e1d5f6b965 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -940,85 +940,67 @@ describe('float window', function()
end)
it('window position fixed', function()
+ command('rightbelow 20vsplit')
local buf = meths.create_buf(false,false)
- command("set nowrap")
local win = meths.open_win(buf, false, {
- relative='editor', width=20, height=2, row=2, col=30, anchor = 'NW', fixed = true})
- local expected_pos = {
- [4]={{id=1001}, 'NW', 1, 2, 30, true},
- }
+ relative='win', width=15, height=2, row=2, col=10, anchor='NW', fixed=true})
if multigrid then
screen:expect{grid=[[
## grid 1
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
+ [2:-------------------]{5:│}[4:--------------------]|
+ [2:-------------------]{5:│}[4:--------------------]|
+ [2:-------------------]{5:│}[4:--------------------]|
+ [2:-------------------]{5:│}[4:--------------------]|
+ [2:-------------------]{5:│}[4:--------------------]|
+ {5:[No Name] }{4:[No Name] }|
[3:----------------------------------------]|
## grid 2
- ^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
## grid 3
|
## grid 4
- {1: }|
- {2:~ }|
- ]], float_pos=expected_pos}
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ ## grid 5
+ {1: }|
+ {2:~ }|
+ ]], float_pos={
+ [5] = {{id = 1002}, "NW", 4, 2, 10, true, 50};
+ }}
else
screen:expect([[
- ^ |
- {0:~ }|
- {0:~ }{1: }|
- {0:~ }{2:~ }|
- {0:~ }|
- {0:~ }|
+ {5:│}^ |
+ {0:~ }{5:│}{0:~ }|
+ {0:~ }{5:│}{0:~ }{1: }|
+ {0:~ }{5:│}{0:~ }{2:~ }|
+ {0:~ }{5:│}{0:~ }|
+ {5:[No Name] }{4:[No Name] }|
|
- ]])
+ ]])
end
- meths.win_set_config(win, {
- relative='editor', width=20, height=2, row=2, col=30, anchor = 'NW', fixed = false})
+ meths.win_set_config(win, {fixed=false})
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
- {1: }|
- {2:~ }|
- ]], float_pos=expected_pos}
+ screen:expect_unchanged()
else
screen:expect([[
- ^ |
- {0:~ }|
- {0:~ }{1: }|
- {0:~ }{2:~ }|
- {0:~ }|
- {0:~ }|
+ {5:│}^ |
+ {0:~ }{5:│}{0:~ }|
+ {0:~ }{5:│}{0:~ }{1: }|
+ {0:~ }{5:│}{0:~ }{2:~ }|
+ {0:~ }{5:│}{0:~ }|
+ {5:[No Name] }{4:[No Name] }|
|
- ]])
+ ]])
end
end)