1

I have recently upgraded from WSL (Windows Subsystem for Linux) version 1 to version 2. I am having a problem with using editors; some times, when I exit Nano or Vim, it wipes my history. I still have WSL V1 installed for comparison.

I am running on Windows 10, using the ConEmu terminal. My WSL V1 install is Ubuntu 18.04 and my WSL V2 install in Ubuntu 20.04. Both WSL setups are using xterm-256color.

Here are the symptoms:

  1. When the history is cleared, the last visible screen from Nano/Vim is left in the terminal history, but without any coloration (it turns white) and with enough blank lines below it that it is off the top of the screen. All I see is a single prompt at the bottom of an otherwise empty screen. There is no terminal history besides the final screen of what I had open in the editor, the blank lines, and the single terminal prompt.
  2. The history only clears when I have more than a full screen of terminal history. When I have less than a full screen of terminal history (i.e. no scrollbar), Nano/Vim exit normally (they preserve terminal history).
  3. The history is only cleared on WSL V2 (Ubuntu 20.04); WSL V1 (Ubuntu 18.04) works normally.
  4. The history is only cleared when I am running inside ConEmu. When I run WSL V2 through powershell, it works fine.
  5. All history clearing behavior works exactly as described above even when I am SSHed into a server! (i.e. history clearing occurs only on WSL V2 via ConEmu, and only if I have at least a full screen of terminal history).
  6. All of the above behavior is repeatable across killing and spawning new terminal tabs.
  7. When I try to paste the string xterm into Nano, Nano gives me the error "[ Unknown sequence ]" and then becomes completely unresponsive to user input (I have to kill the terminal window to get out). Pasting other text (including very similar strings) works fine.

I don't think it is a problem with ConEmu, because WSL V1 still works. I don't think it is a problem with my bash config, because it still occurs when I SSH into another server.

Point #7 seems to point a big finger at xterm as the culprit, but what is the setting to fix it?

1

Update: For your "#7" item (pasting the word "xterm" into nano), I'd recommend opening an issue against ConEmu, or perhaps commenting on this one. The problem seems to be related to Bracketed Paste. In ConEmu, I see that bracketed paste is enabled (Settings -> Info -> Console States) when I'm in a WSL2 session, but not when I'm in a WSL1 session.

There doesn't seem to be any way to disable it, but perhaps there is. According to the ConEmu issue, it should be turned off at the application level, but this doesn't sound quite right to me, given the research below.

Not sure if any of the other issues you are seeing are related to it, but it seems to be the big difference between when problem #7 happens and when it doesn't.

Also not sure why the text "xterm" triggers this, but nothing else. Perhaps the ConEmu team can assist there as well.

Background Research:

There's definitely some super-funky-interaction going on there (and that's the technical term for it). I downloaded ConEmu (latest release from the Github releases page).

I'm just going for focus on #7 in your question for the moment:

  • I can reproduce the "[ Unknown Sequence ]" and subsequent lock-up when pasting "xterm" into Nano under ConEmu + WSL2 + Ubuntu 20.04.
  • As you have seen, this only seems to apply with Nano + ConEmu + WSL2. If I change to my WSL1 Ubuntu 20.04 under ConEmu - No problem. If I paste "xterm" into nano on Windows Terminal using the same WSL instance (WSL2 Ubuntu 20.04) - No problem.
  • Under ConEmu + WSL2 + Kali, I do not get the "[ Unknown Sequence ]", but the session still does become unresponsive.

Here's some new information, though:

  • When pasting "xterm" at the prompt (fish shell, for me) under WSL2 and ConEmu, I get one of two things. Either (1) a brief "flash" before the text is pasted (which doesn't happen for anything else I've tried to paste), or (2) "^[[201xterm", usually on the second and subsequent paste attempts. On the bright side, fish doesn't lock up.

The ^[[201 seems to be "bracketed paste mode" (see here, the "CSI ? 2004 h" code). Of course, this is an escape sequence that originates from xterm, but that doesn't explain why pasting the text "xterm" will trigger it. It probably does explain why Nano chokes on it, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.