diff --git a/src/client/common/installer/productInstaller.ts b/src/client/common/installer/productInstaller.ts index 1d6f34637ea8..c404906d6cb5 100644 --- a/src/client/common/installer/productInstaller.ts +++ b/src/client/common/installer/productInstaller.ts @@ -154,18 +154,21 @@ class LinterInstaller extends BaseInstaller { public async promptToInstall(product: Product, resource?: Uri): Promise { const productName = ProductNames.get(product)!; const install = 'Install'; - const disable = 'Disable linting'; + const disableAllLinting = 'Disable linting'; + const disableThisLinter = `Disable ${productName}`; const response = await this.appShell - .showErrorMessage(`Linter ${productName} is not installed.`, install, disable); + .showErrorMessage(`Linter ${productName} is not installed.`, install, disableThisLinter, disableAllLinting); if (response === install) { return this.install(product, resource); } const lm = this.serviceContainer.get(ILinterManager); - if (response === disable) { + if (response === disableAllLinting) { await lm.enableLintingAsync(false); - } else { - lm.disableSessionLinting(); + return InstallerResponse.Disabled; + } else if (response === disableThisLinter) { + await lm.getLinterInfo(product).enableAsync(false); + return InstallerResponse.Disabled; } return InstallerResponse.Ignore; } diff --git a/src/client/linters/linterManager.ts b/src/client/linters/linterManager.ts index 9b8a9a13d430..4158d8210ebc 100644 --- a/src/client/linters/linterManager.ts +++ b/src/client/linters/linterManager.ts @@ -30,7 +30,6 @@ export class LinterManager implements ILinterManager { private lintingEnabledSettingName = 'enabled'; private linters: ILinterInfo[]; private configService: IConfigurationService; - private disabledForCurrentSession = false; constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) { this.configService = serviceContainer.get(IConfigurationService); @@ -58,18 +57,11 @@ export class LinterManager implements ILinterManager { } public isLintingEnabled(resource?: Uri): boolean { - if (this.disabledForCurrentSession) { - return false; - } const settings = this.configService.getSettings(resource); return (settings.linting[this.lintingEnabledSettingName] as boolean) && this.getActiveLinters(resource).length > 0; } public async enableLintingAsync(enable: boolean, resource?: Uri): Promise { - if (enable) { - this.disabledForCurrentSession = false; - } - await this.configService.updateSettingAsync(`linting.${this.lintingEnabledSettingName}`, enable, resource); // If nothing is enabled, fix it up to PyLint (default). @@ -78,10 +70,6 @@ export class LinterManager implements ILinterManager { } } - public disableSessionLinting(): void { - this.disabledForCurrentSession = true; - } - public getActiveLinters(resource?: Uri): ILinterInfo[] { return this.linters.filter(x => x.isEnabled(resource)); } diff --git a/src/client/linters/types.ts b/src/client/linters/types.ts index bbd89558fa47..6a7755eec2ee 100644 --- a/src/client/linters/types.ts +++ b/src/client/linters/types.ts @@ -38,7 +38,6 @@ export interface ILinterManager { getActiveLinters(resource?: vscode.Uri): ILinterInfo[]; isLintingEnabled(resource?: vscode.Uri): boolean; enableLintingAsync(enable: boolean, resource?: vscode.Uri): Promise; - disableSessionLinting(): void; setActiveLintersAsync(products: Product[], resource?: vscode.Uri): Promise; createLinter(product: Product, outputChannel: vscode.OutputChannel, serviceContainer: IServiceContainer, resource?: vscode.Uri): ILinter; }