Merge pull request #1977 from ProAdd-ons/Update-Variables-Reference
This commit is contained in:
Коммит
cb1869c4ba
|
@ -8,12 +8,12 @@
|
|||
// path to VSCode executable
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": [
|
||||
"--extensionDevelopmentPath=${workspaceRoot}"
|
||||
"--extensionDevelopmentPath=${workspaceFolder}"
|
||||
],
|
||||
"stopOnEntry": false,
|
||||
"sourceMaps": true,
|
||||
"outFiles": [
|
||||
"${workspaceRoot}/out/**/*.js"
|
||||
"${workspaceFolder}/out/**/*.js"
|
||||
],
|
||||
"preLaunchTask": "npm"
|
||||
},
|
||||
|
@ -21,13 +21,13 @@
|
|||
"name": "Launch as server",
|
||||
"type": "node2",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/out/src/debugAdapter/goDebug.js",
|
||||
"program": "${workspaceFolder}/out/src/debugAdapter/goDebug.js",
|
||||
"args": [
|
||||
"--server=4712"
|
||||
],
|
||||
"sourceMaps": true,
|
||||
"outFiles": [
|
||||
"${workspaceRoot}/out/**/*.js"
|
||||
"${workspaceFolder}/out/**/*.js"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -37,13 +37,13 @@
|
|||
"runtimeExecutable": "${execPath}",
|
||||
// the workspace path should be GOPATH
|
||||
"args": [
|
||||
"--extensionDevelopmentPath=${workspaceRoot}",
|
||||
"--extensionTestsPath=${workspaceRoot}/out/test"
|
||||
"--extensionDevelopmentPath=${workspaceFolder}",
|
||||
"--extensionTestsPath=${workspaceFolder}/out/test"
|
||||
],
|
||||
"stopOnEntry": false,
|
||||
"sourceMaps": true,
|
||||
"outFiles": [
|
||||
"${workspaceRoot}/out/**/*.js"
|
||||
"${workspaceFolder}/out/**/*.js"
|
||||
],
|
||||
"preLaunchTask": "npm"
|
||||
},
|
||||
|
@ -51,14 +51,14 @@
|
|||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Unit Tests",
|
||||
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
|
||||
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
|
||||
"args": [
|
||||
"-u",
|
||||
"tdd",
|
||||
"--timeout",
|
||||
"5000",
|
||||
"--colors",
|
||||
"${workspaceRoot}/out/test/unit"
|
||||
"${workspaceFolder}/out/test/unit"
|
||||
],
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
}
|
||||
|
@ -72,4 +72,4 @@
|
|||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Available variables which can be used inside of strings.
|
||||
// ${workspaceRoot}: the root folder of the team
|
||||
// ${workspaceFolder}: the root folder of the team
|
||||
// ${file}: the current opened file
|
||||
// ${fileBasename}: the current opened file's basename
|
||||
// ${fileDirname}: the current opened file's dirname
|
||||
|
@ -28,4 +28,4 @@
|
|||
|
||||
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
|
||||
"problemMatcher": "$tsc-watch"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ An alternative of golint is [revive](https://github.com/mgechev/revive). It is e
|
|||
To configure revive, use:
|
||||
|
||||
```javascript
|
||||
"go.lintFlags": ["-exclude=vendor/...", "-config=${workspaceRoot}/config.toml"]
|
||||
"go.lintFlags": ["-exclude=vendor/...", "-config=${workspaceFolder}/config.toml"]
|
||||
```
|
||||
|
||||
Finally, the result of those linters will show right in the code (locations with suggestions will be underlined),
|
||||
|
|
14
package.json
14
package.json
|
@ -277,7 +277,7 @@
|
|||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"program": "^\"\\${workspaceRoot}${1:}\""
|
||||
"program": "^\"\\${workspaceFolder}${1:}\""
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -299,7 +299,7 @@
|
|||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "test",
|
||||
"program": "^\"\\${workspaceRoot}${1:}\""
|
||||
"program": "^\"\\${workspaceFolder}${1:}\""
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -310,7 +310,7 @@
|
|||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "test",
|
||||
"program": "^\"\\${workspaceRoot}${1:}\"",
|
||||
"program": "^\"\\${workspaceFolder}${1:}\"",
|
||||
"args": [
|
||||
"-test.run",
|
||||
"${2:MyTestFunction}"
|
||||
|
@ -325,10 +325,10 @@
|
|||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "remote",
|
||||
"remotePath": "^\"\\${workspaceRoot}${1:}\"",
|
||||
"remotePath": "^\"\\${workspaceFolder}${1:}\"",
|
||||
"port": 2345,
|
||||
"host": "127.0.0.1",
|
||||
"program": "^\"\\${workspaceRoot}${1:}\"",
|
||||
"program": "^\"\\${workspaceFolder}${1:}\"",
|
||||
"env": {},
|
||||
"args": []
|
||||
}
|
||||
|
@ -341,7 +341,7 @@
|
|||
"program": {
|
||||
"type": "string",
|
||||
"description": "Path to the program folder (or any file within that folder) when in 'debug' or 'test' mode, and to the pre-built binary file to debug in 'exec' mode.",
|
||||
"default": "${workspaceRoot}"
|
||||
"default": "${workspaceFolder}"
|
||||
},
|
||||
"mode": {
|
||||
"enum": [
|
||||
|
@ -422,7 +422,7 @@
|
|||
"envFile": {
|
||||
"type": "string",
|
||||
"description": "Absolute path to a file containing environment variable definitions.",
|
||||
"default": "${workspaceRoot}/.env"
|
||||
"default": "${workspaceFolder}/.env"
|
||||
},
|
||||
"backend": {
|
||||
"type": "string",
|
||||
|
|
21
src/util.ts
21
src/util.ts
|
@ -350,16 +350,16 @@ function resolveToolsGopath(): string {
|
|||
|
||||
let toolsGopathForWorkspace = vscode.workspace.getConfiguration('go')['toolsGopath'] || '';
|
||||
|
||||
// In case of single root, use resolvePath to resolve ~ and ${workspaceRoot}
|
||||
// In case of single root
|
||||
if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length <= 1) {
|
||||
return resolvePath(toolsGopathForWorkspace);
|
||||
}
|
||||
|
||||
// In case of multi-root, resolve ~ and ignore ${workspaceRoot}
|
||||
// In case of multi-root, resolve ~ and ${workspaceFolder}
|
||||
if (toolsGopathForWorkspace.startsWith('~')) {
|
||||
toolsGopathForWorkspace = path.join(os.homedir(), toolsGopathForWorkspace.substr(1));
|
||||
}
|
||||
if (toolsGopathForWorkspace && toolsGopathForWorkspace.trim() && !/\${workspaceRoot}/.test(toolsGopathForWorkspace)) {
|
||||
if (toolsGopathForWorkspace && toolsGopathForWorkspace.trim() && !/\${workspaceFolder}|\${workspaceRoot}/.test(toolsGopathForWorkspace)) {
|
||||
return toolsGopathForWorkspace;
|
||||
}
|
||||
|
||||
|
@ -502,21 +502,21 @@ export function timeout(millis): Promise<void> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Exapnds ~ to homedir in non-Windows platform and resolves ${workspaceRoot}
|
||||
* Exapnds ~ to homedir in non-Windows platform and resolves ${workspaceFolder} or ${workspaceRoot}
|
||||
*/
|
||||
export function resolvePath(inputPath: string, workspaceRoot?: string): string {
|
||||
export function resolvePath(inputPath: string, workspaceFolder?: string): string {
|
||||
if (!inputPath || !inputPath.trim()) return inputPath;
|
||||
|
||||
if (!workspaceRoot && vscode.workspace.workspaceFolders) {
|
||||
if (!workspaceFolder && vscode.workspace.workspaceFolders) {
|
||||
if (vscode.workspace.workspaceFolders.length === 1) {
|
||||
workspaceRoot = vscode.workspace.rootPath;
|
||||
workspaceFolder = vscode.workspace.rootPath;
|
||||
} else if (vscode.window.activeTextEditor && vscode.workspace.getWorkspaceFolder(vscode.window.activeTextEditor.document.uri)) {
|
||||
workspaceRoot = vscode.workspace.getWorkspaceFolder(vscode.window.activeTextEditor.document.uri).uri.fsPath;
|
||||
workspaceFolder = vscode.workspace.getWorkspaceFolder(vscode.window.activeTextEditor.document.uri).uri.fsPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (workspaceRoot) {
|
||||
inputPath = inputPath.replace(/\${workspaceRoot}/g, workspaceRoot).replace(/\${workspaceFolder}/g, workspaceRoot);
|
||||
if (workspaceFolder) {
|
||||
inputPath = inputPath.replace(/\${workspaceFolder}|\${workspaceRoot}/g, workspaceFolder);
|
||||
}
|
||||
return resolveHomeDir(inputPath);
|
||||
}
|
||||
|
@ -890,4 +890,3 @@ export function cleanupTempDir() {
|
|||
}
|
||||
tmpDir = undefined;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче