From fad31c178608724652199e5ef3a5782effe61fcc Mon Sep 17 00:00:00 2001 From: Joseph Britton <85815005+JoeeBritton@users.noreply.github.com> Date: Mon, 23 Oct 2023 07:54:20 -0700 Subject: [PATCH] Fix stdio incompatibility with some third-party clients (#604) * Stdio patch Do not log validation status on stdout, use connection logs instead. See #540, #541 * Fix: use optional chaining for connection as it may not exist for purposes of testing. --------- Co-authored-by: Priyam Sahoo <42550351+priyamsahoo@users.noreply.github.com> --- src/providers/validationProvider.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/providers/validationProvider.ts b/src/providers/validationProvider.ts index 263d5bcb..09113cb3 100644 --- a/src/providers/validationProvider.ts +++ b/src/providers/validationProvider.ts @@ -36,7 +36,7 @@ export async function doValidate( const settings = await context.documentSettings.get(textDocument.uri); if (!settings.validation.enabled) { - console.log("Validation disabled"); + connection?.console.log("Validation disabled"); // this is done to remove the cache as well const blankDiagnostics = new Map(); @@ -54,10 +54,10 @@ export async function doValidate( : settings.validation.lint.path; const lintAvailability = await commandRunner.getExecutablePath(lintExecutable); - console.debug("Path for lint: ", lintAvailability); + connection?.console.log(`Path for lint: ${lintAvailability}`); if (lintAvailability) { - console.debug("Validating using ansible-lint"); + connection?.console.log("Validating using ansible-lint"); diagnosticsByFile = await context.ansibleLint.doValidate(textDocument); } else { connection?.window.showErrorMessage( @@ -68,14 +68,14 @@ export async function doValidate( // validate using ansible-playbook --syntax-check else { - console.debug("Validating using ansible syntax-check"); + connection?.console.log("Validating using ansible syntax-check"); if (isPlaybook(textDocument)) { - console.debug("playbook file"); + connection?.console.log("playbook file"); diagnosticsByFile = await context.ansiblePlaybook.doValidate(textDocument); } else { - console.debug("non-playbook file"); + connection?.console.log("non-playbook file"); diagnosticsByFile = new Map(); } }