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

Commit

Permalink
Use selected text for browsing pkgs #330
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Jul 17, 2017
1 parent 6abec04 commit 352ecac
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/goBrowsePackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ export function browsePackages() {
if (!goRuntimePath) {
return;
}
let selection = vscode.window.activeTextEditor ? vscode.window.activeTextEditor.selection : undefined;
let selectedText = (selection && !selection.isEmpty) ? vscode.window.activeTextEditor.document.getText(selection) : '';

goListAll().then(pkgMap => {
const pkgs: string[] = Array.from(pkgMap.keys());
if (!pkgs || pkgs.length === 0) {
return;
}
vscode.window.showQuickPick(pkgs).then(pkg => {
let selectPkgPromise: Thenable<string> = Promise.resolve(selectedText);
if (!selectedText || pkgs.indexOf(selectedText) === -1) {
selectPkgPromise = vscode.window.showQuickPick(pkgs);
}
selectPkgPromise.then(pkg => {
cp.execFile(goRuntimePath, ['list', '-f', '{{.Dir}}:{{.GoFiles}}:{{.TestGoFiles}}:{{.XTestGoFiles}}', pkg], (err, stdout, stderr) => {
if (!stdout || stdout.indexOf(':') === -1) {
return;
Expand Down

0 comments on commit 352ecac

Please sign in to comment.