Skip to content

Commit 5aa78d0

Browse files
committed
feat: Improve relative file path handling in filesAutoImport
1 parent 9f532d3 commit 5aa78d0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

typescript/src/completions/filesAutoImport.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ export default () => {
6060
const files = collected.filter(f => f.endsWith(ext))
6161
for (const file of files) {
6262
const fullPath = nodeModules.path.join(root, file)
63-
const relativeToFile = nodeModules.path.relative(nodeModules.path.dirname(sourceFile.fileName), fullPath).replaceAll('\\', '/')
63+
let relativeToFile = nodeModules.path.relative(nodeModules.path.dirname(sourceFile.fileName), fullPath).replaceAll('\\', '/')
64+
if (!relativeToFile.startsWith('.')) relativeToFile = `./${relativeToFile}`
6465
const lastModified = nodeModules.fs.statSync(fullPath).mtime
6566
const lastModifiedFormatted = timeDifference(Date.now(), lastModified.getTime())
6667
const importPath = (item.importPath ?? '$path').replaceAll('$path', relativeToFile)

0 commit comments

Comments
 (0)