diff --git a/server/src/deno.ts b/server/src/deno.ts index 257c678..cf1aeb7 100644 --- a/server/src/deno.ts +++ b/server/src/deno.ts @@ -150,8 +150,8 @@ class Deno { return denoModuleFilepath .replace(deno.DENO_DEPS_DIR, "") .replace(/^(\/|\\\\)/, "") - .replace(/http(\/|\\\\)/, "http://") - .replace(/https(\/|\\\\)/, "https://"); + .replace(/^http(\/|\\\\)/, "http://") + .replace(/^https(\/|\\\\)/, "https://"); } // get deno dependencies files public async getDependencies( @@ -163,14 +163,20 @@ class Deno { const promises = files.map(filename => { const filepath = path.join(rootDir, filename); return fs.stat(filepath).then(stat => { - if (stat.isDirectory()) { + const isInternalModule = + filename.startsWith("_") || filename.startsWith("."); + if (stat.isDirectory() && !isInternalModule) { return this.getDependencies(filepath, deps); - } else if (stat.isFile() && filepath.endsWith(".headers.json")) { + } else if ( + stat.isFile() && + filepath.endsWith(".headers.json") && + !isInternalModule + ) { const moduleFilepath = filepath.replace(/\.headers\.json$/, ""); deps.push({ url: this.filepath2url(moduleFilepath), - filepath: filepath + filepath: moduleFilepath }); } }); diff --git a/server/src/server.ts b/server/src/server.ts index 2cc1726..0d4a854 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -152,7 +152,7 @@ connection.onCompletion(async params => { const IMPORT_REG = /import\s['"][a-zA-Z\._-]$/; const IMPORT_FROM_REG = /import\s(([^\s]*)|(\*\sas\s[^\s]*))\sfrom\s['"][a-zA-Z\._-]$/; - const DYNAMIC_REG = /import\s*\(['"][a-zA-Z\._-]$/; + const DYNAMIC_REG = /import\s*\(['"][a-zA-Z\._-]['"]?$/; const isImport = IMPORT_REG.test(currentLine) || // import "https://xxxx.xxxx" @@ -169,7 +169,7 @@ connection.onCompletion(async params => { const deps = await deno.getDependencies(); const range = Range.create( - Position.create(position.line, position.character - 5), + Position.create(position.line, position.character), position );