Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/tt/src/buffer.rs')
| -rw-r--r-- | crates/tt/src/buffer.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/crates/tt/src/buffer.rs b/crates/tt/src/buffer.rs index c4b455e3f1..0615a3763d 100644 --- a/crates/tt/src/buffer.rs +++ b/crates/tt/src/buffer.rs @@ -7,7 +7,12 @@ use crate::{Leaf, Subtree, TokenTree}; struct EntryId(usize); #[derive(Copy, Clone, Debug, Eq, PartialEq)] -struct EntryPtr(EntryId, usize); +struct EntryPtr( + /// The index of the buffer containing the entry. + EntryId, + /// The index of the entry within the buffer. + usize, +); /// Internal type which is used instead of `TokenTree` to represent a token tree /// within a `TokenBuffer`. @@ -229,7 +234,11 @@ impl<'a, Span> Cursor<'a, Span> { Some(&Entry::Subtree(_, _, entry_id)) => { Cursor::create(self.buffer, EntryPtr(entry_id, 0)) } - _ => self.bump(), + Some(Entry::End(exit)) => match exit { + Some(exit) => Cursor::create(self.buffer, *exit), + None => self, + }, + _ => Cursor::create(self.buffer, EntryPtr(self.ptr.0, self.ptr.1 + 1)), } } |