Skip to content

Commit

Permalink
Filter control characters
Browse files Browse the repository at this point in the history
  • Loading branch information
lusingander committed Sep 21, 2024
1 parent 8aaadf2 commit 72618e0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/widget/text_preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl TextPreviewState {
if let Some(msg) = msg {
warn_msg = Some(msg);
}
s.lines().map(|s| Line::raw(s.to_string())).collect()
s.lines().map(drop_control_chars).map(Line::raw).collect()
}
};

Expand All @@ -68,6 +68,10 @@ fn to_preview_string(bytes: &[u8]) -> String {
}
}

fn drop_control_chars(s: &str) -> String {
s.chars().filter(|c| !c.is_control()).collect()
}

fn build_highlighted_lines(
s: &str,
file_name: &str,
Expand Down

0 comments on commit 72618e0

Please sign in to comment.