diff --git a/src/node/main.ts b/src/node/main.ts index 00b4bda1..cf589952 100644 --- a/src/node/main.ts +++ b/src/node/main.ts @@ -9,7 +9,7 @@ import { AuthType, DefaultedArgs, Feature, SpawnCodeCli, toCodeArgs, UserProvide import { coderCloudBind } from "./coder_cloud" import { commit, version } from "./constants" import { register } from "./routes" -import { humanPath, isFile, loadAMDModule, open } from "./util" +import { humanPath, isDirectory, loadAMDModule, open } from "./util" /** * Return true if the user passed an extension-related VS Code flag. @@ -69,14 +69,15 @@ export const openInExistingInstance = async (args: DefaultedArgs, socketPath: st fileURIs: [], forceReuseWindow: args["reuse-window"], forceNewWindow: args["new-window"], + gotoLineMode: true, } const paths = args._ || [] for (let i = 0; i < paths.length; i++) { const fp = path.resolve(paths[i]) - if (await isFile(fp)) { - pipeArgs.fileURIs.push(fp) - } else { + if (await isDirectory(fp)) { pipeArgs.folderURIs.push(fp) + } else { + pipeArgs.fileURIs.push(fp) } } if (pipeArgs.forceNewWindow && pipeArgs.fileURIs.length > 0) { diff --git a/src/node/util.ts b/src/node/util.ts index 140431cc..698fe604 100644 --- a/src/node/util.ts +++ b/src/node/util.ts @@ -482,6 +482,15 @@ export const isFile = async (path: string): Promise => { } } +export const isDirectory = async (path: string): Promise => { + try { + const stat = await fs.stat(path) + return stat.isDirectory() + } catch (error) { + return false + } +} + /** * Escapes any HTML string special characters, like &, <, >, ", and '. *