diff options
| author | JJ Liebig <jonathan.liebig@gmail.com> | 2026-09-03 19:03:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-03 19:03:47 +0200 |
| commit | ec745235a95df0004e14069b79689814104c199c (patch) | |
| tree | 6d48abcad2b60082ed3127c792239d5fbce917b9 /src/platform | |
| parent | 27b05c1082790e33e072e94822522eaea1753903 (diff) | |
fix(windows): preserve LF paste order (#3582)
refs #3172
Diffstat (limited to 'src/platform')
| -rw-r--r-- | src/platform/mod.rs | 9 | ||||
| -rw-r--r-- | src/platform/windows.rs | 12 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/platform/mod.rs b/src/platform/mod.rs index b831e120..f15c71ef 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -39,6 +39,15 @@ pub(crate) fn apply_pane_runtime_marker(command: &mut portable_pty::CommandBuild apply_pane_runtime_marker_platform(command); } +pub(crate) fn prepare_paste_text_for_pty(text: String) -> String { + prepare_paste_text_for_pty_platform(text) +} + +#[cfg(not(windows))] +fn prepare_paste_text_for_pty_platform(text: String) -> String { + text +} + #[cfg(not(windows))] pub(crate) fn terminal_title_for_presentation(title: &str) -> &str { title diff --git a/src/platform/windows.rs b/src/platform/windows.rs index 890c24ca..8d370964 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -134,6 +134,10 @@ pub(crate) fn terminal_title_for_presentation(title: &str) -> &str { title.strip_prefix("Administrator: ").unwrap_or(title) } +pub(crate) fn prepare_paste_text_for_pty_platform(text: String) -> String { + text.replace("\r\n", "\n").replace('\n', "\r\n") +} + /// Resolves against the current foreground layout because asynchronous console /// records do not retain the layout that was active when the key was pressed. pub(crate) fn resolve_base_printable_key(vk: u16, scan: u16) -> Option<char> { @@ -2599,6 +2603,14 @@ mod tests { }; #[test] + fn paste_text_uses_windows_line_endings() { + assert_eq!( + super::prepare_paste_text_for_pty_platform("one\ntwo\r\nthree\rfour".to_owned()), + "one\r\ntwo\r\nthree\rfour" + ); + } + + #[test] fn private_remote_directory_supports_long_paths() { let base = std::env::temp_dir().join(format!( "herdr-private-remote-dir-test-{}", |
