fix: avoid writing default autoSelectOrganization to workspace config [IDE-1738]#715
fix: avoid writing default autoSelectOrganization to workspace config [IDE-1738]#715bastiandoetsch wants to merge 2 commits intomainfrom
Conversation
… [IDE-1738] The autoSelectOrganization setting was always written to the workspace folder configuration (.vscode/settings.json), even when the value was true (the default). This polluted workspace configs unnecessarily. Root cause: the condition `desiredAutoOrg !== currentAutoOrg || desiredAutoOrg` always evaluated to true when desiredAutoOrg was true (the default case). Fix: only write when the desired value actually differs from the current effective value. When clearing a folder-level override back to default, write undefined instead of true to remove the setting entirely. Co-authored-by: Cursor <cursoragent@cursor.com>
|
/describe |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
PR Description updated to latest commit (b9f821d) |
This comment has been minimized.
This comment has been minimized.
PR Reviewer Guide 🔍
|
michelkaporin
left a comment
There was a problem hiding this comment.
I'll leave the code review to your team - we're aligned on the behavioural implementation, thank you! ❤️
User description
Description
Fixes user-reported issue where the
snyk.advanced.autoSelectOrganizationsetting was always written into the workspace configuration file (.vscode/settings.json), even when the value wastrue(the default). This polluted workspace configs unnecessarily and was unwanted by users.Root cause: In
handleOrgSettingsFromFolderConfigs, the conditiondesiredAutoOrg !== currentAutoOrg || desiredAutoOrgalways evaluated totruewhendesiredAutoOrgwastrue(the common default case where the user hasn't manually set an org).Fix:
desiredAutoOrg !== currentAutoOrg— only write when there's an actual changeundefinedinstead oftrueto remove the setting entirely from workspace configsetAutoSelectOrganizationto acceptboolean | undefinedChecklist
Screenshots / GIFs
N/A — no UI changes.
PR Type
Bug fix
Description
Avoid writing default auto-select-organization to workspace config.
Only write folder config if value differs from effective config.
Clear folder-level override when falling back to default.
Diagram Walkthrough
flowchart LR A[Old Logic: Always Write Default] --> B{Check If Desired Matches Current}; B -- True --> C[Write Value]; B -- False --> D[Skip Write]; E[New Logic: Write Only if Different] --> F{Desired != Current?}; F -- True --> G{Is Desired True?}; G -- True --> H[Write Undefined (Clear Override)]; G -- False --> I[Write False]; F -- False --> D;File Walkthrough
configuration.ts
Update setAutoSelectOrganization signaturesrc/snyk/common/configuration/configuration.ts
setAutoSelectOrganizationto acceptboolean | undefined.languageServer.ts
Refine auto-organization setting logicsrc/snyk/common/languageServer/languageServer.ts
autoSelectOrganizationif the desiredvalue differs from the current effective value.
undefinedinstead oftrue.languageServer.test.ts
Update language server tests for auto-org settingssrc/test/unit/common/languageServer/languageServer.test.ts
autoSelectOrganizationis not writtenwhen
orgSetByUseris false andcurrentAutoOrgis already true.autoSelectOrganizationoverride is cleared by writingundefinedwhenorgSetByUseris false andcurrentAutoOrgis false.