#7420·starship

$fill 误计算 ZWJ 表情符序列的宽度 (例如 ‍ 在 home_symbol 中), 导致产生额外的填充字符

作者: rwestMSFT创建于 2026年4月24日更新于 2026年9月25日
标签🐛 bug

pkg_version:1.25.0 branch: commit_hash: build_time:2026-04-18 11:10:42 +00:00 build_env:rustc 1.94.1 (e408947bf 2026-03-25) (Homebrew), Generated bug report: #### Current Behavior Borrowing design cues from Powerlevel 10k, I have a two-line prompt. In iTerm2, when I am in my home directory, I want to use a ZWJ emoji character instead of ~ as the path name. When I do this, the clock wraps the last two characters to the next line. #### Expected Behavior The clock should not wrap to the next line when using a ZWJ emoji character as my path name. #### Additional context/Screenshots It seems like the Rust unicode-width crate doesn't handle ZWJ emoji sequences when calculating the display width of prompt content: it sums individual codepoint widths as opposed to recognizing the sequence renders as a single glyph. To work around this, I tell the terminal it's two characters shorter than it thinks. The effect is that the clock is not quite right-aligned, but at least it doesn't wrap. bash __fix_tw() { [[ "$PWD" == "$HOME" ]] && __STW=$(( COLUMNS - 2 )) || __STW=$COLUMNS; } precmd_functions+=(__fix_tw) PROMPT="${PROMPT//\$COLUMNS/\$__STW}" #### Possible Solution Calculate the ZWJ emoji as a single glyph. #### Environment - Starship version: 1.25.0 - zsh version: zsh 5.9 (arm64-apple-darwin25.0) - Operating system: Mac OS 26.4.1 - Terminal emulator: Apple_Terminal 470 - Git Commit Hash: - Branch/Tag: - Rust Version: rustc 1.94.1 (e408947bf 2026-03-25) (Homebrew) - Rust channel: release - Build Time: 2026-04-18 11:10:42 +00:00 #### Relevant Shell Configuration bash # --------------------------------------------------------------------------- # zsh configuration. PATH and other env vars are set in ~/.zshenv. # --------------------------------------------------------------------------- # History HISTFILE="$HOME/.zsh_history" HISTSIZE=50000 SAVEHIST=50000 setopt HIST_IGNORE_ALL_DUPS HIST_FIND_NO_DUPS HIST_EXPIRE_DUPS_FIRST HIST_SAVE_NO_DUPS setopt SHARE_HISTORY INC_APPEND_HISTORY EXTENDED_HISTORY # Completion: case-insensitive, hyphen-insensitive, colorized. autoload -Uz compinit compinit zstyle ':completion:' matcher-list 'm:{a-zA-Z-}={A-Za-z-}' 'r:|=' 'l:|=* r:|=' zstyle ':completion:' menu select zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" # Editor export EDITOR='nano' export VISUAL='code --wait' export LANG=en_US.UTF-8 # Aliases # fzf eval "$(fzf --zsh)" export FZF_DEFAULT_COMMAND="fd --hidden --strip-cwd-prefix --exclude .git" export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" export FZF_ALT_C_COMMAND="fd --type=d --hidden --strip-cwd-prefix --exclude .git" _fzf_compgen_path() { fd --hidden --exclude .git . "$1"; } _fzf_compgen_dir() { fd --type=d --hidden --exclude .git . "$1"; } # zsh plugins (installed via Homebrew) source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh source /opt/homebrew/share/zsh-history-substring-search/zsh-history-substring-search.zsh

内容来源: starship/starship