Skip to content

Fix bracketed paste on Windows#149

Merged
Ikuyadeu merged 2 commits intoREditorSupport:masterfrom
andycraig:issue-117-radian-windows
Dec 8, 2019
Merged

Fix bracketed paste on Windows#149
Ikuyadeu merged 2 commits intoREditorSupport:masterfrom
andycraig:issue-117-radian-windows

Conversation

@andycraig
Copy link
Copy Markdown
Collaborator

@andycraig andycraig commented Nov 27, 2019

Fixes #117

What problem did you solve?

Quoting @Hong-Revo from #117 (comment)

I think the only indentation issue I'm having is that sometimes, Radian will treat a single multi-line block of submitted text as a group of lines. For example:

f <- function(x)
{
    if(x)
        return(42)
    else
    {
        if(TRUE)
            23
        else 69
    }
}

When I submit this, it shows up as:

image

Note the "+" in the middle. Also, sometimes radian thinks there is more text coming and I have to press Enter in the terminal to get it to process the submitted code. This is with bracketed paste on.

This PR makes two changes:

  1. When bracketed paste mode is set, sends code text all at once instead of line by line
  2. When bracketed paste mode is set and OS is Windows, does not attach ANSI control characters, as Windows does not seem to support these in general

How can I check this pull request?

  1. Use Windows
  2. If r.bracketedPaste setting not enabled, enable it and restart VSCode
  3. Paste this code into a file temp-R/temp.R:
f <- function(x) {
    if(x)
        return(42)
    else
    {
        if(TRUE)
            23
        else 69
    }
}
  1. 'Open Folder...' and choose 'temp-R'
  2. Start radian console
  3. Position cursor on line 1 of file
  4. R: Run Selection/Line in Active Terminal
  5. Observe no + in the text sent to the console, and no need to hit Enter in the console for it to make it process the code

For full testing, this should also be tried in the following configurations:

  1. Windows, with r.bracketedPaste not enabled, in normal R
  2. Mac/Linux, with r.bracketedPaste enabled, in radian
  3. Mac/Linux, with r.bracketedPaste not enabled, in normal R

I've tried these on Linux but I don't have access to a Mac.

Notes

This PR means that setting r.bracketedPaste on Windows doesn't actually use bracketed paste ANSI control characters. I think it's probably easier to just leave the setting name and description as-is, but open to discussion if anyone thinks it will make things too confusing.

I think this PR is probably fine as is but I would like to do a bit more testing. I will remove 'WIP' after that.

@hongooi73
Copy link
Copy Markdown

Thanks! Is there a way to test this without Node.js etc installed?

@andycraig
Copy link
Copy Markdown
Collaborator Author

@Hong-Revo Not that I know of. I’m hoping to finish testing it this weekend.

@andycraig andycraig changed the title WIP Fix bracketed paste on Windows Fix bracketed paste on Windows Dec 1, 2019
@andycraig
Copy link
Copy Markdown
Collaborator Author

@Ikuyadeu I have done some more testing and I think this PR is ready.

@Ikuyadeu
Copy link
Copy Markdown
Member

Ikuyadeu commented Dec 1, 2019

@andycraig Thank you for your continuous work!
I can only check the code maintainability cause my laptop OS.
I believe this function will work well.

For future maintenance work, I have one small question.
How did you decide delay function arguments? Currently preview.ts and rTerminal.ts have a that.

  • 350
  • 50
  • 200
  • 8

If it is based on your test experience, OK! I merge now.
If you have any references for them, can you share it with me and name these values? After checking, I will merge this PR.

@andycraig
Copy link
Copy Markdown
Collaborator Author

@Ikuyadeu Great, thank you!

@Ladvien I think you chose the delay amounts, perhaps you can answer @Ikuyadeu's question about them? Thank you in advance!

@Ikuyadeu
Copy link
Copy Markdown
Member

Ikuyadeu commented Dec 8, 2019

OK, I will merge this.
If that maintainability future work makes confusing, I will refactor them.

@Ikuyadeu Ikuyadeu merged commit b5f6178 into REditorSupport:master Dec 8, 2019
@andycraig
Copy link
Copy Markdown
Collaborator Author

@Ikuyadeu Great, thank you!

@randy3k
Copy link
Copy Markdown
Member

randy3k commented Dec 22, 2019

I don’t know much about vscode terminal but radian indeed supports bracketed paste mode in Windows.

@andycraig
Copy link
Copy Markdown
Collaborator Author

@randy3k I’m sure that’s true but something in the combination of Windows + VSCode + bracketed paste mode + radian doesn’t work. The VSCode Julia extension uses the same solution (bracketed paste mode on Mac/Linux, no bracketed paste mode on Windows) so I’m pretty sure the problem is on the Windows + VSCode side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Messy indentation in console when sending text to Radian

4 participants