This implementation adds support for synchronizing disabled extensions in VSCode Settings Sync.
Previously, VSCode Settings Sync could not synchronize the disabled state of extensions. When users disabled extensions on one machine, those extensions would remain enabled when synced to another machine.
The solution works by:
- Detection: Reading VSCode's internal settings to detect disabled extensions
- Storage: Including disabled extension information in the sync data
- Restoration: Restoring disabled states when downloading settings
Core service for handling disabled extensions:
- Reads VSCode user and workspace settings
- Detects globally and workspace-disabled extensions
- Provides methods to enable/disable extensions programmatically
- Handles cross-platform configuration file paths
Comprehensive test suite for the new functionality:
- Unit tests for disabled extension detection
- Integration tests for sync workflow
- Mock data helpers for testing
Enhanced the ExtensionInformation class and PluginService:
- Added
disabled,disabledGlobally, anddisabledInWorkspaceproperties - Updated
CreateExtensionList()to include disabled extensions - Added
RestoreDisabledExtensions()method for sync restoration - Enhanced JSON serialization/deserialization
Integrated disabled extension restoration into the download workflow:
- Added call to
RestoreDisabledExtensions()after extension installation - Proper error handling and user feedback
CreateExtensionList()now includes both enabled and disabled extensions- Each extension has flags indicating its disabled state:
disabled: true if disabled in any waydisabledGlobally: true if disabled globallydisabledInWorkspace: true if disabled in current workspace
- This information is serialized and uploaded to the Gist
- Extensions are installed as before
- After installation,
RestoreDisabledExtensions()is called - The service reads the disabled state flags from sync data
- Uses VSCode commands to disable extensions as needed:
workbench.extensions.disableExtensionfor global disableworkbench.extensions.disableExtensionInWorkspacefor workspace disable
The service reads disabled extension information from:
Windows:
%APPDATA%\Code\User\settings.json<workspace>\.vscode\settings.json
macOS:
~/Library/Application Support/Code/User/settings.json<workspace>/.vscode/settings.json
Linux:
~/.config/Code/User/settings.json<workspace>/.vscode/settings.json
Disabled extensions are stored in the extensions.disabled array:
{
"extensions.disabled": [
"publisher.extension-name",
"another-publisher.another-extension"
]
}The implementation includes robust error handling:
- Gracefully handles missing configuration files
- Continues sync process even if disabled extension restoration fails
- Provides user feedback through output channel and status bar
- Logs errors for debugging
The implementation is fully backward compatible:
- Existing sync data without disabled extension info works normally
- New properties are optional and default to
false - No breaking changes to existing APIs
Run the test suite:
npm testThe tests cover:
- Disabled extension detection
- JSON serialization/deserialization
- Error handling for missing files
- Mock data generation for integration testing
Once implemented, the feature works automatically:
- Setup: No additional configuration needed
- Upload: Disabled extensions are automatically included in sync
- Download: Disabled states are automatically restored
- Feedback: Progress shown in output channel and status bar
Potential improvements for future versions:
- Configuration option to enable/disable this feature
- Support for extension-specific workspace settings
- Bulk enable/disable operations
- UI indicators for disabled extension sync status
This implementation fully resolves Issue #143 by providing complete support for disabled extension synchronization across all platforms and workspace configurations.