-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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 large multiline text is extremelly slow #9232
Comments
While you're waiting (in step 6), is it actively typing the text into Neovim, or is it just hung? I ask because it is not a fair comparison between the two. Neovim-qt, because it is a GUI application, uses the clipboard directly. A terminal, on the other hand, has no choice but to communicate the clipboard contents by "typing it in" one character at a time. If your hang is during active text input, that's just the way things are. If your hang is happening before any text starts to show up, that's probably something we can optimize. |
nothing visible is happening while I wait... |
Great! Thanks. That's something we can work with. |
Why the windows terminal is not GUI application? and why it can't use clipboard api..... char one by one is vvvvvvvvvvvvvery slow |
Is anyway to optimize it ?? |
Mine slowly pasted over 30 seconds (just pasting build output from visual studio, around 450 lines), finished, and then hung the whole terminal... This was pasting into vim in Text flow in the window became completely broken, with the upper half empty, even if I background or close vim and do ctrl+l or run |
I have pasted 117 lines of code into Neovim and the Terminal freezes. I think it should be pasted immediately, but it's not. I have to close it using Task Manager after waiting a minute. Do you have any idea to solve this issue? |
@zadjii-msft note to self, this might be related to that other neovim hang thread. The theory had something to do with someone else taking the clipboard lock. |
For myself, this has improved a lot with newer versions of terminal, I'm on latest preview. Even if it is not instant, it is okish. |
Having the same problem with Far Manager running in Windows Terminal. |
This is still a serious problem. Using any of the shells, command prompt or power shell, if you are working in those text windows and paste in text, you can just watch how the text is pasted in slowly. And I have a really powerful machine. My guess is that this formatting filter that is applied before pasting is just really really bad coded and quite slow. I work a lot with text files and jump around in folder using tools like FileCommander. Those are not really usable anymore on Windows 11. And it's a pain to open each file in a separate editor, that's not running inside that command shell. And as impworks said, the legacy console is as fast as it should be. But once this console is gone, then we'll have a problem. |
@ngoc199 @impworks @Tillerz I found a solution for console software like Far Manager, etc. Seemly the slowing down is caused by the Windows Terminal which is an "emulator" over native PowerShell (in my understanding).
That's it, after this tweak my Far Manager look and works as in old times. |
This issue still exists. The paste is very slow. |
That's surely an interesting observation! If you're finding that pasting is slow in both conhost and Terminal, that seems like it would suggest that the issue is in the neovim implementation itself, right? Perhaps there's something in your config that's slowing it down? Almost everyone else in this thread seems to have an issue specifically with Terminal's paste implementation. That just makes it feel like what you're seeing is ultimately a different root cause. |
You are right @zadjii-msft. |
Not really. I've never used neovim, and copy/paste was staggeringly slow for me, too. It was truly unbelievably slow, frankly, with everything I tried. It was impossible to use for me at that time (sorry, no records of details, and I'm away from my desktop now). OTOH, interestingly, I've also noticed this extreme pasting slowdown even when supposedly using ConHost -- but only after trying the new Terminal, never before. So I got totally perplexed. Had to give up investigating it further, with my limited understanding (of this subsystem and its various interop. cases, dependencies etc.). |
I feel like there can be multiple issues at play here and we need to be careful not to mix them up.
|
FWIW, several Win10 updates later, I've quickly tried to reproduce the issue, and failed. Across Win - Win, across WSL - Win, WSLg - Win, whatever I tried today, it's smooth. For clarity, regarding @lhecker's list: "If pasting lags a lot even for small files (<1000 chars)" -- that was my main use case. It's possible, indeed, that something had locked the clipboard (but I vaguely recall really basic, dummy use cases, when it still happened). But now that we talk, I can recall another case from earlier this week, when it was a substantially larger amount of text, and it was not just slower, but I had to kill the stuck process minutes later. Unfortunately, I was not trying/equipped to gather data, and all my memories are vague now, but I'll try to keep an eye open then, and get back if I have anything useful. |
For anyone interested you can fix slow pasting in Windows Terminal for PowerShell console windows by commenting out command paste lines in Windows Terminal settings.json for immediate pasting. Execution will only trigger after all lines are pasted. Note: This solution is specifically for PowerShell console windows as it uses separate KeyHandlers for Ctrl+V, in PSReadline module. Try commenting out these in WT settings.json, i.e:
You might also want to consider disabling paste warning as well, as in:
|
Just ran into the issue with Microsoft.WindowsTerminal.Preview 1.19.2831.0 Surely if there is some kind of lock contention over the clipboard, the operation should just time out and abort the paste operation? Better to fail than crash all terminals trying to complete the action. |
@brookst Thanks for the report! It's a bug that I've recently caused and so far we weren't really aware about it. I'll open a PR in a bit. |
Yeah, I think it's different. After restarting, I can paste the same quantity of text fairly quickly. I think there must have been something else up with the system. DWM had leaked a load of memory and been restarted - could have been some interaction with that. One (separate) issue I do notice now is that the paste doesn't go through until I input another keypress, then it's sent after that keypress. So I have to send a new line or else it just sits there. This only seems to affect NVim though - pasting into, say, bash works fine. |
What amount of text are you pasting? I found the issue you described initially to be easily reproducible if I paste a ton of text at once (i.e. 1MB in this case). I think whether it deadlocks or not depends on a ton of circumstances, for instance on how nvim processes its input (i.e. it only happens if nvim redraws rapidly while also reading its input at the same). |
Hmm, using some random plain text from the terminal itself into nvim, it's fine at the end of a file. Even above the 5KiB warning, it pastes instantly. However I can reproduce the lock-up if the paste occurs within a line of existing text. Pasting in a piece of rich-text from a Windows application (happens to be Zotero in this case, but can also be from notepad which I guess has pre-stripped any rich-text-ness) into nvim (starting with an empty buffer) locks up the terminal and crashes it immediately. Pasting into the terminal itself seems to work ok. Copying the text back from the terminal into nvim causes the same lock-up. This text is ~80KiB and has a substantial amount of (non-ASCII) unicode in it. Portions of the text do not cause the same lock up, but I can't narrow down how much of it is needed to cause the lock-up (it seems to need all of it to reproduce the issue). So it seems like something neovim is doing with non-trivial input (mid-line paste, long-lines, unicode). This somehow takes out the terminal with it. I don't think that narrows it down exactly, but it is reproducible. I need to get on with other things and stop crashing my terminal now. I can't reliably reproduce the 'waiting for input before the paste takes effect' issue at this time. |
I've experienced the same issue with Far Manager in WT (created a new profile for it). Even pasting a few dozen lines was taking a few seconds (I could see lines appearing one by one on the screen). I tried the suggestion to comment out the following block in the settings.json:
and now I can paste arbitrary amounts of text instantly. This was also enough to suppress all warnings about multi-line paste. |
It might not work. |
Works great for me! Thank you. |
Environment
Windows Terminal Preview v1.6.10272.0 on windows 10 20h2
Steps to reproduce
Expected behavior
the text gets pasted instantly
Actual behavior
you have to wait a lot.
I tried pasting the same text in neovim-qt (the official GUI version of neovim) and the text gets inserted instantly.
I understand pasting large text would be weird in normal terminal usage, but when you are using wt to host neovim it is a legit use case.
The text was updated successfully, but these errors were encountered: