Skip to content

Commit 901b96d

Browse files
authored
fix: only set borderhighlight if a border is shown (#257)
* fix: only set borderhighlight if a border is shown * test: add tests for border highlight handling * test: fix borderhighlight test
1 parent 80bb2b9 commit 901b96d

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

lua/plenary/popup/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ function popup.create(what, vim_options)
387387
vim.api.nvim_win_set_option(win_id, "winhl", string.format("Normal:%s", vim_options.highlight))
388388
end
389389

390-
if vim_options.borderhighlight then
390+
if should_show_border and vim_options.borderhighlight then
391391
vim.api.nvim_win_set_option(border.win_id, "winhl", string.format("Normal:%s", vim_options.borderhighlight))
392392
end
393393

tests/plenary/popup_spec.lua

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,23 @@ describe("plenary.popup", function()
4444
eq(true, vim.api.nvim_win_is_valid(border_id))
4545
end)
4646

47+
it("can apply a border highlight", function()
48+
local _, opts = popup.create("hello there", {
49+
border = true,
50+
borderhighlight = "PopupColor2",
51+
})
52+
53+
local border_win_id = opts.border.win_id
54+
eq("Normal:PopupColor2", vim.api.nvim_win_get_option(border_win_id, "winhl"))
55+
end)
56+
57+
it("can ignore border highlight with no border", function()
58+
local _ = popup.create("hello there", {
59+
border = false,
60+
borderhighlight = "PopupColor3",
61+
})
62+
end)
63+
4764
it("can do basic padding", function()
4865
local win_id = popup.create("12345", {
4966
line = 1,
@@ -74,7 +91,7 @@ describe("plenary.popup", function()
7491
describe("borderchars", function()
7592
local test_border = function(name, borderchars, expected)
7693
it(name, function()
77-
local win_id, config = popup.create("all the plus signs", {
94+
local _, config = popup.create("all the plus signs", {
7895
line = 8,
7996
col = 55,
8097
padding = { 0, 3, 0, 3 },

0 commit comments

Comments
 (0)