aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2024-09-10 11:11:07 +0200
committerGitHub <noreply@github.com>2024-09-10 11:11:07 +0200
commit4c5bce9cb417cf1c6a93cdd5ca6d3d52d2bf95d6 (patch)
tree0d5a5a387dde3374be579188fd0c3b880cf7b48f
parent5d7853f22903a4f42d52f565f6a662c3ef178a8c (diff)
parent8e81212e151a4e20cff33931b95279e14c4e21c2 (diff)
downloadrneovim-4c5bce9cb417cf1c6a93cdd5ca6d3d52d2bf95d6.tar.gz
rneovim-4c5bce9cb417cf1c6a93cdd5ca6d3d52d2bf95d6.tar.bz2
rneovim-4c5bce9cb417cf1c6a93cdd5ca6d3d52d2bf95d6.zip
Merge pull request #30295 from glepnir/nfloat
fix(highlight): floating windows inherit NormalFloat from global-ns
-rw-r--r--src/nvim/highlight.c7
-rw-r--r--test/functional/ui/float_spec.lua47
2 files changed, 52 insertions, 2 deletions
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c
index 8729c74ce8..b802eab4b9 100644
--- a/src/nvim/highlight.c
+++ b/src/nvim/highlight.c
@@ -370,12 +370,15 @@ void update_window_hl(win_T *wp, bool invalid)
// determine window specific background set in 'winhighlight'
bool float_win = wp->w_floating && !wp->w_config.external;
- if (float_win && hl_def[HLF_NFLOAT] != 0) {
+ if (float_win && hl_def[HLF_NFLOAT] != 0 && ns_id > 0) {
wp->w_hl_attr_normal = hl_def[HLF_NFLOAT];
} else if (hl_def[HLF_COUNT] > 0) {
wp->w_hl_attr_normal = hl_def[HLF_COUNT];
+ } else if (float_win) {
+ wp->w_hl_attr_normal = HL_ATTR(HLF_NFLOAT) > 0
+ ? HL_ATTR(HLF_NFLOAT) : highlight_attr[HLF_NFLOAT];
} else {
- wp->w_hl_attr_normal = float_win ? HL_ATTR(HLF_NFLOAT) : 0;
+ wp->w_hl_attr_normal = 0;
}
if (wp->w_floating) {
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 754f0772f6..409cf5aac4 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -1344,6 +1344,53 @@ describe('float window', function()
|
]])
end
+
+ --
+ -- floating windows inherit NormalFloat from global-ns.
+ --
+ command('fclose')
+ command('hi NormalFloat guibg=LightRed')
+ api.nvim_open_win(0, false, { relative = 'win', row = 3, col = 3, width = 12, height = 3, style = 'minimal' })
+ api.nvim_set_hl_ns(api.nvim_create_namespace('test1'))
+ if multigrid then
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [2:----------------------------------------]|*6
+ [3:----------------------------------------]|
+ ## grid 2
+ {14: 1 }^x |
+ {14: 2 }y |
+ {14: 3 } |
+ {0:~ }|*3
+ ## grid 3
+ |
+ ## grid 5
+ {22:x }|
+ {22:y }|
+ {22: }|
+ ]], float_pos={
+ [5] = {1002, "NW", 2, 3, 3, true, 50};
+ }, win_viewport={
+ [2] = {win = 1000, topline = 0, botline = 4, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0};
+ [5] = {win = 1002, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0};
+ }, win_viewport_margins={
+ [2] = { bottom = 0, left = 0, right = 0, top = 0, win = 1000 },
+ [5] = { bottom = 0, left = 0, right = 0, top = 0, win = 1002 }
+ }})
+ else
+ screen:expect({
+ grid = [[
+ {14: 1 }^x |
+ {14: 2 }y |
+ {14: 3 } |
+ {0:~ }{22:x }{0: }|
+ {0:~ }{22:y }{0: }|
+ {0:~ }{22: }{0: }|
+ |
+ ]]
+ })
+ end
end)
it("can use 'minimal' style", function()