From 19f7732aedd89c5718da729e5f4c4056ce828a02 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sat, 26 Jan 2019 08:00:41 +0000 Subject: 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. --- editors/vi.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'editors/vi.c') 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 HANDLE h = GetStdHandle(STD_INPUT_HANDLE); DWORD ret; - fflush(stdout); + if (hund == 0) { + /* Allow one event in the queue. Otherwise pasted test isn't + * displayed because there's still a key release event waiting + * after the last character is processed. */ + INPUT_RECORD record[2]; + DWORD nevent_out, mode; + + GetConsoleMode(h, &mode); + SetConsoleMode(h, 0); + ret = PeekConsoleInput(h, record, 2, &nevent_out); + GetConsoleMode(h, &mode); + return ret == 0 ? (nevent_out > 1) : 0; + } + fflush_all(); ret = WaitForSingleObject(h, hund*10); return ret != WAIT_TIMEOUT; #else -- cgit v1.2.3-55-g6feb