-
-
Notifications
You must be signed in to change notification settings - Fork 302
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 into Elvish is slow #1744
Comments
What version of Elvish are you using? What does |
In fact, I used the |
It was on 0.20.0-dev.0.20230826021805-1c0cffbfed89+official, but to be sure I downloaded the latest HEAD again. So, now I have 0.20.0-dev.0.20240108164435-9112eb1ab2f4+official. I tried poking around it a little more, it seems like it isn't that slow with built-in commands such as A quick screen recording, 2024-01-09.09-43-48.mp4This is with Windows Terminal (1.18.3181.0), with a Starship prompt. A little digging around and it seems like Windows Terminal should support bracketed pasting? (microsoft/terminal#395) By the way, after rewatching my own recording for a dozen of times, it seems like Elvish isn't evaluating if the input is valid on every character. It just takes in characters slowly for some reason. Edit: This is reproduceable in the integrated terminal in VSCode too, on the same computer. |
I tested on macOS + kitty + elvish nightly and it is instant (grep with 2743 characters pasted from an lorum ipsum). I also tested on a Raspberry Pi 4 (LXTerminal) which should be much less powerful than your system and there is a tiny pause for 2743 characters, but broadly identical with zsh. Try install alacritty or kitty on windows and seeing there? |
I read that issue and the last comment was someone saying it doesn't appear to work. There is also no reason that "with external commands it becomes really noticeable". I suspect that is a quirk of your environment. Elvish syntax highlighting speed should be independent of whether a command is a builtin or external. With the caveat that if the command isn't a builtin Elvish has to then traverse That you are running Elvish on Windows is something you should have stated in the original problem statement (along with the Elvish version). I am reasonably confident that if you enable the SSH service and connect to your Windows system, via the |
Coincidentally, I read this blog post a couple of days ago that was written by a Microsoft software engineer: https://devblogs.microsoft.com/commandline/windows-command-line-introducing-the-windows-pseudo-console-conpty/ TL;DR: The Microsoft support for things the Unix community pretty much takes for granted, like bracketed paste mode, is likely to have bugs. It is pretty unlikely that Elvish will implement workarounds for bugs of that nature. |
Note that is how I interact with my Windows 11 VM 99% of the time. And I just tested that scenario and was able to recreate your problem. So even using an SSH connection from a terminal emulator (iTerm2 on macOS) I know handles this correctly doesn't work. Which means the Windows ConHost/ConPTY subsystem is still broken. |
Just tried with Alacritty, no luck. This really looks like a Windows-specific issue now, lol.
This PC does have about two dozen directories in I tried running the Linux binary for Elvish under WSL2 too (also in Windows Terminal), and all pastes are instant. Looks like there's really a bug in ConHost/ConPTY... I'll try opening an issue in the Windows Terminal repo I think. Thanks everyone for the help! |
Hey! I work on Windows Terminal. The reason this occurs is because elvish needs to set In other words, this is missing a elvish/pkg/cli/term/setup_windows.go Lines 11 to 12 in 8d8e5ae
There seems to be another bug somewhere though, as I can see As an aside, I would heavily recommend calling elvish/pkg/cli/term/reader_windows.go Line 51 in 8d8e5ae
Since it uses unbuffered pipes, each call incurs a syscall and cross-process communication. On the latest conhost/OpenConsole version from the main branch for instance, there's barely any difference between reading 1 |
@lhecker Thanks! There are some reasons why the code works like this though:
I don't have my Windows environment right now, and will get back to this when I do in a few days. |
Oops, closed this by accident. Reopening |
@lhecker, Does Windows ConPTY VT mode support extended modifier keys? If it does that would address the first point in @xiaq's comment since Elvish already supports extended modifier keys on Unix platforms. I found issues such as microsoft/terminal#4334 and this 4 year old ConPTY design document but couldn't readily determine whether Unix style VT modifier keys is supported by Windows and, if so, when that support was introduced. Yes, I could write some code to test the hypothesis but since I don't use Windows other than for testing programs like Elvish on Windows it is easier to simply ask for clarification. :-) |
Yes, the document you found describes our primary way of doing it right now. It's the win32-input-mode introduced here: microsoft/terminal#6309
We expect to resolve these issues this year. |
Currently, Elvish seems to try to check if the current input is valid on every character that is pasted into the prompt and update the prompt input's highlighting accordingly. Pasting into Elvish hence involves an "animation" of watching letters pop up one by one after pressing Ctrl-V, instead of a paste that happens instantaneously like pasting into Bash does.
This is significantly more noticeable on older computers with lesser resources (I mainly get this experience on a laptop that runs a 7th gen Intel), although the effect can still be visible on newer ones if the pasted text is long enough. The terminal emulator used doesn't seem to affect this behaviour.
Wondering if it is possible to fix or workaround it? Since this behaviour makes situations such as pasting long commands somewhat annoying. It is also impossible to cancel the paste halfway, as the unfinished input will still be (slowly) written to the prompt after using Ctrl-C to clear it.
The text was updated successfully, but these errors were encountered: