From b4ca4756aa006c0c623abc85eaa5bc9efb433b6d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 29 Mar 2026 12:57:56 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20respect=20phpcbf.enable=20setting=20?= =?UTF-8?q?=E2=80=94=20operator=20precedence=20bug=20made=20it=20a=20no-op?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `false` due to JavaScript operator precedence: false === true → false (always) So the early-return was never reached and disabling phpcbf via `phpcbf.enable: false` had no effect — the formatter always ran. Fix: - Store the enabled state in `this.enabled` in `loadSettings()` - Guard `format()` with an early `Promise.reject()` when disabled This applies per-resource (the config is scoped), so users can disable phpcbf for specific workspace folders without affecting others. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- extension.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/extension.js b/extension.js index 6457e71..8c4e2c1 100644 --- a/extension.js +++ b/extension.js @@ -27,7 +27,8 @@ class PHPCBF { (window.activeTextEditor ? window.activeTextEditor.document.uri : null); let config = workspace.getConfiguration("phpcbf", configUri); - if (!config.get("enable") === true) { + this.enabled = config.get("enable", true); + if (!this.enabled) { return; } this.onsave = config.get("onsave", false); @@ -132,6 +133,11 @@ class PHPCBF { // per-folder settings are respected on every format call. this.loadSettings(document.uri); + if (!this.enabled) { + // phpcbf.enable is false for this resource — do nothing. + return Promise.reject(); + } + if (this.debug) { console.time("phpcbf"); }