[Backport release-0.9] fix(tui): don't set tty background if &bg was set before VimEnter (#23766)

* fix(tui): don't set tty background if &bg was set before VimEnter

(cherry picked from commit 7d1b3c2b46)

* fix(tui): use nvim_get_option_info2 instead of &bg

(cherry picked from commit a60cfebdb9)

---------

Co-authored-by: Null Chilly <nullchilly@gmail.com>
This commit is contained in:
github-actions[bot]
2023-05-26 12:20:11 +02:00
committed by GitHub
parent ea5ebe509b
commit 3591252cc8

View File

@@ -2860,8 +2860,8 @@ void set_tty_background(const char *value)
if (starting) { if (starting) {
// Wait until after startup, so OptionSet is triggered. // Wait until after startup, so OptionSet is triggered.
do_cmdline_cmd((value[0] == 'l') do_cmdline_cmd((value[0] == 'l')
? "autocmd VimEnter * ++once ++nested set bg=light" ? "autocmd VimEnter * ++once ++nested :lua if not vim.api.nvim_get_option_info2('bg', {}).was_set then vim.o.bg = 'light' end"
: "autocmd VimEnter * ++once ++nested set bg=dark"); : "autocmd VimEnter * ++once ++nested :lua if not vim.api.nvim_get_option_info2('bg', {}).was_set then vim.o.bg = 'dark' end");
} else { } else {
set_option_value_give_err("bg", 0L, value, 0); set_option_value_give_err("bg", 0L, value, 0);
reset_option_was_set("bg"); reset_option_was_set("bg");