Skip to content

Commit c909bd5

Browse files
committed
fix
1 parent f0c95ec commit c909bd5

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/parser/converts/block.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,12 @@ export function convertAwaitBlock(
437437
...ctx.getConvertLocation({
438438
start: thenStart,
439439
end: endIndexFromFragment(then, () => {
440-
return awaitBlock.pending?.range[1] ?? node.end;
440+
return (
441+
ctx.code.indexOf(
442+
"}",
443+
node.value ? getWithLoc(node.value).end : thenStart + 5,
444+
) + 1
445+
);
441446
}),
442447
}),
443448
};
@@ -518,13 +523,13 @@ export function convertAwaitBlock(
518523
(awaitBlock as SvelteAwaitBlockAwaitCatch).kind = "await-catch";
519524
}
520525
const catchStart =
521-
awaitBlock.pending || awaitBlock.then
526+
awaitBlock.then || awaitBlock.pending
522527
? startBlockIndex(
523528
ctx.code,
524529
node.error
525530
? getWithLoc(node.error).start
526531
: startIndexFromFragment(catchFragment, () => {
527-
return (awaitBlock.pending || awaitBlock.then).range[1];
532+
return (awaitBlock.then || awaitBlock.pending).range[1];
528533
}),
529534
":catch",
530535
)
@@ -538,7 +543,12 @@ export function convertAwaitBlock(
538543
...ctx.getConvertLocation({
539544
start: catchStart,
540545
end: endIndexFromFragment(catchFragment, () => {
541-
return (awaitBlock.pending || awaitBlock.then)?.range[1] ?? node.end;
546+
return (
547+
ctx.code.indexOf(
548+
"}",
549+
node.error ? getWithLoc(node.error).end : catchStart + 6,
550+
) + 1
551+
);
542552
}),
543553
}),
544554
} as SvelteAwaitCatchBlock;

tests/fixtures/parser/ast/await03-requirements.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)