wsltty icon indicating copy to clipboard operation
wsltty copied to clipboard

Screen rendering issues with neovim inside tmux on wsltty 3.8.0.3

Open yamam opened this issue 4 months ago • 11 comments

Environment

Windows 11 Pro 23H2 (22631.5768) WSL2 (also reproducible on WSL1)
WSL 2.5.10.0
Ubuntu 24.04.3
tmux 3.4
Neovim v0.9.5
conhost.exe 1044480 Jun 16 16:39

Reproduction steps

$ sudo apt update
$ sudo apt install neovim
$ sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
       https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'

Create the following ~/.config/nvim/init.vim file:

call plug#begin()
Plug 'nvim-lualine/lualine.nvim'
Plug 'nvim-tree/nvim-web-devicons'
call plug#end()

lua << END
require('lualine').setup()
END

Start tmux and open Neovim:

$ tmux
$ nvim

Ignore the following error message:

E5108: Error executing lua [string ":lua"]:1: module 'lualine' not found:

Install plugins and exit.

:PlugInstall<Enter>
:qa<Enter>

Then reopen Neovim and open help.

$ nvim
:h<Enter>

The screen will become distorted as shown below. Image

However, if you run Neovim without tmux or add WSLbridge=2 to the wsltty config, the screen does not get distorted. Image

yamam avatar Aug 31 '25 23:08 yamam

In the above screenshot, the icon before "help" is not displayed correctly, but it will display properly if you install the Nerd Font from the link below: https://www.nerdfonts.com/font-downloads The following is a screenshot displayed using the 0xProto Nerd Font.

Image

yamam avatar Aug 31 '25 23:08 yamam

Referring to https://github.com/mintty/mintty/issues/1332#issuecomment-3240464515, apparently your conhost is the one deployed with Windows, not the substituted update which you need to install manually. Follow the wiki link in https://github.com/mintty/wsltty/#launching-wsl (I should make that clearer).

The file should look like: ls -l /mnt/c/Windows/System32/conhost.exe -rwxrwxrwx+ 1 user Kein 1150008 Aug 12 05:05 conhost.exe or -rwxrwxrwx+ 1 user Kein 1150536 Aug 30 05:05 conhost.exe as copied from OpenConsole.exe version 1.24 or 1.25. It should contain some version info as seen by strings conhost.exe | grep 1.0.2

mintty avatar Sep 01 '25 03:09 mintty

The footer looks a bit different for me, but not distorted:

Image

In your screenshot, look at the two spaces before "help" in the broken one instead of one space in the proper one. The additional space makes the line wrap around which explains the lower left artefact. The bug is the second space. Let's see whether it goes away with the updated conhost.

mintty avatar Sep 01 '25 03:09 mintty

I tried to rename conhost.exe, but I encountered an error and couldn't complete the renaming. Since replacing conhost.exe with OpenConsole.exe carries some risks, would it be possible to modify wsltty to use OpenConsole instead?

yamam avatar Sep 01 '25 04:09 yamam

Based on your screenshot, it appears that lualine is not enabled. After installing lualine with PlugInstall, please exit Neovim, then restart it and run :help.

yamam avatar Sep 01 '25 04:09 yamam

tried to rename conhost.exe, but I encountered an error and couldn't complete the renaming

You need to run as administrator to that aim (I'll improve the instructions...). From which shell did you try (cygwin, cmd, ...)?

installing lualine with PlugInstall

How? I'm not a vim user.

mintty avatar Sep 01 '25 06:09 mintty

You need to run as administrator to that aim (I'll improve the instructions...). From which shell did you try (cygwin, cmd, ...)?

I tried to rename conhost.exe from Windows Explorer. A dialog appeared stating that administrator privileges are required. When I attempted to proceed with administrator rights, an error message was displayed saying, "You need permission to perform this operation. To modify this file, you must obtain access permission from TrustedInstaller." As a result, I was unable to make the change. (In reality, the system message is not in English, so the actual displayed wording differs.)

How? I'm not a vim user.

This is described in the reproduction steps of this issue.

yamam avatar Sep 01 '25 07:09 yamam

OK, I forgot that step. And indeed, I could now reproduce the issue. Good news: it does not happen with the updated conhost.

You can do it within WSL: you must be running as administrator (e.g. right-click wsltty icon, "Run as Administrator"). Then, assuming Windows sits in C:\Windows, and you've copied the OpenConsole.exe from Windows terminal 1.25 to conhost.exe-1.25 before:

cd /mnt/c/Windows/System32
mv conhost.exe conhost.exe.old.1
cp conhost.exe-1.25 conhost.exe

(Or, from a cmd.exe window running as admin, use rename and copy accordingly.)

mintty avatar Sep 01 '25 08:09 mintty

I ran both WSL and cmd.exe with administrator privileges, but I was still unable to rename the files due to permission denied errors (perhaps because they are being used by other processes).

Alacritty can use OpenConsole by placing conpty.dll and OpenConsole.exe in its directory. Would it be possible for wsltty to support using OpenConsole.exe in a similar way?

yamam avatar Sep 01 '25 09:09 yamam

I've not had problems so far renaming conhost even while it's in use. Maybe if you close other programs?

I'd appreciate if someone provides an implementation that injects OpenConsole automatically. Problems are:

  • Mintty does not call CreateProcess (which is reportedly the place to make such injection effective); it calls the POSIX function forkpty and the cygwin/MSYS dll does the rest. I really hesitate to poke into that.
  • I do not have a conpty.dll, it's not part of the Windows terminal package; where does Alacritty get it from? I don't have a Windows build chain either - can the dll be downloaded somewhere with clear license?

mintty avatar Sep 01 '25 11:09 mintty

When I checked the Task Manager, I saw that many instances of conhost.exe are running, and I felt it would be difficult to terminate all of them and then rename conhost.exe. Additionally, since I'm unsure whether replacing conhost.exe with OpenConsole.exe would cause any issues, I would prefer not to replace conhost.exe with OpenConsole.exe if possible.

The conpty.dll file is located here: https://github.com/wezterm/wezterm/tree/main/assets/windows/conhost I do not know how wezterm or alacritty are utilizing openconsole.exe.

yamam avatar Sep 01 '25 22:09 yamam