edit icon indicating copy to clipboard operation
edit copied to clipboard

Bug when copy/cut/paste some special characters

Open george-andrei opened this issue 7 months ago • 20 comments

When copying/cutting special characters like @, [, ], {, } then pasting them, the editor will print other characters or crash.

Ex:

  • copy/paste @ will not work
  • copy/paste [ will crash the editor. Mouse and special keys will print strange characters
  • copy/paste ], {, } will print different characters

george-andrei avatar May 21 '25 09:05 george-andrei

Confirmed on my end too.

Copy [ and then pasting it will make a lot of things insert other things, some I noticed.

  • mouse 1
  • mouse 2
  • scroll wheel up
  • scroll wheel down
  • scroll wheel press
  • backspace
  • insert
  • home
  • delete
  • end
  • home
  • pg up
  • pg down
  • arrow keys
  • any Alt +
  • any Ctrl +

Only copying the character is fine. It's after it's been pasted that the behavior occurs.

Jerakin avatar May 21 '25 09:05 Jerakin

I've tried this and couldn't reproduce it in Windows Terminal when simply trying to copy/paste those 5 characters. What terminal are you using?

lhecker avatar May 21 '25 12:05 lhecker

I've tried this and couldn't reproduce it in Windows Terminal when simply trying to copy/paste those 5 characters. What terminal are you using?

Windows Terminal Version: 1.22.11141.0

I tested with pwsh 7.5.1 and cmd. Same result in both cases.

george-andrei avatar May 21 '25 13:05 george-andrei

Window 11

Windows Terminal Version: 1.22.11141.0

(Also using clink, if that's relevant)

Also tried a on a Window 10 computer, same Terminal version as before, still using Clink. Still broken.

Edit: Tried in powershell (which isn't using clink) and it still happens.

Jerakin avatar May 21 '25 13:05 Jerakin

Additional characters I have found that doesn't copy paste properly: \, |, ~

Here I wrote \, I then copied it and pasted it. I can see in my clipboard that it's still a \

Image

Here I wrote [ copied it, made a new line, then pasted it. I then did the following with a new line after each: Mouse1, mouse2, ctr+s, ctrl+c, ctrl+v, arrow right, down, left, up

With [ copied and pasted I can no longer do anything as even pressing "File" will insert the characters.

Image

Copy pasting multiple of the characters at the same time only makes the first be pasted as something weird.

Line I copy followed by a paste. Image

Jerakin avatar May 21 '25 14:05 Jerakin

Actually if you copy/paste a group of these characters, only the first one is wrong:

Image

Unless it's [ in which case it crashes the editor.

george-andrei avatar May 21 '25 14:05 george-andrei

To make this issue even better [ doesn't crash the editor for me. Except that we get the same behavior.

Edit: WSL isn't install on my computer.

Jerakin avatar May 21 '25 15:05 Jerakin

I found that it won't crash on my end either (both in WSL and not) (I can even copy and paste '[' fine)

Image

Mikhail-Ramirez avatar May 21 '25 15:05 Mikhail-Ramirez

Lol for me still crashing even in WSL ubuntu:

Image

FYI, my ubuntu profile in Windows terminal is using the font "BlexMono"

george-andrei avatar May 21 '25 15:05 george-andrei

I tried on my end. I don't have any problems.

TechnologyTime avatar May 23 '25 09:05 TechnologyTime

I wonder if it has to do with the selected font. I just realized that it's using my terminal font that supports ligatures and it doesn't have the problem. I'm using Window Terminal 1.22.11141.0

CurroRodriguez avatar May 25 '25 13:05 CurroRodriguez

Ok, I just tried in Gnome term Version 3.44.0 with font "BlexMono Nerd Font Mono" and I could not reproduce. I'll try again tomorrow on WSL with another font and will update this issue.

Edit: I tried with "Cascadia Mono" and I have the same issue. I installed the terminal with winget so I tried with the .exe from github release and it's the same as well. Not sure what else could be different :-\

george-andrei avatar May 25 '25 17:05 george-andrei

Tried a lot of different fonts. Including the default(?) "Cascadia Mono" but the problem persist.

Jerakin avatar May 26 '25 08:05 Jerakin

I continue to be unable to reproduce the issue. I tried different keyboard layouts and so on as well.

If anyone has this issue on one of their PCs but not on another, we could check if there's any difference between them.

lhecker avatar May 26 '25 20:05 lhecker

I tested alacritty in Window and could not reproduce the issue.

Image

Using xterm in WSL is working as well:

Image

The problem looks to be caused by Windows Terminal. I don't understand why, I tried other fonts, I tried with WSL, CMD and PWSH, all have the same issue. Also tried changing various settings, but nothing. Any tips how I could troubleshoot this? Thanks!

george-andrei avatar May 27 '25 08:05 george-andrei

I can echo this. I have tried the cygwin terminal and it works as expected. Tried in the standalone gitbash and it worked as expected, tried in gitbash inside of Windows Terminal and the weird behavior is there.

I tried to remove my terminal folder at %LOCALAPPDATA%\Packages to reset it and it still behaves like this.

Downloading the latest zip from windows/terminal here on github still exhibits the behavior.

Jerakin avatar May 27 '25 13:05 Jerakin

What I found so far is that when I paste [0], there are two calls to sys::read_stdin. The first returns ESC [200~ and the second ESC 0] ESC [201~ So, there is an ESC (ASCII 27) where the [ should be.

Is that helpful? (This stuff is quite beyond my knowledge...)

Hasnabruzzn avatar Jun 18 '25 21:06 Hasnabruzzn

I think this is just a Windows Terminal bug: https://github.com/microsoft/terminal/issues/18579

I think it only occurs if you're pasting with a Ctrl keyboard shortcut, and only effects certain keyboard layouts (I can reproduce it with a German layout). I think you also need to have started the session with that keyboard layout already selected, e.g. it won't trigger if you start with an English layout and then switch to German.

j4james avatar Jun 18 '25 21:06 j4james

Yes, SHIFT-INSERT or inserting via the menu works fine. Only CTRL-V messes it up.

I'm using a Swiss layout...

Weird.

Hasnabruzzn avatar Jun 18 '25 22:06 Hasnabruzzn

Oh, interesting. I tried it with a Russian layout (due to that other Windows Terminal keyboard layout bug), and it didn't reproduce the issue for me. With a German layout on the other hand, pasting a [ results in an immediate freeze of the application. It never occurred to me to test other layouts...

lhecker avatar Jun 18 '25 22:06 lhecker