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

Commit

Permalink
Refactor for corner cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Nov 30, 2016
1 parent 5673d88 commit 0505f2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/goImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,14 @@ export function listPackages(excludeImportedPkgs: boolean = false): Thenable<str
return;
}

let magicVendorString = 'vendor/';
let magicVendorString = '/vendor/';
let vendorIndex = pkg.indexOf(magicVendorString);

if (vendorIndex === -1) {
magicVendorString = 'vendor/';
if (pkg.startsWith(magicVendorString)) {
vendorIndex = 0;
}
}
// Check if current file and the vendor pkg belong to the same root project
// If yes, then vendor pkg can be replaced with its relative path to the "vendor" folder
// If not, then the vendor pkg should not be allowed to be imported.
Expand Down
2 changes: 1 addition & 1 deletion src/goSuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
let pkgName = index === -1 ? pkg : pkg.substr(index + 1);
// pkgs from gopkg.in will be of the form gopkg.in/user/somepkg.v3
if (pkg.match(/gopkg\.in\/.*\.v\d+/)) {
pkgName = pkgName.substr(0, pkgName.indexOf('.v'));
pkgName = pkgName.substr(0, pkgName.lastIndexOf('.v'));
}
return {
name: pkgName,
Expand Down

0 comments on commit 0505f2a

Please sign in to comment.