mirror of
https://github.com/wez/wezterm.git
synced 2024-11-23 15:04:36 +03:00
wezterm: fix panic when a large paste is chunked in an emoji
wezterm splits pastes into chunks of 1KB. If that chunk was in the middle of a UTF8 multibyte sequence, the rust string library would panic. This commit rounds the chunk size up to the next character boundary. closes: https://github.com/wez/wezterm/issues/281
This commit is contained in:
parent
9d33073d70
commit
1eab37b677
@ -45,7 +45,13 @@ fn schedule_next_paste(paste: &Arc<Mutex<Paste>>) {
|
||||
let pane = mux.get_pane(locked.pane_id).unwrap();
|
||||
|
||||
let remain = locked.text.len() - locked.offset;
|
||||
let chunk = remain.min(PASTE_CHUNK_SIZE);
|
||||
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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user