Introduce custom fold placeholders (#12214)

This pull request replaces the static `⋯` character we used to insert
when folding a range with a custom render function that return an
`AnyElement`. We plan to use this in the assistant, but for now this
should be behavior-preserving.

Release Notes:

- N/A

---------

Co-authored-by: Nathan <nathan@zed.dev>
Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
Antonio Scandurra
2024-05-23 15:22:30 -06:00
committed by GitHub
co-authored by Nathan Conrad
parent e0cfba43aa
commit 57d570c281
19 changed files with 774 additions and 437 deletions
+1 -1
View File
@@ -875,7 +875,7 @@ impl<'a> Iterator for BlockChunks<'a> {
Some(Chunk {
text: prefix,
..self.input_chunk
..self.input_chunk.clone()
})
}
}
@@ -6,6 +6,8 @@ use sum_tree::{Bias, SeekTarget, SumTree};
use text::Point;
use ui::WindowContext;
use crate::FoldPlaceholder;
#[derive(Copy, Clone, Default, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)]
pub struct FlapId(usize);
@@ -76,6 +78,7 @@ type RenderTrailerFn =
#[derive(Clone)]
pub struct Flap {
pub range: Range<Anchor>,
pub placeholder: FoldPlaceholder,
pub render_toggle: RenderToggleFn,
pub render_trailer: RenderTrailerFn,
}
@@ -83,6 +86,7 @@ pub struct Flap {
impl Flap {
pub fn new<RenderToggle, ToggleElement, RenderTrailer, TrailerElement>(
range: Range<Anchor>,
placeholder: FoldPlaceholder,
render_toggle: RenderToggle,
render_trailer: RenderTrailer,
) -> Self
@@ -107,6 +111,7 @@ impl Flap {
{
Flap {
range,
placeholder,
render_toggle: Arc::new(move |row, folded, toggle, cx| {
render_toggle(row, folded, toggle, cx).into_any_element()
}),
@@ -256,11 +261,13 @@ mod test {
let flaps = [
Flap::new(
snapshot.anchor_before(Point::new(1, 0))..snapshot.anchor_after(Point::new(1, 5)),
FoldPlaceholder::test(),
|_row, _folded, _toggle, _cx| div(),
|_row, _folded, _cx| div(),
),
Flap::new(
snapshot.anchor_before(Point::new(3, 0))..snapshot.anchor_after(Point::new(3, 5)),
FoldPlaceholder::test(),
|_row, _folded, _toggle, _cx| div(),
|_row, _folded, _cx| div(),
),
+129 -85
View File
@@ -2,17 +2,54 @@ use super::{
inlay_map::{InlayBufferRows, InlayChunks, InlayEdit, InlayOffset, InlayPoint, InlaySnapshot},
Highlights,
};
use gpui::{ElementId, HighlightStyle, Hsla};
use language::{Chunk, Edit, Point, TextSummary};
use gpui::{AnyElement, ElementId, WindowContext};
use language::{Chunk, ChunkRenderer, Edit, Point, TextSummary};
use multi_buffer::{Anchor, AnchorRangeExt, MultiBufferRow, MultiBufferSnapshot, ToOffset};
use std::{
cmp::{self, Ordering},
iter,
fmt, iter,
ops::{Add, AddAssign, Deref, DerefMut, Range, Sub},
sync::Arc,
};
use sum_tree::{Bias, Cursor, FilterCursor, SumTree};
use util::post_inc;
#[derive(Clone)]
pub struct FoldPlaceholder {
/// Creates an element to represent this fold's placeholder.
pub render: Arc<dyn Send + Sync + Fn(FoldId, Range<Anchor>, &mut WindowContext) -> AnyElement>,
/// If true, the element is constrained to the shaped width of an ellipsis.
pub constrain_width: bool,
}
impl FoldPlaceholder {
#[cfg(any(test, feature = "test-support"))]
pub fn test() -> Self {
use gpui::IntoElement;
Self {
render: Arc::new(|_id, _range, _cx| gpui::Empty.into_any_element()),
constrain_width: true,
}
}
}
impl fmt::Debug for FoldPlaceholder {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("FoldPlaceholder")
.field("constrain_width", &self.constrain_width)
.finish()
}
}
impl Eq for FoldPlaceholder {}
impl PartialEq for FoldPlaceholder {
fn eq(&self, other: &Self) -> bool {
Arc::ptr_eq(&self.render, &other.render) && self.constrain_width == other.constrain_width
}
}
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
pub struct FoldPoint(pub Point);
@@ -54,7 +91,7 @@ impl FoldPoint {
let mut offset = cursor.start().1.output.len;
if !overshoot.is_zero() {
let transform = cursor.item().expect("display point out of range");
assert!(transform.output_text.is_none());
assert!(transform.placeholder.is_none());
let end_inlay_offset = snapshot
.inlay_snapshot
.to_offset(InlayPoint(cursor.start().1.input.lines + overshoot));
@@ -75,7 +112,7 @@ pub(crate) struct FoldMapWriter<'a>(&'a mut FoldMap);
impl<'a> FoldMapWriter<'a> {
pub(crate) fn fold<T: ToOffset>(
&mut self,
ranges: impl IntoIterator<Item = (Range<T>, &'static str)>,
ranges: impl IntoIterator<Item = (Range<T>, FoldPlaceholder)>,
) -> (FoldSnapshot, Vec<FoldEdit>) {
let mut edits = Vec::new();
let mut folds = Vec::new();
@@ -99,7 +136,7 @@ impl<'a> FoldMapWriter<'a> {
folds.push(Fold {
id: FoldId(post_inc(&mut self.0.next_fold_id.0)),
range: fold_range,
text: fold_text,
placeholder: fold_text,
});
let inlay_range =
@@ -183,7 +220,6 @@ impl<'a> FoldMapWriter<'a> {
/// See the [`display_map` module documentation](crate::display_map) for more information.
pub(crate) struct FoldMap {
snapshot: FoldSnapshot,
ellipses_color: Option<Hsla>,
next_fold_id: FoldId,
}
@@ -198,15 +234,13 @@ impl FoldMap {
input: inlay_snapshot.text_summary(),
output: inlay_snapshot.text_summary(),
},
output_text: None,
placeholder: None,
},
&(),
),
inlay_snapshot: inlay_snapshot.clone(),
version: 0,
ellipses_color: None,
},
ellipses_color: None,
next_fold_id: FoldId::default(),
};
let snapshot = this.snapshot.clone();
@@ -232,15 +266,6 @@ impl FoldMap {
(FoldMapWriter(self), snapshot, edits)
}
pub fn set_ellipses_color(&mut self, color: Hsla) -> bool {
if self.ellipses_color == Some(color) {
false
} else {
self.ellipses_color = Some(color);
true
}
}
fn check_invariants(&self) {
if cfg!(test) {
assert_eq!(
@@ -329,9 +354,9 @@ impl FoldMap {
let buffer_start = fold.range.start.to_offset(&inlay_snapshot.buffer);
let buffer_end = fold.range.end.to_offset(&inlay_snapshot.buffer);
(
fold.clone(),
inlay_snapshot.to_inlay_offset(buffer_start)
..inlay_snapshot.to_inlay_offset(buffer_end),
fold.text,
)
});
folds_cursor.next(&inlay_snapshot.buffer);
@@ -342,17 +367,17 @@ impl FoldMap {
while folds
.peek()
.map_or(false, |(fold_range, _)| fold_range.start < edit.new.end)
.map_or(false, |(_, fold_range)| fold_range.start < edit.new.end)
{
let (mut fold_range, fold_text) = folds.next().unwrap();
let (fold, mut fold_range) = folds.next().unwrap();
let sum = new_transforms.summary();
assert!(fold_range.start.0 >= sum.input.len);
while folds.peek().map_or(false, |(next_fold_range, _)| {
while folds.peek().map_or(false, |(_, next_fold_range)| {
next_fold_range.start <= fold_range.end
}) {
let (next_fold_range, _) = folds.next().unwrap();
let (_, next_fold_range) = folds.next().unwrap();
if next_fold_range.end > fold_range.end {
fold_range.end = next_fold_range.end;
}
@@ -367,21 +392,36 @@ impl FoldMap {
output: text_summary.clone(),
input: text_summary,
},
output_text: None,
placeholder: None,
},
&(),
);
}
if fold_range.end > fold_range.start {
const ELLIPSIS: &'static str = "⋯";
let fold_id = fold.id;
new_transforms.push(
Transform {
summary: TransformSummary {
output: TextSummary::from(fold_text),
output: TextSummary::from(ELLIPSIS),
input: inlay_snapshot
.text_summary_for_range(fold_range.start..fold_range.end),
},
output_text: Some(fold_text),
placeholder: Some(TransformPlaceholder {
text: ELLIPSIS,
renderer: ChunkRenderer {
render: Arc::new(move |cx| {
(fold.placeholder.render)(
fold_id,
fold.range.0.clone(),
cx,
)
}),
constrain_width: fold.placeholder.constrain_width,
},
}),
},
&(),
);
@@ -398,7 +438,7 @@ impl FoldMap {
output: text_summary.clone(),
input: text_summary,
},
output_text: None,
placeholder: None,
},
&(),
);
@@ -414,7 +454,7 @@ impl FoldMap {
output: text_summary.clone(),
input: text_summary,
},
output_text: None,
placeholder: None,
},
&(),
);
@@ -484,7 +524,6 @@ pub struct FoldSnapshot {
folds: SumTree<Fold>,
pub inlay_snapshot: InlaySnapshot,
pub version: usize,
pub ellipses_color: Option<Hsla>,
}
impl FoldSnapshot {
@@ -508,9 +547,9 @@ impl FoldSnapshot {
if let Some(transform) = cursor.item() {
let start_in_transform = range.start.0 - cursor.start().0 .0;
let end_in_transform = cmp::min(range.end, cursor.end(&()).0).0 - cursor.start().0 .0;
if let Some(output_text) = transform.output_text {
if let Some(placeholder) = transform.placeholder.as_ref() {
summary = TextSummary::from(
&output_text
&placeholder.text
[start_in_transform.column as usize..end_in_transform.column as usize],
);
} else {
@@ -533,8 +572,9 @@ impl FoldSnapshot {
.output;
if let Some(transform) = cursor.item() {
let end_in_transform = range.end.0 - cursor.start().0 .0;
if let Some(output_text) = transform.output_text {
summary += TextSummary::from(&output_text[..end_in_transform.column as usize]);
if let Some(placeholder) = transform.placeholder.as_ref() {
summary +=
TextSummary::from(&placeholder.text[..end_in_transform.column as usize]);
} else {
let inlay_start = self.inlay_snapshot.to_offset(cursor.start().1);
let inlay_end = self
@@ -631,7 +671,7 @@ impl FoldSnapshot {
let inlay_offset = self.inlay_snapshot.to_inlay_offset(buffer_offset);
let mut cursor = self.transforms.cursor::<InlayOffset>();
cursor.seek(&inlay_offset, Bias::Right, &());
cursor.item().map_or(false, |t| t.output_text.is_some())
cursor.item().map_or(false, |t| t.placeholder.is_some())
}
pub fn is_line_folded(&self, buffer_row: MultiBufferRow) -> bool {
@@ -646,7 +686,7 @@ impl FoldSnapshot {
let buffer_point = self.inlay_snapshot.to_buffer_point(inlay_point);
if buffer_point.row != buffer_row.0 {
return false;
} else if transform.output_text.is_some() {
} else if transform.placeholder.is_some() {
return true;
}
}
@@ -693,7 +733,6 @@ impl FoldSnapshot {
inlay_offset: inlay_start,
output_offset: range.start.0,
max_output_offset: range.end.0,
ellipses_color: self.ellipses_color,
}
}
@@ -720,7 +759,7 @@ impl FoldSnapshot {
cursor.seek(&point, Bias::Right, &());
if let Some(transform) = cursor.item() {
let transform_start = cursor.start().0 .0;
if transform.output_text.is_some() {
if transform.placeholder.is_some() {
if point.0 == transform_start || matches!(bias, Bias::Left) {
FoldPoint(transform_start)
} else {
@@ -810,15 +849,21 @@ fn consolidate_fold_edits(edits: &mut Vec<FoldEdit>) {
}
}
#[derive(Clone, Debug, Default, Eq, PartialEq)]
#[derive(Clone, Debug, Default)]
struct Transform {
summary: TransformSummary,
output_text: Option<&'static str>,
placeholder: Option<TransformPlaceholder>,
}
#[derive(Clone, Debug)]
struct TransformPlaceholder {
text: &'static str,
renderer: ChunkRenderer,
}
impl Transform {
fn is_fold(&self) -> bool {
self.output_text.is_some()
self.placeholder.is_some()
}
}
@@ -858,7 +903,7 @@ impl Into<ElementId> for FoldId {
pub struct Fold {
pub id: FoldId,
pub range: FoldRange,
pub text: &'static str,
pub placeholder: FoldPlaceholder,
}
#[derive(Clone, Debug, Eq, PartialEq)]
@@ -1004,7 +1049,6 @@ pub struct FoldChunks<'a> {
inlay_offset: InlayOffset,
output_offset: usize,
max_output_offset: usize,
ellipses_color: Option<Hsla>,
}
impl<'a> Iterator for FoldChunks<'a> {
@@ -1019,7 +1063,7 @@ impl<'a> Iterator for FoldChunks<'a> {
// If we're in a fold, then return the fold's display text and
// advance the transform and buffer cursors to the end of the fold.
if let Some(output_text) = transform.output_text {
if let Some(placeholder) = transform.placeholder.as_ref() {
self.inlay_chunk.take();
self.inlay_offset += InlayOffset(transform.summary.input.len);
self.inlay_chunks.seek(self.inlay_offset);
@@ -1030,13 +1074,10 @@ impl<'a> Iterator for FoldChunks<'a> {
self.transform_cursor.next(&());
}
self.output_offset += output_text.len();
self.output_offset += placeholder.text.len();
return Some(Chunk {
text: output_text,
highlight_style: self.ellipses_color.map(|color| HighlightStyle {
color: Some(color),
..Default::default()
}),
text: placeholder.text,
renderer: Some(placeholder.renderer.clone()),
..Default::default()
});
}
@@ -1048,7 +1089,7 @@ impl<'a> Iterator for FoldChunks<'a> {
}
// Otherwise, take a chunk from the buffer's text.
if let Some((buffer_chunk_start, mut chunk)) = self.inlay_chunk {
if let Some((buffer_chunk_start, mut chunk)) = self.inlay_chunk.clone() {
let buffer_chunk_end = buffer_chunk_start + InlayOffset(chunk.text.len());
let transform_end = self.transform_cursor.end(&()).1;
let chunk_end = buffer_chunk_end.min(transform_end);
@@ -1165,8 +1206,8 @@ mod tests {
let (mut writer, _, _) = map.write(inlay_snapshot, vec![]);
let (snapshot2, edits) = writer.fold(vec![
(Point::new(0, 2)..Point::new(2, 2), "⋯"),
(Point::new(2, 4)..Point::new(4, 1), "⋯"),
(Point::new(0, 2)..Point::new(2, 2), FoldPlaceholder::test()),
(Point::new(2, 4)..Point::new(4, 1), FoldPlaceholder::test()),
]);
assert_eq!(snapshot2.text(), "aa⋯cc⋯eeeee");
assert_eq!(
@@ -1245,19 +1286,25 @@ mod tests {
let mut map = FoldMap::new(inlay_snapshot.clone()).0;
let (mut writer, _, _) = map.write(inlay_snapshot.clone(), vec![]);
writer.fold(vec![(5..8, "⋯")]);
writer.fold(vec![(5..8, FoldPlaceholder::test())]);
let (snapshot, _) = map.read(inlay_snapshot.clone(), vec![]);
assert_eq!(snapshot.text(), "abcde⋯ijkl");
// Create an fold adjacent to the start of the first fold.
let (mut writer, _, _) = map.write(inlay_snapshot.clone(), vec![]);
writer.fold(vec![(0..1, "⋯"), (2..5, "⋯")]);
writer.fold(vec![
(0..1, FoldPlaceholder::test()),
(2..5, FoldPlaceholder::test()),
]);
let (snapshot, _) = map.read(inlay_snapshot.clone(), vec![]);
assert_eq!(snapshot.text(), "⋯b⋯ijkl");
// Create an fold adjacent to the end of the first fold.
let (mut writer, _, _) = map.write(inlay_snapshot.clone(), vec![]);
writer.fold(vec![(11..11, "⋯"), (8..10, "⋯")]);
writer.fold(vec![
(11..11, FoldPlaceholder::test()),
(8..10, FoldPlaceholder::test()),
]);
let (snapshot, _) = map.read(inlay_snapshot.clone(), vec![]);
assert_eq!(snapshot.text(), "⋯b⋯kl");
}
@@ -1267,7 +1314,10 @@ mod tests {
// Create two adjacent folds.
let (mut writer, _, _) = map.write(inlay_snapshot.clone(), vec![]);
writer.fold(vec![(0..2, "⋯"), (2..5, "⋯")]);
writer.fold(vec![
(0..2, FoldPlaceholder::test()),
(2..5, FoldPlaceholder::test()),
]);
let (snapshot, _) = map.read(inlay_snapshot, vec![]);
assert_eq!(snapshot.text(), "⋯fghijkl");
@@ -1291,10 +1341,10 @@ mod tests {
let mut map = FoldMap::new(inlay_snapshot.clone()).0;
let (mut writer, _, _) = map.write(inlay_snapshot.clone(), vec![]);
writer.fold(vec![
(Point::new(0, 2)..Point::new(2, 2), "⋯"),
(Point::new(0, 4)..Point::new(1, 0), "⋯"),
(Point::new(1, 2)..Point::new(3, 2), "⋯"),
(Point::new(3, 1)..Point::new(4, 1), "⋯"),
(Point::new(0, 2)..Point::new(2, 2), FoldPlaceholder::test()),
(Point::new(0, 4)..Point::new(1, 0), FoldPlaceholder::test()),
(Point::new(1, 2)..Point::new(3, 2), FoldPlaceholder::test()),
(Point::new(3, 1)..Point::new(4, 1), FoldPlaceholder::test()),
]);
let (snapshot, _) = map.read(inlay_snapshot, vec![]);
assert_eq!(snapshot.text(), "aa⋯eeeee");
@@ -1311,8 +1361,8 @@ mod tests {
let (mut writer, _, _) = map.write(inlay_snapshot.clone(), vec![]);
writer.fold(vec![
(Point::new(0, 2)..Point::new(2, 2), "⋯"),
(Point::new(3, 1)..Point::new(4, 1), "⋯"),
(Point::new(0, 2)..Point::new(2, 2), FoldPlaceholder::test()),
(Point::new(3, 1)..Point::new(4, 1), FoldPlaceholder::test()),
]);
let (snapshot, _) = map.read(inlay_snapshot.clone(), vec![]);
assert_eq!(snapshot.text(), "aa⋯cccc\nd⋯eeeee");
@@ -1336,10 +1386,10 @@ mod tests {
let (mut writer, _, _) = map.write(inlay_snapshot.clone(), vec![]);
writer.fold(vec![
(Point::new(0, 2)..Point::new(2, 2), "⋯"),
(Point::new(0, 4)..Point::new(1, 0), "⋯"),
(Point::new(1, 2)..Point::new(3, 2), "⋯"),
(Point::new(3, 1)..Point::new(4, 1), "⋯"),
(Point::new(0, 2)..Point::new(2, 2), FoldPlaceholder::test()),
(Point::new(0, 4)..Point::new(1, 0), FoldPlaceholder::test()),
(Point::new(1, 2)..Point::new(3, 2), FoldPlaceholder::test()),
(Point::new(3, 1)..Point::new(4, 1), FoldPlaceholder::test()),
]);
let (snapshot, _) = map.read(inlay_snapshot.clone(), vec![]);
let fold_ranges = snapshot
@@ -1414,10 +1464,10 @@ mod tests {
snapshot_edits.push((snapshot.clone(), edits));
let mut expected_text: String = inlay_snapshot.text().to_string();
for (fold_range, fold_text) in map.merged_folds().into_iter().rev() {
for fold_range in map.merged_folds().into_iter().rev() {
let fold_inlay_start = inlay_snapshot.to_inlay_offset(fold_range.start);
let fold_inlay_end = inlay_snapshot.to_inlay_offset(fold_range.end);
expected_text.replace_range(fold_inlay_start.0..fold_inlay_end.0, fold_text);
expected_text.replace_range(fold_inlay_start.0..fold_inlay_end.0, "⋯");
}
assert_eq!(snapshot.text(), expected_text);
@@ -1429,7 +1479,7 @@ mod tests {
let mut prev_row = 0;
let mut expected_buffer_rows = Vec::new();
for (fold_range, _fold_text) in map.merged_folds().into_iter() {
for fold_range in map.merged_folds() {
let fold_start = inlay_snapshot
.to_point(inlay_snapshot.to_inlay_offset(fold_range.start))
.row();
@@ -1543,7 +1593,7 @@ mod tests {
let folded_buffer_rows = map
.merged_folds()
.iter()
.flat_map(|(fold_range, _)| {
.flat_map(|fold_range| {
let start_row = fold_range.start.to_point(&buffer_snapshot).row;
let end = fold_range.end.to_point(&buffer_snapshot);
if end.column == 0 {
@@ -1640,8 +1690,8 @@ mod tests {
let (mut writer, _, _) = map.write(inlay_snapshot.clone(), vec![]);
writer.fold(vec![
(Point::new(0, 2)..Point::new(2, 2), "⋯"),
(Point::new(3, 1)..Point::new(4, 1), "⋯"),
(Point::new(0, 2)..Point::new(2, 2), FoldPlaceholder::test()),
(Point::new(3, 1)..Point::new(4, 1), FoldPlaceholder::test()),
]);
let (snapshot, _) = map.read(inlay_snapshot, vec![]);
@@ -1659,7 +1709,7 @@ mod tests {
}
impl FoldMap {
fn merged_folds(&self) -> Vec<(Range<usize>, &'static str)> {
fn merged_folds(&self) -> Vec<Range<usize>> {
let inlay_snapshot = self.snapshot.inlay_snapshot.clone();
let buffer = &inlay_snapshot.buffer;
let mut folds = self.snapshot.folds.items(buffer);
@@ -1667,17 +1717,12 @@ mod tests {
folds.sort_by(|a, b| a.range.cmp(&b.range, buffer));
let mut folds = folds
.iter()
.map(|fold| {
(
fold.range.start.to_offset(buffer)..fold.range.end.to_offset(buffer),
fold.text,
)
})
.map(|fold| fold.range.start.to_offset(buffer)..fold.range.end.to_offset(buffer))
.peekable();
let mut merged_folds = Vec::new();
while let Some((mut fold_range, fold_text)) = folds.next() {
while let Some((next_range, _)) = folds.peek() {
while let Some(mut fold_range) = folds.next() {
while let Some(next_range) = folds.peek() {
if fold_range.end >= next_range.start {
if next_range.end > fold_range.end {
fold_range.end = next_range.end;
@@ -1688,7 +1733,7 @@ mod tests {
}
}
if fold_range.end > fold_range.start {
merged_folds.push((fold_range, fold_text));
merged_folds.push(fold_range);
}
}
merged_folds
@@ -1723,8 +1768,7 @@ mod tests {
for _ in 0..rng.gen_range(1..=2) {
let end = buffer.clip_offset(rng.gen_range(0..=buffer.len()), Right);
let start = buffer.clip_offset(rng.gen_range(0..=end), Left);
let text = if rng.gen() { "⋯" } else { "" };
to_fold.push((start..end, text));
to_fold.push((start..end, FoldPlaceholder::test()));
}
log::info!("folding {:?}", to_fold);
let (mut writer, snapshot, edits) = self.write(inlay_snapshot, vec![]);
+1 -1
View File
@@ -284,7 +284,7 @@ impl<'a> Iterator for InlayChunks<'a> {
self.output_offset.0 += prefix.len();
let mut prefix = Chunk {
text: prefix,
..*chunk
..chunk.clone()
};
if !self.active_highlights.is_empty() {
let mut highlight_style = HighlightStyle::default();
+2 -2
View File
@@ -508,7 +508,7 @@ impl<'a> Iterator for TabChunks<'a> {
self.chunk.text = suffix;
return Some(Chunk {
text: prefix,
..self.chunk
..self.chunk.clone()
});
} else {
self.chunk.text = &self.chunk.text[1..];
@@ -529,7 +529,7 @@ impl<'a> Iterator for TabChunks<'a> {
return Some(Chunk {
text: &SPACES[..len as usize],
is_tab: true,
..self.chunk
..self.chunk.clone()
});
}
}
+2 -2
View File
@@ -812,7 +812,7 @@ impl<'a> Iterator for WrapChunks<'a> {
self.transforms.next(&());
return Some(Chunk {
text: &display_text[start_ix..end_ix],
..self.input_chunk
..self.input_chunk.clone()
});
}
@@ -842,7 +842,7 @@ impl<'a> Iterator for WrapChunks<'a> {
self.input_chunk.text = suffix;
Some(Chunk {
text: prefix,
..self.input_chunk
..self.input_chunk.clone()
})
}
}