-
Notifications
You must be signed in to change notification settings - Fork 154
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
Bracketed Paste does not preserve newline characters in some terminal #576
Comments
Thanks for the report! This seems to be related to the trouble we were observing in nushell/nushell#8907 |
We can fix it with following patch. diff --git a/src/edit_mode/emacs.rs b/src/edit_mode/emacs.rs
index ec35384..54067aa 100644
--- a/src/edit_mode/emacs.rs
+++ b/src/edit_mode/emacs.rs
@@ -156,7 +156,7 @@ impl EditMode for Emacs {
Event::Resize(width, height) => ReedlineEvent::Resize(width, height),
Event::FocusGained => ReedlineEvent::None,
Event::FocusLost => ReedlineEvent::None,
- Event::Paste(body) => ReedlineEvent::Edit(vec![EditCommand::InsertString(body)]),
+ Event::Paste(body) => ReedlineEvent::Edit(vec![EditCommand::InsertString(body.replace('\r', "\n"))]),
}
}
diff --git a/src/edit_mode/vi/mod.rs b/src/edit_mode/vi/mod.rs
index 2a20155..ab5dc1b 100644
--- a/src/edit_mode/vi/mod.rs
+++ b/src/edit_mode/vi/mod.rs
@@ -153,7 +153,7 @@ impl EditMode for Vi {
Event::Resize(width, height) => ReedlineEvent::Resize(width, height),
Event::FocusGained => ReedlineEvent::None,
Event::FocusLost => ReedlineEvent::None,
- Event::Paste(body) => ReedlineEvent::Edit(vec![EditCommand::InsertString(body)]),
+ Event::Paste(body) => ReedlineEvent::Edit(vec![EditCommand::InsertString(body.replace('\r', "\n"))]),
}
}
|
Tagging @WindSoilder since could be a work-around to nushell/nushell#8907 |
Mhh worth checking if there are differences on Windows here. |
So maybe we need to do something like this?
|
Copy following text.
In macos/linux, after paste text above, I get events:
In windows, after paste text above, I get events:
In windows, crossterm dispatchs individual key events other than paste event. No need to replace |
It's interesting that it does a |
Yeah because it's always enabled on Windows, here is a relative pr to make it optional: crossterm-rs/crossterm#778 |
@sigoden Thank you for your testing on windows and mac. So bracketed paste still doesn't work on windows. And currently we can simply replace from |
Platform macOS
Terminal software iTerm2
Bracketed Paste does not preserve newline characters in some terminal.
Steps to reproduce
This may related to crossterm-rs/crossterm#780
In some terminal, they write \r instead of \n when pasting.
The text was updated successfully, but these errors were encountered: