Skip to content

Commit 185c2c1

Browse files
fix(formatting): resolve ANSI text effects into actual effects
The API change in cursive-core 0.4.0 included the addition of EffectStatus, which was intended to allow composite or additive effects, as well as exclusive effects. The recent update to misapplied this new API and ignored the status, effectively applying all styles, all the time. This change instead resolves the incoming styles against an "empty" style, yielding only the styles that should be applied. As far as I am aware, we don't do any compositing with cursive styles, so this should yield same results as we had with cursive 0.3. Moreover, because we're once again only iterating on the actual effects we need to apply, we can also restore the `bail!()` that was unnecessarily removed durint the upgrade. Closes #1642 Ref: ed946a9 Ref: f6a7008 Ref: gyscos/cursive@ea2e0be
1 parent b9e7e3a commit 185c2c1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

git-branchless-lib/src/core/formatting.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
use std::fmt::Display;
88

9-
use cursive::theme::{Effect, Style};
9+
use cursive::theme::{ConcreteEffects, Effect, Style};
1010
use cursive::utils::markup::StyledString;
1111
use cursive::utils::span::Span;
1212

@@ -404,14 +404,14 @@ fn render_style_as_ansi(content: &str, style: Style) -> eyre::Result<String> {
404404

405405
let output = {
406406
let mut output = output;
407-
for (effect, _status) in effects.statuses.iter() {
407+
for effect in effects.resolve(ConcreteEffects::empty()) {
408408
output = match effect {
409409
Effect::Simple => output,
410410
Effect::Dim => output.dim(),
411411
Effect::Reverse => output.reverse(),
412412
Effect::Bold => output.bold(),
413413
Effect::Italic => output.italic(),
414-
Effect::Strikethrough => output, // Not supported by console crate, skip it
414+
Effect::Strikethrough => eyre::bail!("Not implemented: Effect::Strikethrough"),
415415
Effect::Underline => output.underlined(),
416416
Effect::Blink => output.blink(),
417417
};

0 commit comments

Comments
 (0)