Skip to content

Commit

Permalink
feat: avoid auto import added in script block first line
Browse files Browse the repository at this point in the history
close #916
  • Loading branch information
johnsoncodehk committed Feb 12, 2022
1 parent 3dcdb27 commit fdc533f
Showing 1 changed file with 15 additions and 0 deletions.
Expand Up @@ -45,6 +45,21 @@ export function register({ modules: { typescript: ts }, sourceFiles, getTsLs, vu
}
}
data.tsItem = await getTsLs(sourceMap.lsType).doCompletionResolve(data.tsItem, newPosition_2);

// fix https://github.com/johnsoncodehk/volar/issues/916
if (data.tsItem.additionalTextEdits) {
for (const edit of data.tsItem.additionalTextEdits) {
if (
edit.range.start.line === 0
&& edit.range.start.character === 0
&& edit.range.end.line === 0
&& edit.range.end.character === 0
) {
edit.newText = (vueHost.getNewLine?.() ?? '\n') + edit.newText;
}
}
}

const newVueItem = transformCompletionItem(
data.tsItem,
tsRange => sourceMap.getSourceRange(tsRange.start, tsRange.end)?.[0],
Expand Down

0 comments on commit fdc533f

Please sign in to comment.