Skip to content

Commit

Permalink
Merge 'microsoft/vscode-go/master' into 'golang/vscode-go/master'
Browse files Browse the repository at this point in the history
Sync @ 7da5077

* master:
  Address mismatch on path separators in debug config (microsoft#2010) (microsoft#3108)
  Include the link to release note/package overview in the update prompt, and update gopls default version (microsoft#3041)
  bug_report.md: Fix "architecture" typo. (microsoft#3095)
  telemetry.ts: send telemetry only if aiKey is not an empty  string(microsoft#3091)
  • Loading branch information
hyangah committed Mar 19, 2020
2 parents 114da49 + 7da5077 commit d11e342
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Please answer these questions before submitting your issue. Thanks!
- <Paste VS Code version here>
- Check your installed extensions to get the version of the VS Code Go extension
- <Paste Go extension version here>
- Run `go env GOOS GOARCH` to get the operating system and processor arhcitecture details
- Run `go env GOOS GOARCH` to get the operating system and processor architecture details
- <Paste OS and arch details here>

### Share the Go related settings you have added/edited
Expand Down
26 changes: 14 additions & 12 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,16 @@ function logError(...args: any[]) {
logger.error(logArgsToString(args));
}

function findPathSeparator(filePath: string) {
return filePath.includes('/') ? '/' : '\\';
}

function normalizePath(filePath: string) {
if (process.platform === 'win32') {
const pathSeparator = findPathSeparator(filePath);
filePath = path.normalize(filePath);
// Normalize will replace everything with backslash on Windows.
filePath = filePath.replace(/\\/g, pathSeparator);
return fixDriveCasingInWindows(filePath);
}
return filePath;
Expand Down Expand Up @@ -754,13 +761,6 @@ class GoDebugSession extends LoggingDebugSession {
log('InitializeResponse');
}

protected findPathSeperator(filePath: string) {
if (/^(\w:[\\/]|\\\\)/.test(filePath)) {
return '\\';
}
return filePath.includes('/') ? '/' : '\\';
}

protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {
if (!args.program) {
this.sendErrorResponse(
Expand Down Expand Up @@ -835,10 +835,12 @@ class GoDebugSession extends LoggingDebugSession {
if (this.delve.remotePath.length === 0) {
return this.convertClientPathToDebugger(filePath);
}
// The filePath may have a different path separator than the localPath
// So, update it to use the same separator as the remote path to ease
// in replacing the local path in it with remote path
filePath = filePath.replace(/\/|\\/g, this.remotePathSeparator);
return filePath
.replace(this.delve.program, this.delve.remotePath)
.split(this.localPathSeparator)
.join(this.remotePathSeparator);
.replace(this.delve.program.replace(/\/|\\/g, this.remotePathSeparator), this.delve.remotePath);
}

protected toLocalPath(pathToConvert: string): string {
Expand Down Expand Up @@ -1392,8 +1394,8 @@ class GoDebugSession extends LoggingDebugSession {
}

if (args.remotePath.length > 0) {
this.localPathSeparator = this.findPathSeperator(localPath);
this.remotePathSeparator = this.findPathSeperator(args.remotePath);
this.localPathSeparator = findPathSeparator(localPath);
this.remotePathSeparator = findPathSeparator(args.remotePath);

const llist = localPath.split(/\/|\\/).reverse();
const rlist = args.remotePath.split(/\/|\\/).reverse();
Expand Down
9 changes: 8 additions & 1 deletion src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,18 @@ export async function promptForUpdatingTool(toolName: string) {
}
const goVersion = await getGoVersion();
const updateMsg = `Your version of ${tool.name} appears to be out of date. Please update for an improved experience.`;
vscode.window.showInformationMessage(updateMsg, 'Update').then((selected) => {
const choices: string[] = ['Update'];
if (toolName === `gopls`) {
choices.push('Release Notes'); // TODO(hyangah): pass more info such as version, release note location.
}
vscode.window.showInformationMessage(updateMsg, ...choices).then((selected) => {
switch (selected) {
case 'Update':
installTools([tool], goVersion);
break;
case 'Release Notes':
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://github.com/golang/go/issues/33030#issuecomment-510151934'));
break;
default:
declinedUpdates.push(tool);
break;
Expand Down

0 comments on commit d11e342

Please sign in to comment.