Closed wroyca closed 2 months ago
Thanks for the issue!
Mini parse_osc11 implementation introduce a bug that breaks terminal background "restore" when following system-wide dark mode preferences:
Can you, please, clarify what exactly you think is broken? If it is that the color is set back to the light one, then it is by design in order to support wider range of terminal emulators.
This issue does not occur when using the parse_osc11 function directly from https://github.com/neovim/neovim/blob/0d3f2c4904d552635da07a6e2b4e75520b514940/runtime/lua/vim/_defaults.lua#L430
You could not have used parse_osc11
function directly, because it returns incompatible output. Chances are, that the alternative solution uses \027]111\027\\
to restore "original" terminal background color which work well in this scenario. This is not the case with setup_termbg_sync()
, which (as said above) is expected.
Thanks for the issue!
Mini parse_osc11 implementation introduce a bug that breaks terminal background "restore" when following system-wide dark mode preferences:
Can you, please, clarify what exactly you think is broken? If it is that the color is set back to the light one, then it is by design in order to support wider range of terminal emulators.
This issue does not occur when using the parse_osc11 function directly from https://github.com/neovim/neovim/blob/0d3f2c4904d552635da07a6e2b4e75520b514940/runtime/lua/vim/_defaults.lua#L430
You could not have used
parse_osc11
function directly, because it returns incompatible output. Chances are, that the alternative solution uses\027]111\027\\
to restore "original" terminal background color which work well in this scenario. This is not the case withsetup_termbg_sync()
, which (as said above) is expected.
That could be it, indeed, if it return invalid input then it does indeed make sense
If it is that the color is set back to the light one
That'd make sense; would you be open to having a compatibility option that we can opt-out for modern terminals that can handle the initial request properly?
Sorry for the noise. This can either be closed or converted to a feature request. :)
would you be open to having a compatibility option that we can opt-out for modern terminals that can handle the initial request properly?
Sorry, no. I don't changing default terminal color is a frequent enough use case to warrant adding extra configuration. If this is annoying enough for you, I think it would be better to just use custom autocommands:
vim.api.nvim_create_autocmd({ "UIEnter", "ColorScheme" }, {
callback = function()
local normal = vim.api.nvim_get_hl(0, { name = "Normal" })
if not normal.bg then return end
io.write(string.format("\027]11;#%06x\027\\", normal.bg))
end,
})
vim.api.nvim_create_autocmd("UILeave", {
callback = function() io.write("\027]111\027\\") end,
})
Closing as both not an issue and not planned.
I don't changing default terminal color is a frequent enough use case to warrant adding extra configuration
This is not about changing the default terminal color, this is about how it break every terminal that follow OS dark-light preference, this is non-trivial imo :thinking:
This is not about changing the default terminal color, this is about how it break every terminal that follow OS dark-light preference, this is non-trivial imo 🤔
The effect of following OS dark-light preference in terminal emulator is to effectively change its color scheme (which means changing its "default" background color). If using "\027]111\027\" OSC won't help, then there are even more reasons to not support this use case.
If using "\027]111\027\" OSC won't help, then there are even more reasons to not support this use case.
Are we misunderstanding each other? Just to be clear, \027]111\027\
does work properly—which is basically what I'm asking for here: a way to send it instead of sending, e.g.
H.termbg_init = H.termbg_init or bg_init
local reset = function() io.write('\027]11;' .. H.termbg_init .. '\007') end
where H.termbg_init is (e.g.) #162430
Are we misunderstanding each other? Just to be clear,
\027]111\027\
does work properly
Then my suggestion is to use it inside custom autocommands instead of setup_termbg_sync()
.
I don't see it as a good idea based solely on this use case to introduce configuration for an approach with less terminal emulator coverage, which should also be implemented, documented (introducing unnecessary confusion), and tested.
Contributing guidelines
Module(s)
misc
Description
Hello o/
Mini parse_osc11 implementation introduce a bug that breaks terminal background "restore" when following system-wide dark mode preferences:
https://github.com/user-attachments/assets/d085e224-a762-47f6-b16e-0e1f568fffd5
This issue does not occur when using the parse_osc11 function directly from https://github.com/neovim/neovim/blob/0d3f2c4904d552635da07a6e2b4e75520b514940/runtime/lua/vim/_defaults.lua#L430
https://github.com/user-attachments/assets/218497d5-5132-49b3-8041-1198ba6319e6
Neovim version
0.10.0
Steps to reproduce
Using e.g. Fedora 40 in VM
Then run neovim and change desktop to dark or light mode and exit