-
-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Another attempt to fix limited length of paste.
I humbly submit this patch as another attempt to address the issue that tcell will only paste up to 11 characters at a time. The problem is caused by the fact that events (key, mouse, etc) constructed from the stream of raw input characters are sent to the consuming application over a length-10 channel via screen.PostEvent() which, if the channel is full, will drop what can't be sent immediately. If the input stream grows rapidly e.g. because the user pasted a large section of text into the running tcell application, then more than 10 events will likely be built from the chunk of input read by scanInput(). A blocking channel send is not used (i.e. PostEventWait() instead of PostEvent()) because the channel send is issued from a call stack in which the screen struct's lock is held. If the receiving application is not consuming events, then callers to other screen APIs will block waiting for the screen's lock. If the receiving application needs to call another screen API before reading from the channel, a deadlock may occur if that required screen API tries to take the screen's lock. This patch collects events extracted from the input stream into a slice while the lock is held, then after releasing the screen lock, writes them in order to the event channel with PostEventWait(). I chose the blocking API to ensure events aren't dropped, since sending the events outside of the lock-held scope should remove the risk of a deadlock (unless I've missed something important!) This patch is similar in spirit to that submitted by @soyking: soyking@9addd5b. I have not adjusted the windows cmd console screen because the paste problem does not seem to be an issue in practice on that platform, at least according to my testing.
- Loading branch information
Showing
1 changed file
with
36 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters