From fe5a72c08edfb9b76cfc841ba4d10f61e9956d0f Mon Sep 17 00:00:00 2001 From: Pavel Ivanov Date: Wed, 20 Mar 2024 23:12:59 +0100 Subject: [PATCH] new: remove trailing whitespace in message and string values --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/model.rs | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 056f60b0..425807dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -738,7 +738,7 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hl" -version = "0.27.0-beta.3.3" +version = "0.27.0-beta.3.4" dependencies = [ "atoi", "bincode", diff --git a/Cargo.toml b/Cargo.toml index 591d1e6a..e4023013 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ categories = ["command-line-utilities"] description = "Utility for viewing json-formatted log files." keywords = ["cli", "human", "log"] name = "hl" -version = "0.27.0-beta.3.3" +version = "0.27.0-beta.3.4" edition = "2021" build = "build.rs" diff --git a/src/model.rs b/src/model.rs index afa6d2a8..15c0d96d 100644 --- a/src/model.rs +++ b/src/model.rs @@ -128,6 +128,7 @@ impl<'a> RawValue<'a> { #[inline] pub fn format_as_str(&self, buf: &mut Vec) { + let begin = buf.len(); match self { Self::Json(value) => { let mut reader = StrRead::new(&value.get()[1..]); @@ -139,6 +140,9 @@ impl<'a> RawValue<'a> { .unwrap(); } } + if let Some(end) = buf[begin..].iter().rposition(|&b| !b.is_ascii_whitespace()) { + buf.truncate(begin + end + 1); + } } #[inline]