Skip to content

feat: add Clear() for reliable empty clipboard on Windows - #79

Open
Solaris-star wants to merge 1 commit into
atotto:masterfrom
Solaris-star:feat/68-clear-clipboard
Open

feat: add Clear() for reliable empty clipboard on Windows#79
Solaris-star wants to merge 1 commit into
atotto:masterfrom
Solaris-star:feat/68-clear-clipboard

Conversation

@Solaris-star

Copy link
Copy Markdown

Summary

On Windows, repeatedly reading then clearing the clipboard via WriteAll("") can fail subsequent reads (#68).

Fix

Add clipboard.Clear() which uses EmptyClipboard on Windows (and empty-write on other platforms). Document that callers who need a true empty clipboard should prefer Clear() over WriteAll("").

Fixes #68

Writing an empty string via WriteAll can leave the Windows clipboard in
a bad state for subsequent reads (atotto#68). Clear() uses EmptyClipboard and
is the supported way to empty the clipboard.

Other platforms implement Clear via writeAll("").

Fixes atotto#68
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clear clipboard Error in clipboard_windows.go

1 participant