microsoft/Terminal

Wrong character when pasting into Windows Terminal with a Windows Subsystem for Linux profile

Open

#12,072 opened on Dec 30, 2021

View on GitHub
 (26 comments) (0 reactions) (0 assignees)C++ (3,212 forks)batch import
Area-InputArea-ServerHelp WantedIssue-BugPriority-2Product-Conhost

Repository metrics

Stars
 (35,764 stars)
PR merge metrics
 (Avg merge 27d 19h) (24 merged PRs in 30d)

Description

Windows Terminal version

1.11.3471.0

Windows build number

10.0.19044.0

Other Software

Windows Subsystem for Linux (version 2) Debian 5.10.60.1 (according to [Environment]::OSVersion in PowerShell inside WSL) PowerShell 7.2.1 (in Debian)

Steps to reproduce

First the case that I seem to be able to reproduce the easiest.

  1. First the general Windows Subsystem for Linux that's a bit hard to reproduce.

  2. Have Windows Subsystem for Linux installed and install Debian from the Windows store.

  3. Use the profile in Windows Terminal to open a command prompt for the WSL Debian machine.

  4. In Windows Terminal, have a hotkey for paste (such as CTRL+v or Shift+Insert) that's handled by Windows Terminal instead of the command line session.

  5. Install PowerShell using the instructions at https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux?view=powershell-7.2 .

  6. In the PowerShell profile (in my case, ~/.config/powershell/Microsoft.PowerShell_profile.ps1), put the following:

# Register an event when PowerShell is closing cleanly to save the current
# history.
#
# Note:  Closing PowerShell via the X button may not allow this to save.  But,
# typing "exit" should work.
Register-EngineEvent -SourceIdentifier PowerShell.Exiting -SupportEvent -Action {
	# Save-PSHistory

	# Check if any jobs are still running.
	If (Get-Job -State Running | Where-Object {$PSItem.Name -iNe 'PowerShell.Exiting'}) {
		Get-Job -State Running | Where-Object {$PSItem.Name -iNe 'PowerShell.Exiting'} | Wait-Job
	}


	# If we have Linux "sync", run it.
	#
	# For now, we'll only call sync if it's '/bin/sync'.  Add a delay just in case it doesn't run.
	If (Test-Path -Path '/bin/sync') {
		If (Get-Command -Type Application '/bin/sync') {
			& /bin/sync
		}
	}

	Start-Sleep -Seconds 2
}
  1. In a text editor, such as Notepad, put many Box Drawings Double Horizontal characters ("═", Unicode character 0x2550). In my case, I had 80 (═══════════════════════════════════════════════════════════════════════════════).

  2. In Windows Terminal, start a Debian session, and start PowerShell with "pwsh".

  3. Copy the line of Box Drawings Double Horizontal characters, not including any newline characters.

  4. Paste them into the Debian session in Windows Terminal via CTRL+v shortcut.

It has occurred for me in Bash, but it's not consistent. I've only had it happen a few times by pressing and holding CTRL+v to paste the text many times.

Expected Behavior

The same text that was copied should be pasted into the command prompt.

Actual Behavior

I see "═" (Unicode character 0x2550) and "�" (Unicode character 0xFFFD) pasted.

From my Windows Terminal:

PS /home/cdenn/.config> '════════���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������'
════════���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

Contributor guide