aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ui.c
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2024-06-12 19:55:28 -0500
committerGitHub <noreply@github.com>2024-06-12 19:55:28 -0500
commit0231265c8cf8c13f317bbddcfcbac2639e7022cd (patch)
treee258e29530a872f3cedf6cc01bfd5db10bc9c25a /src/nvim/ui.c
parent6311a7fe4b416c23a336c1392a44cf3192ebde36 (diff)
downloadrneovim-0231265c8cf8c13f317bbddcfcbac2639e7022cd.tar.gz
rneovim-0231265c8cf8c13f317bbddcfcbac2639e7022cd.tar.bz2
rneovim-0231265c8cf8c13f317bbddcfcbac2639e7022cd.zip
fix(tui): skip TUI in ui_rgb_attached (#29096)
The ui_rgb_attached function determines if any UI is attached which supports RGB (truecolor). We determine if the TUI supports RGB via the 'termguicolors' option which is checked at the beginning of this function. If the TUI does not support RGB ('termguicolors' is unset), we check to see if any _other_ UI is attached which supports RGB. Normally, the TUI's "rgb" flag and the 'termguicolors' option are the same. However, they may differ during startup when the "rgb" flag is set by tui/tui.c to indicate to the core that the terminal emulator supports truecolor. The 'termguicolors' option is not actually set until _defaults.lua runs.
Diffstat (limited to 'src/nvim/ui.c')
-rw-r--r--src/nvim/ui.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 9bb66b886e..314d322a68 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -144,11 +144,15 @@ void ui_free_all_mem(void)
/// Returns true if any `rgb=true` UI is attached.
bool ui_rgb_attached(void)
{
- if (!headless_mode && p_tgc) {
+ if (p_tgc) {
return true;
}
for (size_t i = 0; i < ui_count; i++) {
- if (uis[i]->rgb) {
+ // We do not consider the TUI in this loop because we already checked for 'termguicolors' at the
+ // beginning of this function. In this loop, we are checking to see if any _other_ UIs which
+ // support RGB are attached.
+ bool tui = uis[i]->stdin_tty || uis[i]->stdout_tty;
+ if (!tui && uis[i]->rgb) {
return true;
}
}