highlight: don't include scope in ScopeEnd events
When there are embedded documents, multiple scopes can start or end at the same position. Previously, there was no guarantee that the ScopeEnd events would always occur in the reverse order of the ScopeStart events. The easiest way to avoid exposing inconsistency is to not surface the scopes being ended.
This commit is contained in:
parent
d2264d597f
commit
e239aa8229
3 changed files with 17 additions and 12 deletions
|
|
@ -209,7 +209,7 @@ pub fn ansi(
|
|||
HighlightEvent::ScopeStart(s) => {
|
||||
scope_stack.push(s);
|
||||
}
|
||||
HighlightEvent::ScopeEnd(_) => {
|
||||
HighlightEvent::ScopeEnd => {
|
||||
scope_stack.pop();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,8 +162,7 @@ fn to_token_vector<'a>(
|
|||
)? {
|
||||
match event {
|
||||
HighlightEvent::ScopeStart(s) => scopes.push(s),
|
||||
HighlightEvent::ScopeEnd(s) => {
|
||||
assert_eq!(*scopes.last().unwrap(), s);
|
||||
HighlightEvent::ScopeEnd => {
|
||||
scopes.pop();
|
||||
}
|
||||
HighlightEvent::Source(s) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue