Julia: Pasting in multiline code terminal regression

Created on 19 Dec 2017  路  26Comments  路  Source: JuliaLang/julia

On 0.7 copy pasting the following

mutable struct Test
    a
    b
    c::String
end

Results in
image

compare to 0.6
image

This is especially/annoying/noticeable for larger blocks

REPL

Most helpful comment

We're not going to have the official "solution" to be typing some weird shit on Windows.

All 26 comments

cc @rfourquet, @KristofferC

Oh I can't reproduce... Could this is a differences in the shells?

BTW this is on Windows just using the regular cmd ....

Or a difference in terminals. cmd is notoriously the worst "terminal" around...

I tried conemu (and powershell) and is reproducible on all of them...

Ok, seems to be Windows specific then. I wonder if it has something to do with \r\n.

This is the auto-indent feature. On newer terminal emulators, "paste" is a special atomic action, so we can disable reformatting (among other issues). The Windows terminal doesn't have that feature.

Please don't close issues that are clearly a huge usability problem.

If the auto-indent feature cannot be properly supported on some terminals then we should turn it off on those terminals. The question is how to detect if we're running in such a terminal or not.

Or you can just type \e[200~ \e[201~ to make it work on Windows :)

If you'd like to reproduce this on your terminal, either type very, very quickly \e[?2004l, or use the following command to have Julia do it for you:

@async (sleep(1); Base.Terminals.disable_bracketed_paste(Base.Terminals.TTYTerminal("", STDIN, STDOUT, STDERR)))

We're not going to have the official "solution" to be typing some weird shit on Windows.

We're not going to have the official "solution" to be typing some weird shit on Windows.

There's nothing Windows-specific about it, you can test it out by doing the same on any system :)

Here in VSCode:

screen shot 2018-01-24 at 14 36 10

I'm guessing this is https://github.com/JuliaLang/julia/pull/22948. @rfourquet

@rfourquet, this bug was introduced by your changes. Do you have any ideas for the way forward here, short of reverting those features?

No I don't see what to do here, except disable the feature on Windows (if the bug is Windows specific and concerns every/most Windows platforms) or introduce a REPL option to disable the feature (I could swear this option already existed!) and document this problem together with the way to change the option. I will make a first PR to introduce the option anyway.

Seems like xterm.js added support in https://github.com/xtermjs/xterm.js/pull/1097. Since the windows
VT100 emulation is done by libuv, we might be able to fix it there too?

Also, since windows now has ENABLE_VIRTUAL_TERMINAL_PROCESSING, maybe we can just ask them to add it.

Being able to fix this to work properly universally would be great because the feature is really nice.

It鈥檚 not in VT100. Conhost.exe would need to implement this functionality - I鈥檓 not aware of its existence currently.

Well, ENABLE_VIRTUAL_TERMINAL_PROCESSING makes conhost behave like a unix terminal emulator (since that's what WSL uses to run unmodified ubuntu binaries in cmd), so it seems possible to request microsoft to implement this. In any case, since xterm.js has this feature now, maybe just a default disable on Windows would be sufficient.

I'm slightly confused how the existence of a javascript implementation of xterm is relevant to the Windows Console kernel driver or its GUI wrapper (conhost). I agree it would be nice if Microsoft implements this, but I doubt they read this issue tracker.

It's not. There were two concerns raised in this issue

  1. It doesn't work in VS Code (which as far as I understand uses an old version of xterm.js, so the way to fix that is to get them to upgrade it).
  2. It doesn't work on Windows
    Thus, since it's fixed in new version of xterm.js, only problem 2 remains. To get microsoft to fix it, the thing is probably to file it against WSL: https://github.com/Microsoft/WSL

Or rather https://github.com/microsoft/console is probably the right place

As of https://github.com/libuv/libuv/commit/58ccfd4c210d3cc1a36dd82474976aac296589f2
We should be able to just turn on ENABLE_VIRTUAL_TERMINAL_PROCESSING for Windows.
Also should enable DEFINE_CONSOLEV2_PROPERTIES see https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences

since this is so annoying, the workaround is to set Base.active_repl.options.auto_indent = false courtesy @rfourquet

Is there any way we can detect terminals where this is likely to be broken and turn auto indent off?

Was this page helpful?
0 / 5 - 0 ratings