-
-
Notifications
You must be signed in to change notification settings - Fork 690
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pty): paste freeze with large amounts of text (#1383)
add pty writer thread to avoid screen thread blocking on unistd::write
- Loading branch information
Showing
5 changed files
with
101 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use zellij_utils::errors::{ContextType, PtyWriteContext}; | ||
|
||
use crate::thread_bus::Bus; | ||
|
||
#[derive(Debug, Clone)] | ||
pub(crate) enum PtyWriteInstruction { | ||
Write(Vec<u8>, i32), | ||
} | ||
|
||
impl From<&PtyWriteInstruction> for PtyWriteContext { | ||
fn from(tty_write_instruction: &PtyWriteInstruction) -> Self { | ||
match *tty_write_instruction { | ||
PtyWriteInstruction::Write(..) => PtyWriteContext::Write, | ||
} | ||
} | ||
} | ||
|
||
pub(crate) fn pty_writer_main(bus: Bus<PtyWriteInstruction>) { | ||
loop { | ||
let (event, mut err_ctx) = bus.recv().expect("failed to receive event on channel"); | ||
err_ctx.add_call(ContextType::PtyWrite((&event).into())); | ||
let os_input = bus.os_input.clone().unwrap(); | ||
match event { | ||
PtyWriteInstruction::Write(bytes, terminal_id) => { | ||
if let Err(e) = os_input.write_to_tty_stdin(terminal_id, &bytes) { | ||
log::error!("failed to write to terminal: {}", e); | ||
} | ||
if let Err(e) = os_input.tcdrain(terminal_id) { | ||
log::error!("failed to drain terminal: {}", e); | ||
}; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters