Merge pull request #288 from kinode-dao/dr/term-newline-paste-fix

fix: remove control chars from pasted lines
This commit is contained in:
doria 2024-03-26 16:33:18 -06:00 committed by GitHub
commit 17240b44e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -244,6 +244,8 @@ pub async fn terminal(
},
// handle pasting of text from outside
Event::Paste(pasted) => {
// strip out control characters and newlines
let pasted = pasted.chars().filter(|c| !c.is_control() && !c.is_ascii_control()).collect::<String>();
current_line.insert_str(line_col, &pasted);
line_col = line_col + pasted.len();
cursor_col = std::cmp::min(line_col.try_into().unwrap_or(win_cols), win_cols);