diff --git a/.vscode/launch.json b/.vscode/launch.json index ecc878a6f..f7683f4af 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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 @@ ] } ] -} \ No newline at end of file +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 39582a4b5..2d616db56 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -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" -} \ No newline at end of file +} diff --git a/README.md b/README.md index e444e24c8..f98b17a21 100644 --- a/README.md +++ b/README.md @@ -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), diff --git a/package.json b/package.json index 0f12cd4dd..21f8a6bdb 100644 --- a/package.json +++ b/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", diff --git a/src/util.ts b/src/util.ts index 33e5efb43..4e5aef808 100644 --- a/src/util.ts +++ b/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 { } /** - * 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; } -