aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/float_spec.lua
diff options
context:
space:
mode:
authornwounkn <nwounkn@gmail.com>2023-10-26 08:44:28 +0500
committerGitHub <noreply@github.com>2023-10-26 11:44:28 +0800
commit9de157bce4b6eb055a0d7a39d1ed6b7a6e6c6545 (patch)
treebdd09d6fec50cd1b85680d53d6b9bb8f7d384288 /test/functional/ui/float_spec.lua
parentf2fc44550fbe5b7ebfedc2b155dc41e93f49aedb (diff)
downloadrneovim-9de157bce4b6eb055a0d7a39d1ed6b7a6e6c6545.tar.gz
rneovim-9de157bce4b6eb055a0d7a39d1ed6b7a6e6c6545.tar.bz2
rneovim-9de157bce4b6eb055a0d7a39d1ed6b7a6e6c6545.zip
fix(float): win_get_bordertext_col returning negative column number (#25752)
Problem: `win_get_bordertext_col` returns column < 1 for right or center aligned text, if its length is more than window width. Solution: Return max(resulting_column, 1)
Diffstat (limited to 'test/functional/ui/float_spec.lua')
-rw-r--r--test/functional/ui/float_spec.lua55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 9f6b3ca296..f9849ea7fa 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -2034,6 +2034,61 @@ describe('float window', function()
eq('center', footer_pos)
end)
+ it('center aligned title longer than window width #25746', function()
+ local buf = meths.create_buf(false, false)
+ meths.buf_set_lines(buf, 0, -1, true, {' halloj! ',
+ ' BORDAA '})
+ local win = meths.open_win(buf, false, {
+ relative='editor', width=9, height=2, row=2, col=5, border="double",
+ title = "abcdefghijklmnopqrstuvwxyz",title_pos = "center",
+ })
+
+ 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:╔}{11:abcdefghi}{5:╗}|
+ {5:║}{1: halloj! }{5:║}|
+ {5:║}{1: BORDAA }{5:║}|
+ {5:╚═════════╝}|
+ ]], float_pos={
+ [4] = { { id = 1001 }, "NW", 1, 2, 5, true }
+ }, win_viewport={
+ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
+ }}
+ else
+ screen:expect{grid=[[
+ ^ |
+ {0:~ }|
+ {0:~ }{5:╔}{11:abcdefghi}{5:╗}{0: }|
+ {0:~ }{5:║}{1: halloj! }{5:║}{0: }|
+ {0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
+ {0:~ }{5:╚═════════╝}{0: }|
+ |
+ ]]}
+ end
+
+ meths.win_close(win, false)
+ assert_alive()
+ end)
+
it('border with title', function()
local buf = meths.create_buf(false, false)
meths.buf_set_lines(buf, 0, -1, true, {' halloj! ',