diff options
author | Martin Fischer <martin@push-f.com> | 2023-08-17 16:12:51 +0200 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2023-08-19 13:41:55 +0200 |
commit | cb4e9cf7cfc1612c67f16bfabadbdf442cd380fe (patch) | |
tree | 5aa2bf7dccafe66d735f3609d446bfad083ab8a3 /tests/test_spans.rs | |
parent | c15895d44d17984386d3684e2aa85aca386ba3bf (diff) |
fix: fix lots of position off-by-ones
Previously the PosTrackingReader always mysteriously subtracted 1
from the current position ... this wasn't sound at all ... the machine
just happens to often call `Tokenizer::unread_char` ... but not always.
E.g. for proper comments it didn't which resulted in their offset and
spans being off-by-one, which is fixed by this commit (see test_spans.rs).
Diffstat (limited to 'tests/test_spans.rs')
-rw-r--r-- | tests/test_spans.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/tests/test_spans.rs b/tests/test_spans.rs index 970099a..a33c2b3 100644 --- a/tests/test_spans.rs +++ b/tests/test_spans.rs @@ -111,12 +111,11 @@ fn comment_proper_data_span() { let Token::Comment(comment) = tokenizer(html).next().unwrap() else { panic!("expected comment"); }; - // FIXME: this span is wrong (starts one byte too soon) - assert_eq!(comment.data, html[1..][comment.data_span()]); + assert_eq!(comment.data, html[comment.data_span()]); let labels = vec![(comment.data_span(), "")]; assert_snapshot!(annotate(html, labels), @r###" <!-- Why are you looking at the source code? --> - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "###); } |