diff --git a/packages/vscode/language-server/languagePlugin.ts b/packages/vscode/language-server/languagePlugin.ts index 5144c64ec8..09bfdc6b6a 100644 --- a/packages/vscode/language-server/languagePlugin.ts +++ b/packages/vscode/language-server/languagePlugin.ts @@ -30,9 +30,7 @@ function* getEmbeddedCodes(parsed: SlidevMarkdown): Generator { const lines = parsed.raw.split('\n') function lineToPos(line: number) { let pos = 0 - for (let i = 0; i <= line; i++) { - if (!lines[i]) - break + for (let i = 0; i <= line && i < lines.length; i++) { pos += lines[i].length + 1 } return pos