Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ class PHPCBF {
(window.activeTextEditor ? window.activeTextEditor.document.uri : null);

let config = workspace.getConfiguration("phpcbf", configUri);
if (!config.get("enable") === true) {
// Always read the enable flag first so format() can check it even when
// disabled. The original `!config.get("enable") === true` check returned
// early without storing the value, leaving stale settings in place and
// allowing phpcbf to run despite being disabled.
this.enable = config.get("enable", true);
if (!this.enable) {
return;
}
this.onsave = config.get("onsave", false);
Expand Down Expand Up @@ -132,6 +137,11 @@ class PHPCBF {
// per-folder settings are respected on every format call.
this.loadSettings(document.uri);

// Respect phpcbf.enable = false: return an empty edit list immediately.
if (!this.enable) {
return Promise.resolve([]);
}

if (this.debug) {
console.time("phpcbf");
}
Expand Down