From ffe8cf6f57c18e887e077370f55ccda7a17b0669 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Fri, 3 Feb 2023 13:20:04 +0530 Subject: [PATCH] Add a button in prompt to check logs in case the selected interpreter is invalid --- .../diagnostics/checks/pythonInterpreter.ts | 14 ++++++++++++-- .../checks/pythonInterpreter.unit.test.ts | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/client/application/diagnostics/checks/pythonInterpreter.ts b/src/client/application/diagnostics/checks/pythonInterpreter.ts index 45a758c9f283..4f5133d9dcbe 100644 --- a/src/client/application/diagnostics/checks/pythonInterpreter.ts +++ b/src/client/application/diagnostics/checks/pythonInterpreter.ts @@ -34,7 +34,7 @@ const messages = { 'No Python interpreter is selected. Please select a Python interpreter to enable features such as IntelliSense, linting, and debugging.', ), [DiagnosticCodes.InvalidPythonInterpreterDiagnostic]: l10n.t( - 'An Invalid Python interpreter is selected{0}, please try changing it to enable features such as IntelliSense, linting, and debugging.', + 'An Invalid Python interpreter is selected{0}, please try changing it to enable features such as IntelliSense, linting, and debugging. See output for more details regarding why the interpreter is invalid.', ), }; @@ -163,7 +163,7 @@ export class InvalidPythonInterpreterService extends BaseDiagnosticsService private getCommandPrompts(diagnostic: IDiagnostic): { prompt: string; command?: IDiagnosticCommand }[] { const commandFactory = this.serviceContainer.get(IDiagnosticsCommandFactory); - return [ + const prompts = [ { prompt: Common.selectPythonInterpreter, command: commandFactory.createCommand(diagnostic, { @@ -172,6 +172,16 @@ export class InvalidPythonInterpreterService extends BaseDiagnosticsService }), }, ]; + if (diagnostic.code === DiagnosticCodes.InvalidPythonInterpreterDiagnostic) { + prompts.push({ + prompt: Common.openOutputPanel, + command: commandFactory.createCommand(diagnostic, { + type: 'executeVSCCommand', + options: Commands.ViewOutput, + }), + }); + } + return prompts; } } diff --git a/src/test/application/diagnostics/checks/pythonInterpreter.unit.test.ts b/src/test/application/diagnostics/checks/pythonInterpreter.unit.test.ts index bbca6c1a84e4..ea9bc9ae62d5 100644 --- a/src/test/application/diagnostics/checks/pythonInterpreter.unit.test.ts +++ b/src/test/application/diagnostics/checks/pythonInterpreter.unit.test.ts @@ -295,7 +295,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => { ), ) .returns(() => cmd) - .verifiable(typemoq.Times.once()); + .verifiable(typemoq.Times.exactly(2)); await diagnosticService.handle([diagnostic]); @@ -304,6 +304,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => { expect(messagePrompt).not.be.equal(undefined, 'Message prompt not set'); expect(messagePrompt!.commandPrompts).to.be.deep.equal([ { prompt: Common.selectPythonInterpreter, command: cmd }, + { prompt: Common.openOutputPanel, command: cmd }, ]); expect(messagePrompt!.onClose).be.equal(undefined, 'onClose handler should not be set.'); });