mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 21:25:04 -07:00
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
This commit is contained in:
parent
d401b33314
commit
0fd8eb8aae
@ -3943,12 +3943,13 @@ static dict_T *create_environment(const dictitem_T *job_env, const bool clear_en
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef MSWIN
|
#ifndef MSWIN
|
||||||
// Set COLORTERM to "truecolor" if termguicolors is set and 256
|
// Set COLORTERM to "truecolor" if termguicolors is set
|
||||||
// otherwise, but only if it was set in the parent terminal at all
|
if (p_tgc) {
|
||||||
dictitem_T *dv = tv_dict_find(env, S_LEN("COLORTERM"));
|
dictitem_T *dv = tv_dict_find(env, S_LEN("COLORTERM"));
|
||||||
if (dv) {
|
if (dv) {
|
||||||
tv_dict_item_remove(env, dv);
|
tv_dict_item_remove(env, dv);
|
||||||
tv_dict_add_str(env, S_LEN("COLORTERM"), p_tgc ? "truecolor" : "256");
|
}
|
||||||
|
tv_dict_add_str(env, S_LEN("COLORTERM"), "truecolor");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user