mirror of
https://github.com/typst/typst
synced 2025-05-19 11:35:27 +08:00
Remove idx
field from Run
This commit is contained in:
parent
7e69ee0942
commit
2fd8046405
@ -271,10 +271,10 @@ fn collect_range<'a>(
|
||||
items: &mut Items<'a>,
|
||||
fallback: &mut Option<ItemEntry<'a>>,
|
||||
) {
|
||||
for run in p.slice(range.clone()) {
|
||||
for (idx, run) in p.slice(range.clone()).enumerate() {
|
||||
// All non-text items are just kept, they can't be split.
|
||||
let Item::Text(shaped) = &run.item else {
|
||||
items.push(&run.item, run.idx);
|
||||
items.push(&run.item, idx);
|
||||
continue;
|
||||
};
|
||||
let subrange = &run.range;
|
||||
@ -295,10 +295,10 @@ fn collect_range<'a>(
|
||||
} else if split {
|
||||
// When the item is split in half, reshape it.
|
||||
let reshaped = shaped.reshape(engine, sliced);
|
||||
items.push(Item::Text(reshaped), run.idx);
|
||||
items.push(Item::Text(reshaped), idx);
|
||||
} else {
|
||||
// When the item is fully contained, just keep it.
|
||||
items.push(&run.item, run.idx);
|
||||
items.push(&run.item, idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ use super::*;
|
||||
pub struct Run<'a> {
|
||||
pub item: Item<'a>,
|
||||
pub range: Range,
|
||||
pub idx: usize,
|
||||
}
|
||||
|
||||
/// A representation in which children are already layouted and text is already
|
||||
@ -80,7 +79,6 @@ pub fn prepare<'a>(
|
||||
|
||||
let mut cursor = 0;
|
||||
let mut items = Vec::with_capacity(segments.len());
|
||||
let mut next_idx = 0;
|
||||
|
||||
// Shape the text to finalize the items.
|
||||
for segment in segments {
|
||||
@ -90,19 +88,10 @@ pub fn prepare<'a>(
|
||||
|
||||
match segment {
|
||||
Segment::Text(_, styles) => {
|
||||
shape_range(
|
||||
&mut items,
|
||||
engine,
|
||||
text,
|
||||
&bidi,
|
||||
range,
|
||||
styles,
|
||||
&mut next_idx,
|
||||
);
|
||||
shape_range(&mut items, engine, text, &bidi, range, styles);
|
||||
}
|
||||
Segment::Item(item) => {
|
||||
items.push(Run { range, item, idx: next_idx });
|
||||
next_idx += 1;
|
||||
items.push(Run { range, item });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -599,7 +599,6 @@ pub fn shape_range<'a>(
|
||||
bidi: &BidiInfo<'a>,
|
||||
range: Range,
|
||||
styles: StyleChain<'a>,
|
||||
next_idx: &mut usize,
|
||||
) {
|
||||
let script = TextElem::script_in(styles);
|
||||
let lang = TextElem::lang_in(styles);
|
||||
@ -608,8 +607,7 @@ pub fn shape_range<'a>(
|
||||
let dir = if level.is_ltr() { Dir::LTR } else { Dir::RTL };
|
||||
let shaped =
|
||||
shape(engine, range.start, &text[range.clone()], styles, dir, lang, region);
|
||||
items.push(Run { range, item: Item::Text(shaped), idx: *next_idx });
|
||||
*next_idx += 1;
|
||||
items.push(Run { range, item: Item::Text(shaped) });
|
||||
};
|
||||
|
||||
let mut prev_level = BidiLevel::ltr();
|
||||
|
Loading…
x
Reference in New Issue
Block a user