diff --git a/CHANGELOG.md b/CHANGELOG.md index 0406fbbf..9267d327 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,10 @@ Versioning](https://semver.org/spec/v2.0.0.html). - Fixed builds on Wine 6.8 because of internal changes to Wine's `windows.h` implementation. +### yabridgectl + +- Fixed text wrapping being broken after a dependency update earlier this year. + ## [3.2.0] - 2021-05-03 ### Added diff --git a/tools/yabridgectl/Cargo.lock b/tools/yabridgectl/Cargo.lock index 70158860..438fb2a5 100644 --- a/tools/yabridgectl/Cargo.lock +++ b/tools/yabridgectl/Cargo.lock @@ -438,12 +438,6 @@ dependencies = [ "syn", ] -[[package]] -name = "smawk" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" - [[package]] name = "strsim" version = "0.10.0" @@ -461,6 +455,16 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "term_size" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "termcolor" version = "1.1.2" @@ -482,21 +486,20 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.12.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" dependencies = [ - "terminal_size", + "term_size", "unicode-width", ] [[package]] name = "textwrap" -version = "0.13.4" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd05616119e612a8041ef58f2b578906cc2531a6069047ae092cfb86a325d835" +checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789" dependencies = [ - "smawk", "terminal_size", "unicode-width", ] @@ -624,7 +627,7 @@ dependencies = [ "rayon", "serde", "serde_derive", - "textwrap 0.13.4", + "textwrap 0.11.0", "toml", "walkdir", "which", diff --git a/tools/yabridgectl/Cargo.toml b/tools/yabridgectl/Cargo.toml index e4358a9c..2dc6c576 100644 --- a/tools/yabridgectl/Cargo.toml +++ b/tools/yabridgectl/Cargo.toml @@ -20,7 +20,9 @@ promptly = "0.3.0" rayon = "1.3.1" serde = "1.0.114" serde_derive = "1.0.114" -textwrap = { version = "0.13.4", features = ["terminal_size"] } +# NOTE: textwrap 0.12.0 up to at least 0.13.4 apply the subsequent indent after +# wrapping +textwrap = { version = "0.11.0", features = ["term_size"] } toml = "0.5.6" walkdir = "2.3.1" which = "4.0.1" diff --git a/tools/yabridgectl/src/utils.rs b/tools/yabridgectl/src/utils.rs index 234371b8..7e705d91 100644 --- a/tools/yabridgectl/src/utils.rs +++ b/tools/yabridgectl/src/utils.rs @@ -27,7 +27,7 @@ use std::os::unix::fs as unix_fs; use std::os::unix::process::CommandExt; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; -use textwrap; +use textwrap::Wrapper; use crate::config::{self, Config, KnownConfig, YABRIDGE_HOST_EXE_NAME}; use crate::files::NativeFile; @@ -341,10 +341,7 @@ pub fn verify_wine_setup(config: &mut Config) -> Result<()> { /// Wrap a long paragraph of text to terminal width, or 80 characters if the width of the terminal /// can't be determined. Everything after the first line gets indented with four spaces. pub fn wrap(text: &str) -> String { - textwrap::fill( - text, - textwrap::Options::new(textwrap::termwidth()) - .splitter(textwrap::NoHyphenation) - .subsequent_indent(" "), - ) + let wrapper = Wrapper::with_termwidth().subsequent_indent(" "); + + wrapper.fill(text) }