Skip to content

Commit 7c4f4c3

Browse files
committed
fix: indented statement parsing
1 parent 5d8dccb commit 7c4f4c3

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

.changeset/polite-cougars-read.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"htmljs-parser": patch
3+
---
4+
5+
Fix regression caused by indented statement parsing.

src/__tests__/fixtures/commas-relax/__snapshots__/commas-relax.expected.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,15 @@
1313
8├─ Link,
1414
9├─ BaseInput {
1515
10├─ reviewCount: number;
16-
11╭─ }
17-
╰─ ╰─ openTagEnd
16+
11├─ }
17+
12╭─
18+
╰─ ╰─ openTagEnd
19+
13╭─ export interface Input {
20+
╰─ ╰─ tagName "export"
21+
14├─ foo: string;
22+
15├─ }
23+
16╭─ $ const bar = "bar"
24+
│ ││╰─ scriptlet.value "const bar = \"bar\""
25+
│ │╰─ scriptlet " const bar = \"bar\""
26+
╰─ ╰─ openTagEnd
27+
17╰─

src/__tests__/fixtures/commas-relax/input.marko

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@ export interface Input
88
Link,
99
BaseInput {
1010
reviewCount: number;
11-
}
11+
}
12+
13+
export interface Input {
14+
foo: string;
15+
}
16+
$ const bar = "bar"

src/states/EXPRESSION.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export const EXPRESSION: StateDefinition<ExpressionMeta> = {
173173
(expression.wasComment || !checkForOperators(this, expression, true)) &&
174174
!(
175175
expression.consumeIndentedContent &&
176-
isIndentCode(this.lookAtCharCodeAhead(len + 1))
176+
isIndentCode(this.lookAtCharCodeAhead(len))
177177
)
178178
) {
179179
this.exitState();

0 commit comments

Comments
 (0)