-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add bracketed paste #3233
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't needed here as it's done in editor's event handling.
@@ -1126,6 +1138,13 @@ impl Component for EditorView { | |||
}; | |||
|
|||
match event { | |||
Event::Paste(contents) => { | |||
cx.count = cx.editor.count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt like it made more sense to use a pending count here, though I could also see leaving it for an upcoming command.
@@ -6,10 +6,13 @@ use std::fmt; | |||
|
|||
pub use crate::keyboard::{KeyCode, KeyModifiers}; | |||
|
|||
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.