mirror of
https://github.com/typst/typst
synced 2025-07-11 22:52:53 +08:00
Ignore spans when checking for RawElem equality (#6560)
This commit is contained in:
parent
4534167656
commit
9e6adb6f45
@ -456,7 +456,11 @@ impl PlainText for Packed<RawElem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The content of the raw text.
|
/// 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 {
|
pub enum RawContent {
|
||||||
/// From a string.
|
/// From a string.
|
||||||
Text(EcoString),
|
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! {
|
cast! {
|
||||||
RawContent,
|
RawContent,
|
||||||
self => self.get().into_value(),
|
self => self.get().into_value(),
|
||||||
|
@ -687,6 +687,11 @@ a b c --------------------
|
|||||||
#let hi = "你好world"
|
#let hi = "你好world"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
--- issue-6559-equality-between-raws ---
|
||||||
|
|
||||||
|
#test(`foo`, `foo`)
|
||||||
|
#assert.ne(`foo`, `bar`)
|
||||||
|
|
||||||
--- raw-theme-set-to-auto ---
|
--- raw-theme-set-to-auto ---
|
||||||
```typ
|
```typ
|
||||||
#let hi = "Hello World"
|
#let hi = "Hello World"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user