mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-09 14:52:25 +01:00
Strip OSC sequences before printing
This commit strips OSC (Operating System Command) sequences before printing lines. Eventually when time permits, I want to add back support for printing OSC sequences (and improve it to treat hyperlinks like an attribute). Until then, this should help prevent garbled output :)
This commit is contained in:
@@ -33,7 +33,7 @@ use crate::line_range::RangeCheckResult;
|
||||
use crate::preprocessor::{expand_tabs, replace_nonprintable};
|
||||
use crate::style::StyleComponent;
|
||||
use crate::terminal::{as_terminal_escaped, to_ansi_color};
|
||||
use crate::vscreen::AnsiStyle;
|
||||
use crate::vscreen::{strip_problematic_sequences, AnsiStyle};
|
||||
use crate::wrapping::WrappingMode;
|
||||
|
||||
pub enum OutputHandle<'a> {
|
||||
@@ -581,7 +581,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
||||
let italics = self.config.use_italic_text;
|
||||
|
||||
for &(style, region) in ®ions {
|
||||
let ansi_iterator = AnsiCodeIterator::new(region);
|
||||
let text = strip_problematic_sequences(region);
|
||||
let ansi_iterator = AnsiCodeIterator::new(&text);
|
||||
for chunk in ansi_iterator {
|
||||
match chunk {
|
||||
// ANSI escape passthrough.
|
||||
@@ -634,7 +635,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
||||
}
|
||||
} else {
|
||||
for &(style, region) in ®ions {
|
||||
let ansi_iterator = AnsiCodeIterator::new(region);
|
||||
let text = strip_problematic_sequences(region);
|
||||
let ansi_iterator = AnsiCodeIterator::new(&text);
|
||||
for chunk in ansi_iterator {
|
||||
match chunk {
|
||||
// ANSI escape passthrough.
|
||||
|
Reference in New Issue
Block a user