aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/float_spec.lua
diff options
context:
space:
mode:
authorglepnir <glephunter@gmail.com>2024-04-20 12:01:28 +0800
committerglepnir <glephunter@gmail.com>2024-04-21 15:25:46 +0800
commit5f18dd30137565da782c155b52b530c172b3b29d (patch)
treee4b6f641be8cdee56c694f1845c0e45c02a3e353 /test/functional/ui/float_spec.lua
parent4d52b0cf670502caf81b70f2f1e6f8c548b78f58 (diff)
downloadrneovim-5f18dd30137565da782c155b52b530c172b3b29d.tar.gz
rneovim-5f18dd30137565da782c155b52b530c172b3b29d.tar.bz2
rneovim-5f18dd30137565da782c155b52b530c172b3b29d.zip
fix(float): wrong position when bufpos is set
Problem: when lnum in bufpos is out of range the position of float is wired. Solution: avoid the height value out of buffer line range.
Diffstat (limited to 'test/functional/ui/float_spec.lua')
-rw-r--r--test/functional/ui/float_spec.lua37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index ed66557ee8..f4e611b255 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -9256,6 +9256,43 @@ describe('float window', function()
api.nvim_set_current_win(winid)
eq("floating window cannot be relative to itself", pcall_err(api.nvim_win_set_config, winid, config))
end)
+
+ it("bufpos out of range", function()
+ local buf = api.nvim_create_buf(false, true)
+ api.nvim_buf_set_lines(0, 0, -1, false, {})
+ local config = { relative='win', width=5, height=2, row=0, col=0, bufpos = { 3, 3 } }
+ api.nvim_open_win(buf, false, config)
+ if multigrid then
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [2:----------------------------------------]|*6
+ [3:----------------------------------------]|
+ ## grid 2
+ ^ |
+ {0:~ }|*5
+ ## grid 3
+ |
+ ## grid 4
+ {1: }|
+ {2:~ }|
+ ]], float_pos={
+ [4] = {1001, "NW", 2, 0, 0, true, 50};
+ }, win_viewport={
+ [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ }})
+ else
+ screen:expect({
+ grid = [[
+ {1:^ } |
+ {2:~ }{0: }|
+ {0:~ }|*4
+ |
+ ]]
+ })
+ end
+ end)
end
describe('with ext_multigrid', function()