aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/funcs.c
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2023-08-21 13:55:51 -0500
committerGitHub <noreply@github.com>2023-08-21 13:55:51 -0500
commit0fd8eb8aae101815c699048a4dbc6ac7c5e35a9d (patch)
treed75db5ab56cc2d579bc70d5f693d14ec5bb4af1c /src/nvim/eval/funcs.c
parentd401b33314a4178b23443c78119055c3d34a407e (diff)
downloadrneovim-0fd8eb8aae101815c699048a4dbc6ac7c5e35a9d.tar.gz
rneovim-0fd8eb8aae101815c699048a4dbc6ac7c5e35a9d.tar.bz2
rneovim-0fd8eb8aae101815c699048a4dbc6ac7c5e35a9d.zip
fix(terminal): set $COLORTERM unconditionally in :terminal (#24763)
$COLORTERM is set in the terminal emulator based on the value of 'termguicolors' ("truecolor" if &tgc is set, 256 otherwise), but ONLY if $COLORTERM is also set in the parent terminal emulator. This is an unnecessary restriction that can cause issues in some cases. For instance, $COLORTERM is stripped by default by OpenSSH, so is not present in an SSH session. The terminal emulator still supports 24 bit color, so the lack of $COLORTERM is not a reliable indicator. When an application runs in Nvim's :terminal it thus has no way to know whether or not true color is supported. Instead, setting it unconditionally based on 'termguicolors' uses the user's own preferences to infer if 24-bit color is supported, rather than depending on the (unreliable) presence of $COLORTERM. If 'termguicolors' is set in a terminal that does not support true color then the colors in Nvim will already look bad. Enabling them for applications in the terminal emulator will not make it any worse. If 'termguicolors' is not set then the value of $COLORTERM from the parent terminal (if any) is forwarded to Nvim's :terminal. Fixes: https://github.com/neovim/neovim/issues/24717
Diffstat (limited to 'src/nvim/eval/funcs.c')
-rw-r--r--src/nvim/eval/funcs.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 755df761e7..cf8525e66a 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -3943,12 +3943,13 @@ static dict_T *create_environment(const dictitem_T *job_env, const bool clear_en
}
}
#ifndef MSWIN
- // Set COLORTERM to "truecolor" if termguicolors is set and 256
- // otherwise, but only if it was set in the parent terminal at all
- dictitem_T *dv = tv_dict_find(env, S_LEN("COLORTERM"));
- if (dv) {
- tv_dict_item_remove(env, dv);
- tv_dict_add_str(env, S_LEN("COLORTERM"), p_tgc ? "truecolor" : "256");
+ // Set COLORTERM to "truecolor" if termguicolors is set
+ if (p_tgc) {
+ dictitem_T *dv = tv_dict_find(env, S_LEN("COLORTERM"));
+ if (dv) {
+ tv_dict_item_remove(env, dv);
+ }
+ tv_dict_add_str(env, S_LEN("COLORTERM"), "truecolor");
}
#endif
}