Skip to content

Commit 3c4b1a7

Browse files
authored
fix: paste not working in PTY sessions (#89)
* fix: Enable paste operations in PTY mode sessions Resolves clipboard paste issues in PTY SSH sessions by implementing bracketed paste mode support and handling Event::Paste events. Changes: - Enable bracketed paste mode in TerminalStateGuard::new() - Disable bracketed paste mode in restore_terminal_state() - Add Event::Paste handler in handle_input_event() - Increase SmallVec capacity from 8 to 64 bytes for paste content - Update PtyMessage::LocalInput to use SmallVec<[u8; 64]> - Add comprehensive unit tests for paste event handling This fixes paste operations on all platforms (macOS Cmd+V, Linux Ctrl+Shift+V, Windows Ctrl+V) by properly capturing and forwarding pasted content through the SSH channel. Tests: All 455 tests pass, including 8 new paste event tests * fix: Add paste size limit and optimize memory handling - Add 1MB size limit to prevent memory exhaustion attacks (H1 issue) - Return None for empty paste to avoid unnecessary channel sends (M1 issue) - Use from_vec() instead of into_bytes() + from_slice() to avoid double copy (L1 issue) - Add test for paste size limit behavior * style: Apply cargo fmt formatting to test assertions * test: Add comprehensive tests for key input handling - Add tests for all Ctrl+key combinations (C, D, Z, A, E, U, K, W, L, R, B, F) - Add tests for arrow keys (Up, Down, Left, Right) - Add tests for all function keys (F1-F12) and verify F13+ returns None - Add tests for special keys (Enter, Tab, Backspace, Esc, Home, End, PageUp, PageDown, Insert, Delete) - Add tests for KeyEventKind::Release and Repeat being ignored - Add tests for modifier keys (Shift accepted, Alt/Meta ignored for chars) - Add tests for Unicode and emoji character input - Add test for mouse events returning None - Add test for Ctrl+char out of range
1 parent cb84ad5 commit 3c4b1a7

3 files changed

Lines changed: 909 additions & 6 deletions

File tree

src/pty/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ pub enum PtyState {
9191
#[derive(Debug)]
9292
pub enum PtyMessage {
9393
/// Data from local terminal to send to remote
94-
/// SmallVec<[u8; 8]> keeps key sequences stack-allocated
95-
LocalInput(SmallVec<[u8; 8]>),
94+
/// SmallVec<[u8; 64]> handles both key sequences and paste content without allocation
95+
LocalInput(SmallVec<[u8; 64]>),
9696
/// Data from remote to display on local terminal
9797
/// SmallVec<[u8; 64]> handles most terminal output without allocation
9898
RemoteOutput(SmallVec<[u8; 64]>),

0 commit comments

Comments
 (0)