Fix fread clipboard handling on Windows (fixes #1292)#7640
Fix fread clipboard handling on Windows (fixes #1292)#7640AmanKashyap0807 wants to merge 2 commits intoRdatatable:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @MichaelChirico, I’ve synced the branch with master. Let me know if there’s anything else I should do on my end to help resolve these! |
| }) | ||
| } else { | ||
| # Note: macOS (pbpaste) and Linux (xclip/xsel) support discussed in #1292 | ||
| stopf("Clipboard reading is supported on Windows only.") |
There was a problem hiding this comment.
i wonder if we must stopf here
There was a problem hiding this comment.
I added the explicit error to avoid this potentially confusing behavior on non-Windows systems.
I tested this by commenting out else-stopf() block on Ubuntu 20.04 (WSL). In that case, fread("clipboard") falls through and returns:
> temp <- fread("clipboard")
> print(temp)
Empty data.table (0 rows and 1 cols): clipboardThat said, if preserving the current fallback behavior is preferred for compatibility, I’m happy to remove the stopf() and let the normal control flow continue.
Closes #1292
Fix fread clipboard handling on Windows using
readClipboard(), add test (#2366), and update NEWS.Changed files :
clipboardinputs on Windows, reading it by using readClipboard(), handle errors and process clipboard content as a temporary file for parsing.To keep the scope of issue #1292, I only solved it for Windows. I'd be happy to submit another PR for macOS and Linux later.
Reproduction:
fread()does not recognize"clipboard"/"clipboard-128"as clipboard input on Windows. Due to the long period since the issue was reported, there might have been some changes in fread() over time, which is why the error message differs now, but the core problem is the same, clipboard input is not detected.Environment:
Please let me know if any changes are needed.