🎨 excerpt_list::Chunks::next
This commit is contained in:
parent
416033a01c
commit
09c0c3a0e7
1 changed files with 43 additions and 44 deletions
|
@ -356,6 +356,7 @@ impl<'a> Iterator for Chunks<'a> {
|
||||||
type Item = Chunk<'a>;
|
type Item = Chunk<'a>;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
loop {
|
||||||
if self.header_height > 0 {
|
if self.header_height > 0 {
|
||||||
let chunk = Chunk {
|
let chunk = Chunk {
|
||||||
text: unsafe {
|
text: unsafe {
|
||||||
|
@ -370,19 +371,18 @@ impl<'a> Iterator for Chunks<'a> {
|
||||||
if let Some(entry_chunks) = self.entry_chunks.as_mut() {
|
if let Some(entry_chunks) = self.entry_chunks.as_mut() {
|
||||||
if let Some(chunk) = entry_chunks.next() {
|
if let Some(chunk) = entry_chunks.next() {
|
||||||
return Some(chunk);
|
return Some(chunk);
|
||||||
} else if self.range.end >= self.cursor.end(&()) {
|
}
|
||||||
self.entry_chunks.take();
|
self.entry_chunks.take();
|
||||||
|
if self.cursor.end(&()) <= self.range.end {
|
||||||
return Some(Chunk {
|
return Some(Chunk {
|
||||||
text: "\n",
|
text: "\n",
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
return None;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.cursor.next(&());
|
self.cursor.next(&());
|
||||||
if *self.cursor.start() == self.range.end {
|
if *self.cursor.start() >= self.range.end {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,8 +402,7 @@ impl<'a> Iterator for Chunks<'a> {
|
||||||
.buffer
|
.buffer
|
||||||
.chunks(buffer_range.start..buffer_end, self.theme),
|
.chunks(buffer_range.start..buffer_end, self.theme),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
self.next()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue