Skip to content
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

fixes background reset #2900

Merged
merged 4 commits into from
Jun 28, 2022
Merged

fixes background reset #2900

merged 4 commits into from
Jun 28, 2022

Conversation

sbromberger
Copy link
Contributor

Fixes #2856 (comment). Another set of eyes on this would be good, but here's how it looks (before / after; backgrounds deliberately garish):

Before:
IMG_0606

After:
IMG_0605

Some(Severity::Info) => info,
Some(Severity::Hint) => hint,
});
let style = Style::default().remove_modifier(Modifier::all()).patch(
Copy link
Contributor

@pickfire pickfire Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better if we patch it twice after reset? First with normal text background, then with diagnostic style.

Or another approach is to just fix the styles.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand. This is intended to fix the reported problem by removing the modifiers for the diagnostics (prior to applying the diagnostic style, which can include modifiers) while leaving the other style elements untouched.

What would patching twice buy us here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we could do

Style::reset().patch(background_style).patch(
  match {
    // ... that existing match expression ...
  },
)

I'm pretty sure that would be correct - I don't think there are any odd scenarios where we would want inherit a background that isn't the regular background, right 🤔?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I understand. OK. One sec.

Copy link
Member

@archseer archseer Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reset.patch(background) should be identical to just using background though. It's just a completely blank style

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at Style::reset, it looks like it'll start out with a sub_modifier of Modifier::all() which I think is what we need to clear the italics. We could probably do:

background_style.remove_modifier(Modifier::all())

to be more clear that we only want to drop the modifiers from the background

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you want me to follow up with this change, or are we all good at this point?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it's working well for me now so I say no need for any more changes 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy. Thanks, and sorry for the original oversight.

Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should do the trick 👍

Copy link
Contributor

@pickfire pickfire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Italics not reset for diagnostics text
4 participants