diff --git a/crates/djls-template-ast/src/parser.rs b/crates/djls-template-ast/src/parser.rs index 70a30ef..ae82676 100644 --- a/crates/djls-template-ast/src/parser.rs +++ b/crates/djls-template-ast/src/parser.rs @@ -20,11 +20,11 @@ impl Parser { // First pass: collect line offsets for token in self.tokens.tokens() { - if token.line() > last_line { + if *token.line() > last_line { if let Some(start) = token.start() { line_offsets.add_line(*start as u32); } - last_line = token.line(); + last_line = *token.line(); } } diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__comments__parse_comments.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__comments__parse_comments.snap index 34109ef..ba19092 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__comments__parse_comments.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__comments__parse_comments.snap @@ -13,5 +13,7 @@ nodes: span: start: 21 length: 18 -line_offsets: [] +line_offsets: + - 0 + - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_complex_if_elif.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_complex_if_elif.snap index 11d6556..39f2f54 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_complex_if_elif.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_complex_if_elif.snap @@ -69,5 +69,7 @@ nodes: tag_span: start: 0 length: 8 -line_offsets: [] +line_offsets: + - 0 + - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_for_block.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_for_block.snap index 479f215..3141a63 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_for_block.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_for_block.snap @@ -52,5 +52,7 @@ nodes: tag_span: start: 0 length: 17 -line_offsets: [] +line_offsets: + - 0 + - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_if_block.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_if_block.snap index 3e60bd1..a890b84 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_if_block.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_if_block.snap @@ -32,5 +32,7 @@ nodes: tag_span: start: 0 length: 24 -line_offsets: [] +line_offsets: + - 0 + - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_variable.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_variable.snap index 2662026..d8ce616 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_variable.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_variable.snap @@ -16,5 +16,7 @@ nodes: span: start: 0 length: 15 -line_offsets: [] +line_offsets: + - 0 + - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_filter_chains.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_filter_chains.snap index 86f6776..d9d3d39 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_filter_chains.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_filter_chains.snap @@ -26,5 +26,7 @@ nodes: span: start: 0 length: 35 -line_offsets: [] +line_offsets: + - 0 + - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_mixed_content.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_mixed_content.snap index 18ceec3..409e30b 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_mixed_content.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_mixed_content.snap @@ -250,5 +250,19 @@ nodes: span: start: 359 length: 1 -line_offsets: [] +line_offsets: + - 0 + - 0 + - 39 + - 81 + - 116 + - 159 + - 184 + - 231 + - 273 + - 289 + - 309 + - 326 + - 337 + - 347 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_nested_for_if.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_nested_for_if.snap index 3542f4f..a47f8c1 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_nested_for_if.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_nested_for_if.snap @@ -61,5 +61,7 @@ nodes: tag_span: start: 0 length: 17 -line_offsets: [] +line_offsets: + - 0 + - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_error_recovery.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_error_recovery.snap index 720f40d..a94adae 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_error_recovery.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_error_recovery.snap @@ -107,6 +107,19 @@ nodes: tag_span: start: 48 length: 24 -line_offsets: [] +line_offsets: + - 0 + - 0 + - 23 + - 43 + - 78 + - 130 + - 169 + - 183 + - 243 + - 275 + - 311 + - 332 + - 365 errors: - UnclosedTag: if diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_for.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_for.snap index 12303b2..9935206 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_for.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_for.snap @@ -26,6 +26,8 @@ nodes: tag_span: start: 0 length: 17 -line_offsets: [] +line_offsets: + - 0 + - 0 errors: - UnclosedTag: for diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_if.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_if.snap index 62e48e3..92ef3e9 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_if.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_django_if.snap @@ -21,6 +21,8 @@ nodes: tag_span: start: 0 length: 24 -line_offsets: [] +line_offsets: + - 0 + - 0 errors: - UnclosedTag: if diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_html_tag.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_html_tag.snap index be8aa85..ab2ce91 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_html_tag.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_html_tag.snap @@ -8,5 +8,7 @@ nodes: span: start: 0 length: 5 -line_offsets: [] +line_offsets: + - 0 + - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_script.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_script.snap index 5d21c55..457c0f6 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_script.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_script.snap @@ -8,5 +8,7 @@ nodes: span: start: 0 length: 28 -line_offsets: [] +line_offsets: + - 0 + - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_style.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_style.snap index 31f4adb..2182fa0 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_style.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__errors__parse_unclosed_style.snap @@ -8,5 +8,7 @@ nodes: span: start: 0 length: 27 -line_offsets: [] +line_offsets: + - 0 + - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__full_templates__parse_full.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__full_templates__parse_full.snap index f71a1bb..da837d1 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__full_templates__parse_full.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__full_templates__parse_full.snap @@ -126,5 +126,36 @@ nodes: span: start: 799 length: 35 -line_offsets: [] +line_offsets: + - 0 + - 0 + - 15 + - 22 + - 33 + - 65 + - 96 + - 133 + - 150 + - 190 + - 214 + - 240 + - 269 + - 297 + - 312 + - 330 + - 342 + - 353 + - 385 + - 450 + - 493 + - 531 + - 604 + - 643 + - 682 + - 709 + - 747 + - 775 + - 799 + - 814 + - 826 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_doctype.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_doctype.snap index 061d265..4f12506 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_doctype.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_doctype.snap @@ -8,5 +8,7 @@ nodes: span: start: 0 length: 15 -line_offsets: [] +line_offsets: + - 0 + - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_tag.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_tag.snap index a189e9a..edad717 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_tag.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_tag.snap @@ -8,5 +8,7 @@ nodes: span: start: 0 length: 34 -line_offsets: [] +line_offsets: + - 0 + - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_void.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_void.snap index 01aa3f2..59b9455 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_void.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__html__parse_html_void.snap @@ -8,5 +8,7 @@ nodes: span: start: 0 length: 21 -line_offsets: [] +line_offsets: + - 0 + - 0 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__script__parse_script.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__script__parse_script.snap index 1e0a35f..5c5a85a 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__script__parse_script.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__script__parse_script.snap @@ -8,5 +8,13 @@ nodes: span: start: 0 length: 142 -line_offsets: [] +line_offsets: + - 0 + - 0 + - 31 + - 58 + - 75 + - 93 + - 112 + - 132 errors: [] diff --git a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__style__parse_style.snap b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__style__parse_style.snap index 6313af8..77f6c43 100644 --- a/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__style__parse_style.snap +++ b/crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__style__parse_style.snap @@ -8,5 +8,12 @@ nodes: span: start: 0 length: 97 -line_offsets: [] +line_offsets: + - 0 + - 0 + - 23 + - 47 + - 61 + - 82 + - 88 errors: []