Skip to content

Commit

Permalink
fix(language-core): transform range of file-md correctly (#4735)
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX authored Aug 28, 2024
1 parent 38c1e48 commit 7437e3b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/language-core/lib/plugins/file-md.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,17 @@ const plugin: VueLanguagePlugin = ({ vueCompilerOptions }) => {
return sfc;

function transformRange(block: SFCBlock) {
block.loc.start.offset = -1;
block.loc.end.offset = -1;
for (const [start] of file2VueSourceMap.toSourceLocation(block.loc.start.offset)) {
block.loc.start.offset = start;
const { start, end } = block.loc;
const startOffset = start.offset;
const endOffset = end.offset;
start.offset = -1;
end.offset = -1;
for (const [offset] of file2VueSourceMap.toSourceLocation(startOffset)) {
start.offset = offset;
break;
}
for (const [end] of file2VueSourceMap.toSourceLocation(block.loc.end.offset)) {
block.loc.end.offset = end;
for (const [offset] of file2VueSourceMap.toSourceLocation(endOffset)) {
end.offset = offset;
break;
}
}
Expand Down

0 comments on commit 7437e3b

Please sign in to comment.