Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Corner cases for add pkg to workspace cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Jul 25, 2018
1 parent 4e2c08b commit a3033f4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* Fix error with `Go: Generate Interface Stubs` command when using on an interface that is defined inside an "internal" folder.[Bug 1769](https://github.com/Microsoft/vscode-go/issues/1769)
* Fix bug where auto-completions dont show built-in types. [Bug 1739](https://github.com/Microsoft/vscode-go/issues/1739)
* Look at GOROOT before PATH when looking for the Go binary. Fixes [Bug 1760](https://github.com/Microsoft/vscode-go/issues/1760) which was a regression.
* Clean up the debug binary that gets generated by delve at the end of the debugging session. Fix works in Windows only at the moment, waiting for upstream fixes to make it work in other platforms.
* Clean up the debug binary that gets generated by delve at the end of the debugging session. [Bug 1345](https://github.com/Microsoft/vscode-go/issues/1345)

## 0.6.84 - 29th June, 2018

Expand Down
Binary file modified Go-latest.vsix
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Go",
"version": "0.6.85-beta.7",
"version": "0.6.85-beta.8",
"publisher": "ms-vscode",
"description": "Rich Go language support for Visual Studio Code",
"author": {
Expand Down
23 changes: 11 additions & 12 deletions src/goImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,16 @@ export function addImportToWorkspace() {

let importPath = '';
if (!selection.isEmpty) {
// Attempt to load a partial import path based on currently selected text
let selectedText = editor.document.getText(selection).trim();
if (selectedText.length > 0) {
if (!selectedText.startsWith('"')) {
selectedText = '"' + selectedText;
}
if (!selectedText.endsWith('"')) {
selectedText = selectedText + '"';
if (selectedText.indexOf(' ') === -1) {
// Attempt to load a partial import path based on currently selected text
if (!selectedText.startsWith('"')) {
selectedText = '"' + selectedText;
}
if (!selectedText.endsWith('"')) {
selectedText = selectedText + '"';
}
}
importPath = getImportPath(selectedText);
}
Expand All @@ -140,12 +142,9 @@ export function addImportToWorkspace() {
const env = getToolsEnvVars();

cp.execFile(goRuntimePath, ['list', '-f', '{{.Dir}}', importPath], { env }, (err, stdout, stderr) => {
if (!stdout) {
return;
}

let dirs = stdout.split('\n');
if (dirs.length === 0) {
let dirs = (stdout || '').split('\n');
if (!dirs.length || !dirs[0].trim()) {
vscode.window.showErrorMessage(`Could not find package ${importPath}`);
return;
}

Expand Down

0 comments on commit a3033f4

Please sign in to comment.