Skip to content

Commit

Permalink
fix: reset style at new line
Browse files Browse the repository at this point in the history
  • Loading branch information
pamburus committed Nov 30, 2021
1 parent 8729c44 commit 9d9622e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ categories = ["command-line-utilities"]
description = "Utility for viewing json-formatted log files."
keywords = ["cli", "human", "log"]
name = "hl"
version = "0.10.7-alpha.1"
version = "0.10.7"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
8 changes: 4 additions & 4 deletions src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ impl RecordFormatter {
});
});
};
//
// eol
//
s.batch(|buf| buf.push(b'\n'));
});
//
// eol
//
buf.push(b'\n')
}

fn format_field<S: StylingPush<Buf>>(
Expand Down
12 changes: 12 additions & 0 deletions src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ impl Theme {
current: None,
};
f(&mut styler);
styler.reset()
}
}

Expand Down Expand Up @@ -193,6 +194,12 @@ pub struct Styler<'a, B: Push<u8>> {
}

impl<'a, B: Push<u8>> Styler<'a, B> {
fn reset(&mut self) {
if let Some(style) = self.pack.reset {
self.pack.styles[style].apply(self.buf)
}
}

#[inline(always)]
fn set(&mut self, e: Element) -> Option<usize> {
self.set_style(self.pack.elements[e])
Expand Down Expand Up @@ -257,6 +264,11 @@ impl StylePack {

fn load(s: &themecfg::StylePack) -> Self {
let mut result = Self::default();
let items = s.items();
if items.len() != 0 {
result.styles.push(Style::reset());
result.reset = Some(0);
}
for (&element, style) in s.items() {
result.add(element, &Style::from(style))
}
Expand Down

0 comments on commit 9d9622e

Please sign in to comment.