Add bracketed paste#3233
Conversation
9d310b1 to
32b44b0
Compare
fc10eed to
89f6790
Compare
| } | ||
|
|
||
| Some(transaction) | ||
| pub(crate) fn paste_bracketed_value(cx: &mut Context, contents: String) { |
There was a problem hiding this comment.
This doesn't function as an actual command as I didn't see a good way to pass the contents through the Context. I think it's nicer to have it as a standalone function, but maybe I'm missing a way to make it work more like a regular command?
Because it's not a command, it doesn't set editor.last_insert and won't be repeated with .. Since you can spam your paste key as easily as ., I didn't think that was a big deal.
| { | ||
| Ok(Some(transaction)) => { | ||
| doc.apply(&transaction, view.id); | ||
| doc.append_changes_to_history(view.id); |
There was a problem hiding this comment.
This isn't needed here as it's done in editor's event handling.
|
|
||
| match event { | ||
| Event::Paste(contents) => { | ||
| cx.count = cx.editor.count; |
There was a problem hiding this comment.
I felt like it made more sense to use a pending count here, though I could also see leaving it for an upcoming command.
|
|
||
| pub use crate::keyboard::{KeyCode, KeyModifiers}; | ||
|
|
||
| #[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)] |
There was a problem hiding this comment.
Because the paste data is on the heap, we have to lose this Copy. That's why there's all this introduction of references through the rest of the PR.
89f6790 to
8cb1d29
Compare
|
Is there a need for |
|
Yes, not all terminals support bracketed paste (I also prefer |
|
Looks like Windows sends paste events regardless, so we need to get this merged before |
|
That's frustrating that Windows sends bracketed pastes regardless. This is ready to go as far as I know. If this PR needs additional work, we could also disable the |
50394bf to
a9f57fa
Compare
a9f57fa to
f9e2700
Compare
archseer
left a comment
There was a problem hiding this comment.
Thanks for working on this! It fixes a longstanding papercut for new users that didn't know about space+p.
This adds bracketed paste support to fix #2239. It's based on this PR on crossterm, so that will need to land and be released before this can be merged.
I haven't done any serious benchmarking, but I tried the Moby Dick Workout. Pasting with this enabled took maybe a tenth of a second to get the whole meg of book in there. Without this, I think it would've taken a day or so.