Skip to content

Commit ec1c995

Browse files
committed
fix
1 parent b58e2a3 commit ec1c995

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Diff for: src/parser/converts/block.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,15 @@ export function convertIfBlock(
9696
return ifBlock;
9797
}
9898

99-
const elseStart = startBlockIndex(ctx.code, node.else.start - 1, ":else");
99+
let baseStart = node.else.start;
100+
if (node.else.children.length === 1) {
101+
const c = node.else.children[0];
102+
if (c.type === "IfBlock" && c.elseif) {
103+
baseStart = Math.min(baseStart, c.start, getWithLoc(c.expression).start);
104+
}
105+
}
106+
107+
const elseStart = startBlockIndex(ctx.code, baseStart - 1, ":else");
100108

101109
if (node.else.children.length === 1) {
102110
const c = node.else.children[0];

Diff for: tests/fixtures/parser/ast/if-block01-requirements.json

-6
This file was deleted.

0 commit comments

Comments
 (0)