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

Pasting in multiline code terminal regression #25186

Closed
musm opened this issue Dec 19, 2017 · 26 comments
Closed

Pasting in multiline code terminal regression #25186

musm opened this issue Dec 19, 2017 · 26 comments
Labels
REPL Julia's REPL (Read Eval Print Loop)

Comments

@musm
Copy link
Contributor

musm commented Dec 19, 2017

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

@StefanKarpinski
Copy link
Sponsor Member

cc @rfourquet, @KristofferC

@rfourquet
Copy link
Member

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

@musm
Copy link
Contributor Author

musm commented Dec 19, 2017

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

@StefanKarpinski
Copy link
Sponsor Member

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

@musm
Copy link
Contributor Author

musm commented Dec 19, 2017

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

@StefanKarpinski
Copy link
Sponsor Member

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

@JeffBezanson JeffBezanson added REPL Julia's REPL (Read Eval Print Loop) system:windows Affects only Windows regression Regression in behavior compared to a previous version labels Dec 19, 2017
@vtjnash
Copy link
Sponsor Member

vtjnash commented Dec 19, 2017

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.

@vtjnash vtjnash closed this as completed Dec 19, 2017
@vtjnash vtjnash removed the regression Regression in behavior compared to a previous version label Dec 19, 2017
@StefanKarpinski
Copy link
Sponsor Member

StefanKarpinski commented Dec 19, 2017

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

@StefanKarpinski
Copy link
Sponsor Member

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.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Dec 19, 2017

Or you can just type \e[200~ <paste> \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)))

@StefanKarpinski
Copy link
Sponsor Member

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

@vtjnash
Copy link
Sponsor Member

vtjnash commented Dec 19, 2017

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 :)

@KristofferC
Copy link
Sponsor Member

Here in VSCode:

screen shot 2018-01-24 at 14 36 10

I'm guessing this is #22948. @rfourquet

@StefanKarpinski
Copy link
Sponsor Member

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

@rfourquet
Copy link
Member

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.

@Keno
Copy link
Member

Keno commented Mar 24, 2018

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

@Keno
Copy link
Member

Keno commented Mar 24, 2018

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

@KristofferC
Copy link
Sponsor Member

KristofferC commented Mar 24, 2018

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

@vtjnash vtjnash closed this as completed Mar 25, 2018
@vtjnash vtjnash reopened this Mar 25, 2018
@vtjnash
Copy link
Sponsor Member

vtjnash commented Mar 25, 2018

It’s not in VT100. Conhost.exe would need to implement this functionality - I’m not aware of its existence currently.

@Keno
Copy link
Member

Keno commented Mar 25, 2018

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.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Mar 25, 2018

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.

@Keno
Copy link
Member

Keno commented Mar 25, 2018

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

@Keno
Copy link
Member

Keno commented Mar 25, 2018

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

@musm
Copy link
Contributor Author

musm commented Aug 22, 2018

As of libuv/libuv@58ccfd4
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

@musm
Copy link
Contributor Author

musm commented Sep 10, 2018

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

@StefanKarpinski
Copy link
Sponsor Member

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

rfourquet added a commit that referenced this issue Sep 11, 2018
On some Windows terminals, pasting is not recognized as such.
This happens also with tmux' builtin paste.
In those cases, auto-indent is better disabled, as we want
to preserve the original indentation of the code being pasted.

This fix is quite a hack, but seems to work: using time(), if
the next character after a newline is being inserted very fast,
assume this was with paste, and cancel the insertion of the
spaces done by auto-indent.

I couldn't insert two characters in a raw within less than
about 0.03 or 0.02 seconds, so the threshold for "very fast"
is set to 0.0005, but this is an option which can changed.
rfourquet added a commit that referenced this issue Sep 11, 2018
On some Windows terminals, pasting is not recognized as such.
This happens also with tmux' builtin paste.
In those cases, auto-indent is better disabled, as we want
to preserve the original indentation of the code being pasted.

This fix is quite a hack, but seems to work: using time(), if
the next character after a newline is being inserted very fast,
assume this was with paste, and cancel the insertion of the
spaces done by auto-indent.

I couldn't insert two characters in a raw within less than
about 0.03 or 0.02 seconds, so the threshold for "very fast"
is set to 0.0005, but this is an option which can changed.
rfourquet added a commit that referenced this issue Oct 5, 2018
On some Windows terminals, pasting is not recognized as such.
This happens also with tmux' builtin paste.
In those cases, auto-indent is better disabled, as we want
to preserve the original indentation of the code being pasted.

This fix is quite a hack, but seems to work: using time(), if
the next character after a newline is being inserted very fast,
assume this was with paste, and cancel the insertion of the
spaces done by auto-indent.

I couldn't insert two characters in a raw within less than
about 0.03 or 0.02 seconds, so the threshold for "very fast"
is set to 0.0005, but this is an option which can changed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

No branches or pull requests

7 participants