Skip to content

Commit 7437e3b

Browse files
authored
fix(language-core): transform range of file-md correctly (#4735)
1 parent 38c1e48 commit 7437e3b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

packages/language-core/lib/plugins/file-md.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,17 @@ const plugin: VueLanguagePlugin = ({ vueCompilerOptions }) => {
8888
return sfc;
8989

9090
function transformRange(block: SFCBlock) {
91-
block.loc.start.offset = -1;
92-
block.loc.end.offset = -1;
93-
for (const [start] of file2VueSourceMap.toSourceLocation(block.loc.start.offset)) {
94-
block.loc.start.offset = start;
91+
const { start, end } = block.loc;
92+
const startOffset = start.offset;
93+
const endOffset = end.offset;
94+
start.offset = -1;
95+
end.offset = -1;
96+
for (const [offset] of file2VueSourceMap.toSourceLocation(startOffset)) {
97+
start.offset = offset;
9598
break;
9699
}
97-
for (const [end] of file2VueSourceMap.toSourceLocation(block.loc.end.offset)) {
98-
block.loc.end.offset = end;
100+
for (const [offset] of file2VueSourceMap.toSourceLocation(endOffset)) {
101+
end.offset = offset;
99102
break;
100103
}
101104
}

0 commit comments

Comments
 (0)