mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
wcwidth: Return early for simple ASCII
Characters from space to before DEL are width 1, and they appear *often*. So it's quite a good idea to return early for them. Fixes #5866.
This commit is contained in:
parent
c27c8801af
commit
adcc70d0b3
@ -269,6 +269,10 @@ int fish_get_emoji_width(wchar_t c) {
|
|||||||
#include "widecharwidth/widechar_width.h"
|
#include "widecharwidth/widechar_width.h"
|
||||||
|
|
||||||
int fish_wcwidth(wchar_t wc) {
|
int fish_wcwidth(wchar_t wc) {
|
||||||
|
// Normal ASCII characters.
|
||||||
|
// These are the most common case, so it's worth checking them first.
|
||||||
|
if (wc < 0x7f && wc >= 0x20) return 1;
|
||||||
|
|
||||||
// The system version of wcwidth should accurately reflect the ability to represent characters
|
// The system version of wcwidth should accurately reflect the ability to represent characters
|
||||||
// in the console session, but knows nothing about the capabilities of other terminal emulators
|
// in the console session, but knows nothing about the capabilities of other terminal emulators
|
||||||
// or ttys. Use it from the start only if we are logged in to the physical console.
|
// or ttys. Use it from the start only if we are logged in to the physical console.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user