mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 01:36:39 +08:00
Remove guessed_emoji_width
Just guess anew when it's not set. (this still uses the value of $fish_emoji_width, but clamped to 1 or 2 - we could also guess if it's an unusable value, but that's a different issue and tbh this variable is becoming less and less useful as time moves on and things move to the new widths by default) Fixes #8274.
This commit is contained in:
parent
07e512ecd8
commit
8b093e2651
|
@ -149,11 +149,11 @@ static void handle_timezone(const wchar_t *env_var_name, const environment_t &va
|
|||
tzset();
|
||||
}
|
||||
|
||||
/// Update the value of g_guessed_fish_emoji_width
|
||||
/// Update the value of g_fish_emoji_width
|
||||
static void guess_emoji_width(const environment_t &vars) {
|
||||
if (auto width_str = vars.get(L"fish_emoji_width")) {
|
||||
int new_width = fish_wcstol(width_str->as_string().c_str());
|
||||
g_fish_emoji_width = std::max(0, new_width);
|
||||
g_fish_emoji_width = std::min(2,std::max(1, new_width));
|
||||
FLOGF(term_support, "'fish_emoji_width' preference: %d, overwriting default",
|
||||
g_fish_emoji_width);
|
||||
return;
|
||||
|
@ -172,18 +172,18 @@ static void guess_emoji_width(const environment_t &vars) {
|
|||
|
||||
if (term == L"Apple_Terminal" && version >= 400) {
|
||||
// Apple Terminal on High Sierra
|
||||
g_guessed_fish_emoji_width = 2;
|
||||
g_fish_emoji_width = 2;
|
||||
FLOGF(term_support, "default emoji width: 2 for %ls", term.c_str());
|
||||
} else if (term == L"iTerm.app") {
|
||||
// iTerm2 now defaults to Unicode 9 sizes for anything after macOS 10.12.
|
||||
g_guessed_fish_emoji_width = 2;
|
||||
g_fish_emoji_width = 2;
|
||||
FLOGF(term_support, "default emoji width for iTerm: 2");
|
||||
} else {
|
||||
// Default to whatever system wcwidth says to U+1F603,
|
||||
// but only if it's at least 1.
|
||||
// but only if it's at least 1 and at most 2.
|
||||
int w = wcwidth(L'😃');
|
||||
g_guessed_fish_emoji_width = w > 0 ? w : 1;
|
||||
FLOGF(term_support, "default emoji width: %d", g_guessed_fish_emoji_width);
|
||||
g_fish_emoji_width = std::min(2,std::max(1, w));
|
||||
FLOGF(term_support, "default emoji width: %d", g_fish_emoji_width);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -221,17 +221,12 @@ int killpg(int pgr, int sig) {
|
|||
int g_fish_ambiguous_width = 1;
|
||||
|
||||
// Width of emoji characters.
|
||||
int g_fish_emoji_width = 0;
|
||||
|
||||
// 1 is the typical emoji width in Unicode 8.
|
||||
int g_guessed_fish_emoji_width = 1;
|
||||
int g_fish_emoji_width = 1;
|
||||
|
||||
static int fish_get_emoji_width(wchar_t c) {
|
||||
(void)c;
|
||||
// Respect an explicit value. If we don't have one, use the guessed value. Do not try to fall
|
||||
// back to wcwidth(), it's hopeless.
|
||||
if (g_fish_emoji_width > 0) return g_fish_emoji_width;
|
||||
return g_guessed_fish_emoji_width;
|
||||
return g_fish_emoji_width;
|
||||
}
|
||||
|
||||
// Big hack to use our versions of wcswidth where we know them to be broken, which is
|
||||
|
|
|
@ -21,9 +21,6 @@ extern int g_fish_ambiguous_width;
|
|||
/// painful this is. A value of 0 means to use the guessed value.
|
||||
extern int g_fish_emoji_width;
|
||||
|
||||
/// The guessed value of the emoji width based on TERM.
|
||||
extern int g_guessed_fish_emoji_width;
|
||||
|
||||
/// fish's internal versions of wcwidth and wcswidth, which can use an internal implementation if
|
||||
/// the system one is busted.
|
||||
int fish_wcwidth(wchar_t wc);
|
||||
|
|
Loading…
Reference in New Issue
Block a user