Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #182 #185

Merged
merged 3 commits into from
Jul 17, 2018
Merged

Fix #182 #185

merged 3 commits into from
Jul 17, 2018

Conversation

eth-p
Copy link
Collaborator

@eth-p eth-p commented Jul 5, 2018

Tested with:

printf '\033[33mfoo\033[1m bar\033[22m baz' | cargo run

Results (italic = yellow):

cat foo bar baz
bat 0.4.1: foo bar baz
fix-182: foo bar baz

src/printer.rs Outdated
for chunk in ansi_iterator {
match chunk {
// ANSI escape passthrough.
(text, true) => {
ansi_prefix = text;
if text.chars().last().unwrap() == 'm' {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we prevent the usage of unwrap() here? Maybe by using .map_or(false, |c| c == 'm')?

@eth-p
Copy link
Collaborator Author

eth-p commented Jul 5, 2018

I used your suggested change, and I added a little extra logic to clear the ansi_prefix_sgr variable if it detects a SGR reset code (ESC[0m).

@sharkdp
Copy link
Owner

sharkdp commented Jul 11, 2018

Sorry for the late reply.. I'm happy to merge this once the style changes are fixed (I tried to get an up-to-date rustfmt version to fix it myself, but couldn't get it to work).

@sharkdp sharkdp merged commit 6b57f4e into sharkdp:master Jul 17, 2018
@eth-p eth-p deleted the fix-182 branch September 8, 2018 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants