mirror of
https://github.com/danog/code-server.git
synced 2024-11-26 20:34:56 +01:00
Allow opening files at a specific line and column (fixes #5619)
This commit is contained in:
parent
3a9eb312b1
commit
d11bb41d33
@ -9,7 +9,7 @@ import { AuthType, DefaultedArgs, Feature, SpawnCodeCli, toCodeArgs, UserProvide
|
|||||||
import { coderCloudBind } from "./coder_cloud"
|
import { coderCloudBind } from "./coder_cloud"
|
||||||
import { commit, version } from "./constants"
|
import { commit, version } from "./constants"
|
||||||
import { register } from "./routes"
|
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.
|
* 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: [],
|
fileURIs: [],
|
||||||
forceReuseWindow: args["reuse-window"],
|
forceReuseWindow: args["reuse-window"],
|
||||||
forceNewWindow: args["new-window"],
|
forceNewWindow: args["new-window"],
|
||||||
|
gotoLineMode: true,
|
||||||
}
|
}
|
||||||
const paths = args._ || []
|
const paths = args._ || []
|
||||||
for (let i = 0; i < paths.length; i++) {
|
for (let i = 0; i < paths.length; i++) {
|
||||||
const fp = path.resolve(paths[i])
|
const fp = path.resolve(paths[i])
|
||||||
if (await isFile(fp)) {
|
if (await isDirectory(fp)) {
|
||||||
pipeArgs.fileURIs.push(fp)
|
|
||||||
} else {
|
|
||||||
pipeArgs.folderURIs.push(fp)
|
pipeArgs.folderURIs.push(fp)
|
||||||
|
} else {
|
||||||
|
pipeArgs.fileURIs.push(fp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pipeArgs.forceNewWindow && pipeArgs.fileURIs.length > 0) {
|
if (pipeArgs.forceNewWindow && pipeArgs.fileURIs.length > 0) {
|
||||||
|
@ -482,6 +482,15 @@ export const isFile = async (path: string): Promise<boolean> => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const isDirectory = async (path: string): Promise<boolean> => {
|
||||||
|
try {
|
||||||
|
const stat = await fs.stat(path)
|
||||||
|
return stat.isDirectory()
|
||||||
|
} catch (error) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Escapes any HTML string special characters, like &, <, >, ", and '.
|
* Escapes any HTML string special characters, like &, <, >, ", and '.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user