-
Notifications
You must be signed in to change notification settings - Fork 164
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
strip-ansi-escapes
new release v0.1.2
is breaking reedline.
#616
Comments
not knowing a lot about Reedline, what is the project and what is the command you are running? that might help people reproduce the error and investigate 😋 |
Actually I'm just trying to compile an empty project. Just creating something like |
oh yeah i can reproduce with cargo new --lib /tmp/test_reedline
cd /tmp/test_reedline
cargo add [email protected]
cargo check |
Ah, they changed the API. Version 0.1.1/// Strip ANSI escapes from `data` and return the remaining bytes as a `Vec<u8>`.
///
/// See [the module documentation][mod] for an example.
///
/// [mod]: index.html
pub fn strip<T>(data: T) -> io::Result<Vec<u8>>
where
T: AsRef<[u8]>,
{
let c = Cursor::new(Vec::new());
let mut writer = Writer::new(c);
writer.write_all(data.as_ref())?;
Ok(writer.into_inner()?.into_inner())
} Version 0.1.2/// Strip ANSI escapes from `data` and return the remaining bytes as a `Vec<u8>`.
///
/// See [the module documentation][mod] for an example.
///
/// [mod]: index.html
pub fn strip<T>(data: T) -> Vec<u8>
where
T: AsRef<[u8]>,
{
fn strip_impl(data: &[u8]) -> io::Result<Vec<u8>> {
let c = Cursor::new(Vec::new());
let mut writer = Writer::new(c);
writer.write_all(data.as_ref())?;
Ok(writer.into_inner()?.into_inner())
}
strip_impl(data.as_ref()).expect("writing to a Cursor<Vec<u8>> cannot fail")
} |
I think this will fix the code in reedline. Old code/// Returns string with the ANSI escape codes removed
///
/// If parsing fails silently returns the input string
pub(crate) fn strip_ansi(string: &str) -> String {
strip_ansi_escapes::strip(string)
.map_err(|_| ())
.and_then(|x| String::from_utf8(x).map_err(|_| ()))
.unwrap_or_else(|_| string.to_owned())
} New/// Returns string with the ANSI escape codes removed
///
/// If parsing fails silently returns the input string
pub(crate) fn strip_ansi(string: &str) -> String {
String::from_utf8(strip_ansi_escapes::strip(string))
.map_err(|_| ())
.unwrap_or_else(|_| string.to_owned())
} |
Thank you @fdncred!!!! Can we release a hotfix for that? |
You're welcome. I don't do much here without @sholderbach's blessing. |
Thanks for the heads up @marcosfpr and thanks for the quick fix @fdncred! Not sure if a hotfix will be particularly long lived (unless you use pinned versions with I will land the API change already, and have a look if there are developments on the |
As the problematic version is now yanked this should be resolved |
Platform macOS,
Terminal software zsh
With the new strip-ansi-escapes release luser/strip-ansi-escapes#15 , reedline is not compiling in my project.
Steps to reproduce
Cargo.toml
:Am I doing something wrong? Thanks :)
The text was updated successfully, but these errors were encountered: