diff --git a/mux/src/pane.rs b/mux/src/pane.rs index 5657f60a1..f79360b68 100644 --- a/mux/src/pane.rs +++ b/mux/src/pane.rs @@ -1,10 +1,9 @@ use crate::domain::DomainId; use crate::renderable::*; -use crate::Mux; use async_trait::async_trait; use config::keyassignment::{KeyAssignment, ScrollbackEraseMode}; use downcast_rs::{impl_downcast, Downcast}; -use parking_lot::{MappedMutexGuard, Mutex}; +use parking_lot::MappedMutexGuard; use rangeset::RangeSet; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -98,45 +97,6 @@ pub enum CloseReason { Pane, } -const PASTE_CHUNK_SIZE: usize = 1024; - -struct Paste { - pane_id: PaneId, - text: String, - offset: usize, -} - -fn paste_next_chunk(paste: &Arc>) { - let mut locked = paste.lock(); - let mux = Mux::get(); - let pane = mux.get_pane(locked.pane_id).unwrap(); - - let remain = locked.text.len() - locked.offset; - let mut chunk = remain.min(PASTE_CHUNK_SIZE); - - // Make sure we chunk at a char boundary, otherwise the - // slice operation below will panic - while !locked.text.is_char_boundary(locked.offset + chunk) && chunk < remain { - chunk += 1; - } - let text_slice = &locked.text[locked.offset..locked.offset + chunk]; - pane.send_paste(text_slice).unwrap(); - - if chunk < remain { - // There is more to send - locked.offset += chunk; - schedule_next_paste(paste); - } -} - -fn schedule_next_paste(paste: &Arc>) { - let paste = Arc::clone(paste); - promise::spawn::spawn(async move { - paste_next_chunk(&paste); - }) - .detach(); -} - #[derive(Debug, Clone, PartialEq)] pub struct LogicalLine { pub physical_lines: Vec, @@ -348,22 +308,6 @@ pub trait Pane: Downcast + Send + Sync { fn tty_name(&self) -> Option { None } - - fn trickle_paste(&self, text: String) -> anyhow::Result<()> { - if text.len() <= PASTE_CHUNK_SIZE { - // Send it all now - self.send_paste(&text)?; - } else { - // It's pretty heavy, so we trickle it into the pty - let paste = Arc::new(Mutex::new(Paste { - pane_id: self.pane_id(), - text, - offset: 0, - })); - paste_next_chunk(&paste); - } - Ok(()) - } } impl_downcast!(Pane); diff --git a/wezterm-gui/src/termwindow/clipboard.rs b/wezterm-gui/src/termwindow/clipboard.rs index 47c23a096..d1ca7f81f 100644 --- a/wezterm-gui/src/termwindow/clipboard.rs +++ b/wezterm-gui/src/termwindow/clipboard.rs @@ -49,7 +49,7 @@ impl TermWindow { mux.get_pane(pane_id) }) { - pane.trickle_paste(clip).ok(); + pane.send_paste(&clip).ok(); } }))); } diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs index fe362ee5a..3eadc9538 100644 --- a/wezterm-gui/src/termwindow/mod.rs +++ b/wezterm-gui/src/termwindow/mod.rs @@ -979,7 +979,7 @@ impl TermWindow { }) .collect::>() .join(" "); - pane.trickle_paste(paths)?; + pane.send_paste(&paths)?; Ok(true) } WindowEvent::DraggedFile(_) => Ok(true),