Paste is annoyingly asynchronous wrt typeahead #19842

Open
opened 2026-01-31 06:55:05 +00:00 by claunia · 5 comments
Owner

Originally created by @KalleOlaviNiemitalo on GitHub (May 9, 2023).

Windows Terminal version

1.17.1023

Windows build number

10.0.19045.2846

Other Software

git version 2.40.0.windows.1

Steps to reproduce

Run Git Bash in Windows Terminal, while other processes are causing CPU and paging load.

Copy some text to the Clipboard from another application. (For example, copy a Git commit ID.)

In Git Bash, type some characters, press Shift+Insert to paste, and type more characters. (For example, type git cherry-pick initially, and press Enter at the end.)

Expected Behavior

Pasted text should appear in the correct place between the first and second sequence of characters.

Actual Behavior

Pasted text occasionally appears after the second sequence of characters. As if Shift+Insert starts an asynchronous paste operation that completes at some later time and injects its result into the terminal input at that time.

Originally created by @KalleOlaviNiemitalo on GitHub (May 9, 2023). ### Windows Terminal version 1.17.1023 ### Windows build number 10.0.19045.2846 ### Other Software git version 2.40.0.windows.1 ### Steps to reproduce Run Git Bash in Windows Terminal, while other processes are causing CPU and paging load. Copy some text to the Clipboard from another application. (For example, copy a Git commit ID.) In Git Bash, type some characters, press Shift+Insert to paste, and type more characters. (For example, type `git cherry-pick ` initially, and press Enter at the end.) ### Expected Behavior Pasted text should appear in the correct place between the first and second sequence of characters. ### Actual Behavior Pasted text occasionally appears after the second sequence of characters. As if Shift+Insert starts an asynchronous paste operation that completes at some later time and injects its result into the terminal input at that time.
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (May 9, 2023):

I think Windows Terminal should postpone the subsequent keyboard input events until the paste operation finishes. This should apply only to those events that become input to the session. It should not apply to events that the Terminal itself handles, like switching tabs or searching. Nor should it apply to reports that Terminal generates in response to requests from the session, rather than from user input.

If the clipboard owner hangs the paste operation altogether, then Windows Terminal could detect that after a timeout and display an information bar that lets the user cancel the paste by clicking an abort button or by pressing Ctrl+Break. If the user cancels the paste, Terminal should also discard all the postponed input of that session, to prevent it from running commands that don't include all the text originally intended by the user. (Not sure how this should behave if broadcast input mode https://github.com/microsoft/terminal/issues/2634 has been started or stopped during the paste operation.)

@KalleOlaviNiemitalo commented on GitHub (May 9, 2023): I think Windows Terminal should postpone the subsequent keyboard input events until the paste operation finishes. This should apply only to those events that become input to the session. It should not apply to events that the Terminal itself handles, like switching tabs or searching. Nor should it apply to reports that Terminal generates in response to requests from the session, rather than from user input. If the clipboard owner hangs the paste operation altogether, then Windows Terminal could detect that after a timeout and display an information bar that lets the user cancel the paste by clicking an abort button or by pressing Ctrl+Break. If the user cancels the paste, Terminal should also discard all the postponed input of that session, to prevent it from running commands that don't include all the text originally intended by the user. (Not sure how this should behave if broadcast input mode <https://github.com/microsoft/terminal/issues/2634> has been started or stopped during the paste operation.)
Author
Owner

@PankajBhojwani commented on GitHub (May 10, 2023):

Thanks for filing this issue! Yes, this is definitely a bug. This behaviour might have improved from PR #15328 (probably not completely fixed though... so we'll leave this issue open)

@PankajBhojwani commented on GitHub (May 10, 2023): Thanks for filing this issue! Yes, this is definitely a bug. This behaviour might have improved from PR #15328 (probably not completely fixed though... so we'll leave this issue open)
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (May 24, 2023):

The "In-PR" label should be removed because https://github.com/microsoft/terminal/pull/15360 no longer fixes this according to https://github.com/microsoft/terminal/pull/15360#issuecomment-1554710325.

@KalleOlaviNiemitalo commented on GitHub (May 24, 2023): The "In-PR" label should be removed because <https://github.com/microsoft/terminal/pull/15360> no longer fixes this according to <https://github.com/microsoft/terminal/pull/15360#issuecomment-1554710325>.
Author
Owner

@zadjii-msft commented on GitHub (Oct 4, 2023):

Maybe this got better in 1.19/?

@zadjii-msft commented on GitHub (Oct 4, 2023): Maybe this got better in 1.19/?
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (Oct 9, 2023):

I haven't seen the symptom in 1.19 yet, but TerminalPage::_PasteFromClipboardHandler still does co_await winrt::resume_background(); before it uses the clipboard API and then calls eventArgs.HandleClipboardData(std::move(text)) on the background thread, so I don't believe https://github.com/microsoft/terminal/pull/15360 can have fixed this completely.

@KalleOlaviNiemitalo commented on GitHub (Oct 9, 2023): I haven't seen the symptom in 1.19 yet, but TerminalPage::_PasteFromClipboardHandler still does `co_await winrt::resume_background();` before it uses the clipboard API and then calls `eventArgs.HandleClipboardData(std::move(text))` on the background thread, so I don't believe <https://github.com/microsoft/terminal/pull/15360> can have fixed this completely.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19842