Rendering issues with WSL and Unicode in Prompt #20281

Closed
opened 2026-01-31 07:08:56 +00:00 by claunia · 3 comments
Owner

Originally created by @0xb35c on GitHub (Jul 24, 2023).

Windows Terminal version

1.16.10262.0

Windows build number

10.0.22621.0

Other Software

> wsl --version
WSL-Version: 1.2.5.0
Kernelversion: 5.15.90.1
WSLg-Version: 1.0.51
MSRDC-Version: 1.2.3770
Direct3D-Version: 1.608.2-61064218
DXCore-Version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows-Version: 10.0.22621.1848

Steps to reproduce

Hi everyone,

I currently have the issue, that my cursor is a bit off on my WSL prompt. I use a zsh on Arch with the WSL Version mentioned above.
My zsh config:

export TERM=xterm-256color

# The following lines were added by compinstall

zstyle ':completion:*' menu select
zstyle ':completion:*' completer _expand _complete _ignored _approximate
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' '+r:|[._-]=** r:|=**' '+l:|=* r:|=*'
zstyle :compinstall filename '/home/schwendb/.zshrc'

autoload -Uz compinit colors vcs_info
colors
compinit

# End of lines added by compinstall
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=100000
SAVEHIST=100000
setopt autocd extendedglob
# Appends every command to the history file once it is executed
setopt inc_append_history
# Reloads the history whenever you use it
setopt share_history

setopt HIST_IGNORE_ALL_DUPS
setopt EXTENDED_HISTORY
setopt prompt_subst

bindkey -e
# End of lines configured by zsh-newuser-install

bindkey "^[[A" history-beginning-search-backward # Up
bindkey "^[[B" history-beginning-search-forward # Down
bindkey "^[[H" beginning-of-line # Pos1
bindkey "^[[F" end-of-line # End
bindkey "^[[3~" delete-char # Del
bindkey "^[[2~" overwrite-mode # Ins
bindkey "^[[1;5D" backward-word # Ctrl+Left
bindkey "^[[1;5C" forward-word # Ctrl+Right

zstyle ':vcs_info:*' stagedstr '%F{green}▴'
zstyle ':vcs_info:*' unstagedstr '%F{yellow}▴'
zstyle ':vcs_info:git:*' check-for-changes true
zstyle ':vcs_info:git*' formats "%F{blue} %b%u%c%f"

precmd () {
    vcs_info
}

RPROMPT='${vcs_info_msg_0_}'
PROMPT=" %(1j.%F{cyan}%j%f .)%F{blue}%3~%f %(!.%F{red}#%f .)%(?.%F{blue}.%F{red}[%?])❱%f "

I have the same behaviour when I use Windows Terminal, Fluent Terminal and VS Code. I assume the use the same backend? Also I use the patched Hack Font from https://github.com/ryanoasis/nerd-fonts/. I have also tried different fonts, the behaviour stays the same.

Expected Behavior

In my Linux vm the prompt in alacritty looks like this:
Prompt in alacritty in linux VM

Actual Behavior

On the prompt the curser is by about 4 characters off to the left. Also I have some spacing on the right, after the prompt:
Prompt in windows terminal and WSL

Originally created by @0xb35c on GitHub (Jul 24, 2023). ### Windows Terminal version 1.16.10262.0 ### Windows build number 10.0.22621.0 ### Other Software ``` > wsl --version WSL-Version: 1.2.5.0 Kernelversion: 5.15.90.1 WSLg-Version: 1.0.51 MSRDC-Version: 1.2.3770 Direct3D-Version: 1.608.2-61064218 DXCore-Version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows-Version: 10.0.22621.1848 ``` ### Steps to reproduce Hi everyone, I currently have the issue, that my cursor is a bit off on my WSL prompt. I use a zsh on Arch with the WSL Version mentioned above. My zsh config: ``` export TERM=xterm-256color # The following lines were added by compinstall zstyle ':completion:*' menu select zstyle ':completion:*' completer _expand _complete _ignored _approximate zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' '+r:|[._-]=** r:|=**' '+l:|=* r:|=*' zstyle :compinstall filename '/home/schwendb/.zshrc' autoload -Uz compinit colors vcs_info colors compinit # End of lines added by compinstall # Lines configured by zsh-newuser-install HISTFILE=~/.histfile HISTSIZE=100000 SAVEHIST=100000 setopt autocd extendedglob # Appends every command to the history file once it is executed setopt inc_append_history # Reloads the history whenever you use it setopt share_history setopt HIST_IGNORE_ALL_DUPS setopt EXTENDED_HISTORY setopt prompt_subst bindkey -e # End of lines configured by zsh-newuser-install bindkey "^[[A" history-beginning-search-backward # Up bindkey "^[[B" history-beginning-search-forward # Down bindkey "^[[H" beginning-of-line # Pos1 bindkey "^[[F" end-of-line # End bindkey "^[[3~" delete-char # Del bindkey "^[[2~" overwrite-mode # Ins bindkey "^[[1;5D" backward-word # Ctrl+Left bindkey "^[[1;5C" forward-word # Ctrl+Right zstyle ':vcs_info:*' stagedstr '%F{green}▴' zstyle ':vcs_info:*' unstagedstr '%F{yellow}▴' zstyle ':vcs_info:git:*' check-for-changes true zstyle ':vcs_info:git*' formats "%F{blue} %b%u%c%f" precmd () { vcs_info } RPROMPT='${vcs_info_msg_0_}' PROMPT=" %(1j.%F{cyan}%j%f .)%F{blue}%3~%f %(!.%F{red}#%f .)%(?.%F{blue}.%F{red}[%?])❱%f " ``` I have the same behaviour when I use Windows Terminal, Fluent Terminal and VS Code. I assume the use the same backend? Also I use the patched Hack Font from https://github.com/ryanoasis/nerd-fonts/. I have also tried different fonts, the behaviour stays the same. ### Expected Behavior In my Linux vm the prompt in alacritty looks like this: ![Prompt in alacritty in linux VM](https://github.com/microsoft/terminal/assets/9317774/4007b288-c7b9-4914-bacd-013b7ba954a6) ### Actual Behavior On the prompt the curser is by about 4 characters off to the left. Also I have some spacing on the right, after the prompt: ![Prompt in windows terminal and WSL](https://github.com/microsoft/terminal/assets/9317774/42dce0b4-9b20-463e-91fe-5725ac96a2f6)
claunia added the Needs-TriageIssue-BugNeeds-Attention labels 2026-01-31 07:08:56 +00:00
Author
Owner

@DHowett commented on GitHub (Jul 24, 2023):

Hmmm. This looks like a character width measurement issue on behalf of the shell (it thinks it knows where to place the cursor, but it does not.)

Can you share the output of locale in the working and non-working repros?

@DHowett commented on GitHub (Jul 24, 2023): _Hmmm._ This looks like a character width measurement issue on behalf of the shell (it thinks it knows where to place the cursor, but it does not.) Can you share the output of `locale` in the working and non-working repros?
Author
Owner

@0xb35c commented on GitHub (Jul 24, 2023):

Sure. For the WSL (not working):

locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES=
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

VM (working):

LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC=de_DE.UTF-8
LC_TIME=de_DE.UTF-8
LC_COLLATE="en_US.utf8"
LC_MONETARY=de_DE.UTF-8
LC_MESSAGES="en_US.utf8"
LC_PAPER=de_DE.UTF-8
LC_NAME=de_DE.UTF-8
LC_ADDRESS=de_DE.UTF-8
LC_TELEPHONE=de_DE.UTF-8
LC_MEASUREMENT=de_DE.UTF-8
LC_IDENTIFICATION=de_DE.UTF-8
LC_ALL=

Actually, the errors the locale command was printing, gave me a deciding hint. I had to regenerate the locales, it seems.

In the Archlinux WSL:

  • Edit your /etc/locale.gen and comment in the en_US.UTF-8 UTF-8 line
  • Run locale-gen
  • Reopen WSL
@0xb35c commented on GitHub (Jul 24, 2023): Sure. For the WSL (not working): ``` locale locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory LANG=en_US.UTF-8 LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES= LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL= ``` VM (working): ``` LANG=en_US.utf8 LC_CTYPE="en_US.utf8" LC_NUMERIC=de_DE.UTF-8 LC_TIME=de_DE.UTF-8 LC_COLLATE="en_US.utf8" LC_MONETARY=de_DE.UTF-8 LC_MESSAGES="en_US.utf8" LC_PAPER=de_DE.UTF-8 LC_NAME=de_DE.UTF-8 LC_ADDRESS=de_DE.UTF-8 LC_TELEPHONE=de_DE.UTF-8 LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=de_DE.UTF-8 LC_ALL= ``` Actually, the errors the locale command was printing, gave me a deciding hint. I had to regenerate the locales, it seems. In the Archlinux WSL: - Edit your `/etc/locale.gen` and comment in the `en_US.UTF-8 UTF-8` line - Run `locale-gen` - Reopen WSL
Author
Owner

@DHowett commented on GitHub (Jul 24, 2023):

Oh, woot! It worked! Thanks for following up. 😄

@DHowett commented on GitHub (Jul 24, 2023): Oh, woot! It worked! Thanks for following up. :smile:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20281