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

Strip version from autocompleted pkgs from gopkg.in #659

Merged
merged 1 commit into from Nov 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/goSuggest.ts
Expand Up @@ -207,8 +207,13 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
let pkgPromise = listPackages(true).then((pkgs: string[]) => {
this.pkgsList = pkgs.map(pkg => {
let index = pkg.lastIndexOf('/');
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'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the user or package name have '.v'? You could use lastIndexOf, or more regex cleverness.

}
return {
name: index === -1 ? pkg : pkg.substr(index + 1),
name: pkgName,
path: pkg
};
});
Expand Down