Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra characters appended when pasting text of certain size into Julia REPL running in VSCode #112831

Closed
BioTurboNick opened this issue Dec 18, 2020 · 17 comments
Assignees
Labels
*as-designed Described behavior is as designed bug Issue identified by VS Code Team member as probable bug confirmed Issue has been confirmed by VS Code Team member terminal General terminal issues that don't fall under another label
Milestone

Comments

@BioTurboNick
Copy link

BioTurboNick commented Dec 18, 2020

  • VSCode Version: 1.52.1
  • OS Version: Windows 10.0.21277

Steps to Reproduce:

  1. Install Julia 1.5.3
  2. Open Terminal inside VS Code
  3. Navigate to and execute julia.exe to run Julia REPL
  4. Paste "combinednormalizedmontecarlomeasurementsc" at prompt (right click, excluding quote marks)
  5. Observe that the characters "01~" have been appended.

Does this issue occur when all extensions are disabled?: Yes

The issue varies with length of the string, as documented here: julia-vscode/julia-vscode#1824

I'm reporting it here because this problem does not occur when the REPL is running inside a Windows Terminal window.

@meganrogge meganrogge added terminal General terminal issues that don't fall under another label bug Issue identified by VS Code Team member as probable bug labels Dec 18, 2020
@meganrogge meganrogge added this to the Backlog milestone Dec 18, 2020
@meganrogge meganrogge added confirmed Issue has been confirmed by VS Code Team member and removed confirmation-pending labels Oct 13, 2021
@meganrogge
Copy link
Contributor

Here are the logs from pasting combinednormalizedmontecarlomeasurementsc:

xterm.js: sending data "�[200~combinednormalizedmontecarlomeasurementsc�[201~" (53) [27, 91, 50, 48, 48, 126, 99, 111, 109, 98, 105, 110, 101, 100, 110, 111, 114, 109, 97, 108, 105, 122, 101, 100, 109, 111, 110, 116, 101, 99, 97, 114, 108, 111, 109, 101, 97, 115, 117, 114, 101, 109, 101, 110, 116, 115, 99, 27, 91, 50, 48, 49, 126]
LogService.ts:62 xterm.js: parsing data c
LogService.ts:62 xterm.js: parsing data ombinednormalizedmontecarlomeasurementsc01~

@meganrogge
Copy link
Contributor

meganrogge commented Oct 13, 2021

This happens for any string > 38 characters and < 44 characters

@meganrogge
Copy link
Contributor

happens for the same character counts even if I split the terminal / resize it

@Tyriar
Copy link
Member

Tyriar commented Oct 14, 2021

It looks like the Julia REPL is not handling bracketed paste mode correctly and sending it back to print 01~. \x1b[200~ and \x1b[201~ wrap pasted text only when requested by the REPL, these are meant to be stripped out by Julia after accepting them.

@Tyriar Tyriar closed this as completed Oct 14, 2021
@Tyriar Tyriar added the *as-designed Described behavior is as designed label Oct 14, 2021
@BioTurboNick
Copy link
Author

Thanks all for looking into it. I'll forward this over.

@BioTurboNick
Copy link
Author

@meganrogge Is the logging you did something I can enable locally? The extension dev isn't convinced it's something the extension is doing, and I'd like to be able to poke around at it.

Also, is bracketed paste mode something that is handled by Windows, or by VS Code and passed through to the extension and then to the REPL/terminal?

@Tyriar
Copy link
Member

Tyriar commented Nov 23, 2021

@BioTurboNick you can enable with the toggle escape sequence logging command, they then show up in devtool's console.

Bracketed paste mode is enabled by the shell process sending us \x1b[?2004h, we will then wrap any pasted text in \x1b[200~ and \x1b[201~. I don't know how Julia's repl is built but it might be built upon something that handles bracketed paste mode, maybe incorrectly?

@BioTurboNick
Copy link
Author

Thanks. The REPL when running in a normal Windows Terminal doesn't have the issue, which is what's odd.

Something that stands out to me: the logging shows bracketed data is being sent, but then it's being parsed into two chunks. Where is that happening? (maybe that's a downstream by-design side effect of the bug, but I just want to thoroughly understand what's happening).

Is the extension interposed into this process, and it should be stripping the brackets before the parse function is called using some hook?

Or are the brackets unexpected at the "sending data" stage, and the extension is supposed to, but isn't, stripping them out prior to that? Is there a hook it should be using?

@Tyriar
Copy link
Member

Tyriar commented Nov 23, 2021

@BioTurboNick WT doesn't support bracketed paste mode yet: microsoft/terminal#395

Something that stands out to me: the logging shows bracketed data is being sent, but then it's being parsed into two chunks.

That should be fine

Is the extension interposed into this process

I don't think the extension has anything to do with this, it's just the repl executable.

@BioTurboNick
Copy link
Author

@Tyriar sorry one more question to gauge my understanding

Is this what's happening?

  1. Paste event triggered in xTerm, wraps content in brackets.
  2. xTerm sends the data to STDIN
  3. Julia REPL reads STDIN, processes it, then sends to STDOUT
  4. xTerm reads STDOUT and displays text

@Tyriar
Copy link
Member

Tyriar commented Nov 24, 2021

Basically yeah, it's possible something funny is going on with conpty which is Windows' emulation layer if WT doesn't implements bracketed paste support. Hard to say exactly as I mainly only have experience programming on this side of the terminal.

@BioTurboNick
Copy link
Author

BioTurboNick commented Nov 24, 2021

Thanks. Okay. Just proving to myself I'm not crazy... Julia in WSL in WT vs. Julia in WSL in VSCode

image
image

(the tail of that last one shows stray end-bracket characters)

EDIT: further complicating matters is that both WSL examples work on Windows 11. But not on my Windows 10 machine.

@BioTurboNick
Copy link
Author

Out of curiosity, is there any way to interject some monitor of STDIN and STDOUT of the components here on Windows? Or to see which ones are hooked up to each other?

@BioTurboNick
Copy link
Author

Okay, it definitely isn't Julia at fault here. This issue should be reopened or moved to the appropriate supporting project repository.

This is the result of pasting into a WSL terminal on Windows 10 in VSCode after enabling bracketed paste mode manually:

image

@Tyriar
Copy link
Member

Tyriar commented Nov 29, 2021

On WSL it will be using a native pty backend where bracketed paste mode is supported. The more I think about this, the more I think this is blocked on Windows Terminal not supporting bracketed paste mode (microsoft/terminal#395).

@Tyriar
Copy link
Member

Tyriar commented Nov 29, 2021

Out of curiosity, is there any way to interject some monitor of STDIN and STDOUT of the components here on Windows? Or to see which ones are hooked up to each other?

I only know how to log on the terminal end via the escape sequences command on Windows.

@BioTurboNick
Copy link
Author

Okay, thanks! I'll keep an eye on that being released.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed bug Issue identified by VS Code Team member as probable bug confirmed Issue has been confirmed by VS Code Team member terminal General terminal issues that don't fall under another label
Projects
None yet
Development

No branches or pull requests

3 participants