aboutsummaryrefslogtreecommitdiff
path: root/editors/vi.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-01-26 08:00:41 +0000
committerRon Yorston <rmy@pobox.com>2019-01-26 08:00:41 +0000
commit19f7732aedd89c5718da729e5f4c4056ce828a02 (patch)
tree67462763905f8e6cbbdaa2e1b2d8614dfa964538 /editors/vi.c
parent8e55f1eabc0632d6060caf1c0bf9325ac1cc19c2 (diff)
downloadbusybox-w32-19f7732aedd89c5718da729e5f4c4056ce828a02.tar.gz
busybox-w32-19f7732aedd89c5718da729e5f4c4056ce828a02.tar.bz2
busybox-w32-19f7732aedd89c5718da729e5f4c4056ce828a02.zip
vi: display pasted text
vi tries to avoid updating the display if more input is available. This didn't work when text was pasted in because a key release event was left in the event queue. When mysleep() is called to test for this condition allow up to one event to be present in the queue before reporting that input is available.
Diffstat (limited to 'editors/vi.c')
-rw-r--r--editors/vi.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/editors/vi.c b/editors/vi.c
index 433a37908..7b7f95cb1 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -2827,7 +2827,20 @@ static int mysleep(int hund) // sleep for 'hund' 1/100 seconds or stdin ready
2827 HANDLE h = GetStdHandle(STD_INPUT_HANDLE); 2827 HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
2828 DWORD ret; 2828 DWORD ret;
2829 2829
2830 fflush(stdout); 2830 if (hund == 0) {
2831 /* Allow one event in the queue. Otherwise pasted test isn't
2832 * displayed because there's still a key release event waiting
2833 * after the last character is processed. */
2834 INPUT_RECORD record[2];
2835 DWORD nevent_out, mode;
2836
2837 GetConsoleMode(h, &mode);
2838 SetConsoleMode(h, 0);
2839 ret = PeekConsoleInput(h, record, 2, &nevent_out);
2840 GetConsoleMode(h, &mode);
2841 return ret == 0 ? (nevent_out > 1) : 0;
2842 }
2843 fflush_all();
2831 ret = WaitForSingleObject(h, hund*10); 2844 ret = WaitForSingleObject(h, hund*10);
2832 return ret != WAIT_TIMEOUT; 2845 return ret != WAIT_TIMEOUT;
2833#else 2846#else