npm.fetchOnlinePackageInfo is not respected in latest build. Fixes #103540

This commit is contained in:
Martin Aeschlimann
2020-08-12 11:59:51 +02:00
parent de7bb5b5fe
commit 4899592904
3 changed files with 24 additions and 12 deletions

View File

@@ -51,6 +51,10 @@ export class PackageJSONContribution implements IJSONContribution {
return Promise.resolve(null);
}
private isEnabled() {
return this.canRunNPM || this.onlineEnabled();
}
private onlineEnabled() {
return !!workspace.getConfiguration('npm').get('fetchOnlinePackageInfo');
}
@@ -63,7 +67,7 @@ export class PackageJSONContribution implements IJSONContribution {
isLast: boolean,
collector: ISuggestionsCollector
): Thenable<any> | null {
if (!this.onlineEnabled()) {
if (!this.isEnabled()) {
return null;
}
@@ -180,7 +184,7 @@ export class PackageJSONContribution implements IJSONContribution {
}
public async collectValueSuggestions(_fileName: string, location: Location, result: ISuggestionsCollector): Promise<any> {
if (!this.onlineEnabled()) {
if (!this.isEnabled()) {
return null;
}
@@ -250,7 +254,7 @@ export class PackageJSONContribution implements IJSONContribution {
if (this.canRunNPM) {
info = await this.npmView(pack);
}
if (!info) {
if (!info && this.onlineEnabled()) {
info = await this.npmjsView(pack);
}
return info;
@@ -303,6 +307,9 @@ export class PackageJSONContribution implements IJSONContribution {
}
public getInfoContribution(_fileName: string, location: Location): Thenable<MarkedString[] | null> | null {
if (!this.isEnabled()) {
return null;
}
if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']) || location.matches(['optionalDependencies', '*']) || location.matches(['peerDependencies', '*']))) {
const pack = location.path[location.path.length - 1];
if (typeof pack === 'string') {