simple errors for lang-dev
fix width calculation of escapes
| -rw-r--r-- | .github/example.png | bin | 20132 -> 18968 bytes | |||
| -rw-r--r-- | Cargo.toml | 4 | ||||
| -rw-r--r-- | src/lib.rs | 8 |
3 files changed, 7 insertions, 5 deletions
diff --git a/.github/example.png b/.github/example.png Binary files differindex 9f574e3..c48594e 100644 --- a/.github/example.png +++ b/.github/example.png @@ -1,6 +1,6 @@ [package] name = "lerr" -version = "0.1.3" +version = "0.1.4" edition = "2021" license = "MIT" readme = "README.md" @@ -14,6 +14,4 @@ keywords = ["error", "lang-dev", "diagnostics"] [dependencies] comat = "0.1.0" unicode-width = "0.1.10" - -[dev-dependencies] anstream = { version = "0.5.0", default-features = false } @@ -7,6 +7,7 @@ clippy::dbg_macro, missing_docs )] +use anstream::adapter::strip_str; use comat::{cwrite, cwriteln}; use config::Charset; use std::{fmt::Write, ops::Range}; @@ -115,7 +116,7 @@ impl<'s> Error<'s> { #[cfg(test)] fn monochrome(&self) -> String { - anstream::adapter::strip_str(&self.to_string()).to_string() + strip_str(&self.to_string()).to_string() } } @@ -157,7 +158,10 @@ impl<'s> std::fmt::Display for Error<'s> { point += 1; } // ^^^ [<this part length>] - let msglen = UnicodeWidthStr::width(candidate.message.as_str()); + let mut msglen = 0; + for chr in strip_str(candidate.message.as_str()) { + msglen += UnicodeWidthStr::width(chr); + } found.push((candidate, msglen, point)); } else { i += 1; |