mirror of
https://github.com/helix-editor/tree-house.git
synced 2025-10-06 00:12:46 +02:00
highlighter: Eagerly panic when highlight ranges are out of order
The errors were collected into the string but `errors` was never read. Instead of collecting errors I think it's better for the sake of debugging to panic eagerly.
This commit is contained in:
@@ -206,26 +206,23 @@ pub fn highlighter_fixture(
|
||||
wln!(res, "{ident}{line}")
|
||||
}
|
||||
}
|
||||
let mut errors = String::new();
|
||||
while pos < end as u32 {
|
||||
let (event, new_highlights) = highlighter.advance();
|
||||
if event == HighlightEvent::Refresh {
|
||||
highlight_stack.clear();
|
||||
}
|
||||
highlight_stack.extend(new_highlights.map(&get_highlight_name));
|
||||
let mut start = pos;
|
||||
let start = pos;
|
||||
pos = highlighter.next_event_offset();
|
||||
if pos == u32::MAX {
|
||||
pos = src.len_bytes() as u32
|
||||
}
|
||||
if pos <= start {
|
||||
wln!(
|
||||
errors,
|
||||
"INVALID HIGHLIGHT RANGE: {start}..{pos} {:?} {:?}",
|
||||
panic!(
|
||||
"INVALID HIGHLIGHT RANGE: {start}..{pos} '{}' {:?}",
|
||||
src.byte_slice(pos as usize..start as usize),
|
||||
highlight_stack
|
||||
);
|
||||
start = pos;
|
||||
}
|
||||
|
||||
while start >= line_end {
|
||||
|
Reference in New Issue
Block a user