Ignore spans when checking for RawElem equality (#6560)

This commit is contained in:
frozolotl 2025-07-09 14:04:22 +02:00 committed by GitHub
parent 4534167656
commit 9e6adb6f45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View File

@ -456,7 +456,11 @@ impl PlainText for Packed<RawElem> {
}
/// The content of the raw text.
#[derive(Debug, Clone, Hash, PartialEq)]
#[derive(Debug, Clone, Hash)]
#[allow(
clippy::derived_hash_with_manual_eq,
reason = "https://github.com/typst/typst/pull/6560#issuecomment-3045393640"
)]
pub enum RawContent {
/// From a string.
Text(EcoString),
@ -481,6 +485,22 @@ impl RawContent {
}
}
impl PartialEq for RawContent {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(RawContent::Text(a), RawContent::Text(b)) => a == b,
(lines @ RawContent::Lines(_), RawContent::Text(text))
| (RawContent::Text(text), lines @ RawContent::Lines(_)) => {
*text == lines.get()
}
(RawContent::Lines(a), RawContent::Lines(b)) => Iterator::eq(
a.iter().map(|(line, _)| line),
b.iter().map(|(line, _)| line),
),
}
}
}
cast! {
RawContent,
self => self.get().into_value(),

View File

@ -687,6 +687,11 @@ a b c --------------------
#let hi = "你好world"
```
--- issue-6559-equality-between-raws ---
#test(`foo`, `foo`)
#assert.ne(`foo`, `bar`)
--- raw-theme-set-to-auto ---
```typ
#let hi = "Hello World"