New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement CTRL-V support on Windows #521
Conversation
|
Sure thing!
What's the reasoning behind that? IMO, copy-paste should work out the box. Happy to make the change if you want, though. Let me know what the feature flag should be.
Ok. What do you want it to be called? |
Pushed 2 changes:
Note that C-q or C-v was used for QuotedInsert before. Now, I've bound C-v to ClipboardPaste by default on Windows. As far as I can tell, C-q doesn't really do anything my terminals on Windows anyways, but this is the smallest change I could make. |
I'm happy to squash commits once you're happy with the work. |
"paste-from-clipboard" is the name used by readline. |
Don't worry because most of the time |
Fixes #519. This commit adds a Windows-only dependency on clipboard-win to implement `read_pasted_text()`. The keymap is updated such that CTRL-V maps to (the new command) `PasteFromClipboard`. Before this commit, using mouse rightclick to paste would work in all terminals, but using CTRL-V to paste would only work in Windows Terminal (i.e. did _not_ work in cmd.exe and Powershell). A new Windows-only error variant is added. This can be returned if the clipboard lookup fails more than 10 times.
I squashed my commits and cleaned up the commit message. I addressed the two comments above. |
After reverting 7055c27 again, I've tested that rustyline compiles and passes all tests on a Windows and macOS machine. I've tested that paste is fixed on my Windows machine and not affected on the macOS machine. |
I see a previous action run failed because of cargo-fmt failures (https://github.com/kkawakam/rustyline/runs/2533459886?check_suite_focus=true). Those are unrelated to my change. I can fix them if you'd like (I've actually been undoing them as I worked to avoid a noisy diff). |
It may be related to rust 1.52.0: |
Thanks. |
Thanks for helping me with this. Do you have any idea when the next release (to crates.io) will be? |
Nope. |
@marcbowes This PR pulled in |
Oh, that sucks. I'm not the maintainer of this library, so I'm tagging @gwenn for input. I guess the options are:
Again, I'm not the maintainer, but if it were up to me I'd revert this commit, release 8.2.0, then readd the commit and release as 9.0.0. IMO, this was an important bugfix and consumers should not have to turn on a feature flag to disable bugs. |
Not sure it's important, but CI failed with rust 1.50.0 at deltachat/deltachat-core-rust#2448 Probably makes sense to pin rust version in GitHub Actions workflow of rustyline or test across several versions to avoid such surprises later. |
Sorry for this. |
8.2.0 released. |
This commit implements CTRL-V support on Windows. See #519 where this issue was raised.
Implementation notes
On Windows, we have 3 key changes:
clipboard-win
anderror-code
crates.read_pasted_text
by calling the clipboard-win crate. Errors are mapped to a new Windows-only error variant.QuotedInsert
will perform a yank using the text from the clipboard (inserting the text and moving the cursor).Testing
I made a new package:
As noted in #519, running this example in Windows Terminal works (CTRL-V pastes text from the system clipboard) while using Powershell or cmd.exe does not work (CTRL-V does nothing, while rightclick pastes text from the system clipboard).
After this change, CTRL-V works in all 3 shells. Mouse rightclick continues to work.
Other
See #520 for why I reverted the change to use fd-lock.