[Repo Assist] fix: respect phpcbf.enable setting — operator precedence bug made it a no-op#114
Draft
github-actions[bot] wants to merge 1 commit intomasterfrom
Conversation
…a no-op `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>
This was referenced Mar 29, 2026
github-actions bot
added a commit
that referenced
this pull request
Apr 2, 2026
Summarises all bug fixes that are ready to ship, drawn from the open Repo Assist PRs (primarily #106, #114, #117, #120, #124 and the earlier consolidated fixes). The version number in package.json is intentionally not changed here (that file requires maintainer action due to protected-file restrictions). This PR exists so the maintainer can review the intended release notes and bump the version when ready. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Repo Assist here — I'm an automated AI assistant for this repository.
Problem
The
phpcbf.enablesetting has been documented inpackage.jsonsince the early versions of this extension, but it never actually worked. Setting"phpcbf.enable": falsehad no effect — the formatter always ran.Root cause — operator precedence bug in
loadSettings():JavaScript evaluates left-to-right:
!config.get("enable")producesfalse(when enable istrue), andfalse === trueis alwaysfalse. So the guard is effectively dead code.Fix
Two minimal changes:
loadSettings()— store the enabled state correctly and keep the early-return:format()— add an early-return guard so formatting is actually skipped when disabled:The
format()guard is necessary becauseloadSettings()returning early only skips refreshing settings — without the guard informat(), the formatter would still run with whatever settings were loaded previously.Behaviour
"phpcbf.enable": true(default) — no change, formatter runs as before."phpcbf.enable": false— formatter skips silently. VS Code may show a "Formatter failed" notice ifeditor.formatOnSaveis also enabled (this is pre-existing behaviour for any formatter error; PR [Repo Assist] fix: consolidate critical bug fixes (pre-v0.0.10) #106 eliminates it by changing the catch toresolve([])).The setting is resource-scoped, so disabling phpcbf for a specific workspace folder works correctly.
Compatibility note
This PR touches the same file as the in-progress PR #106 (consolidation bug fixes), but the changes are in non-overlapping lines. If #106 is merged first, this two-line fix can be applied cleanly as a follow-up patch.
Test Status
✅ All 7 existing unit tests pass (
npm run test:unit)No new tests added — the
enablecheck is in the VSCode extension activation path which requires the VSCode test harness to exercise.Closes #(no dedicated issue — discovered during code review)