- Notifications
You must be signed in to change notification settings - Fork 36.8k
Add ARGB color format support for color decorators #282693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Fixes microsoft#282673 Adds editor.colorDecoratorsHexFormat setting to support ARGB color format (#AARRGGBB) used by Qt and Android frameworks, in addition to the default RGBA format (#RRGGBBAA) used by CSS. - New setting: editor.colorDecoratorsHexFormat ('rgba' | 'argb') - Modified Color.Format.CSS.parseHex to accept format parameter - Updated entire worker service chain to propagate format - Added comprehensive tests for ARGB parsing - Default remains RGBA to preserve existing behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for the ARGB hexadecimal color format (#AARRGGBB and #ARGB) alongside the existing RGBA format (#RRGGBBAA and #RGBA) for color decorators in the editor. This enables users working with Qt-based frameworks and other tools that use ARGB format to have colors parsed correctly. The implementation maintains backward compatibility by defaulting to RGBA format.
Key Changes:
- Added new editor setting
editor.colorDecoratorsHexFormatwith options'rgba'(default) and'argb' - Modified core color parsing logic to accept a format parameter that determines alpha channel position
- Propagated the format parameter through the service chain from editor configuration to worker services
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/vs/monaco.d.ts | Added TypeScript API declarations for new colorDecoratorsHexFormat option and updated EditorOption enum |
src/vs/editor/common/standalone/standaloneEnums.ts | Updated EditorOption enum to include new colorDecoratorsHexFormat entry |
src/vs/editor/common/config/editorOptions.ts | Registered new editor option with localized descriptions for RGBA and ARGB formats |
src/vs/base/common/color.ts | Modified parseHex() to accept optional format parameter controlling alpha channel position |
src/vs/editor/common/languages/defaultDocumentColorsComputer.ts | Threaded format parameter through color computation functions |
src/vs/editor/common/services/editorWorker.ts | Added optional format parameter to computeDefaultDocumentColors interface |
src/vs/editor/browser/services/editorWorkerService.ts | Propagated format parameter to worker method invocation |
src/vs/editor/common/services/editorWebWorker.ts | Added format parameter with default value to worker implementation |
src/vs/editor/contrib/colorPicker/browser/defaultDocumentColorProvider.ts | Read configuration value and pass format to worker service |
src/vs/editor/contrib/colorPicker/browser/standaloneColorPicker/standaloneColorPickerWidget.ts | Updated to inject and pass configuration service to DefaultDocumentColorProvider |
src/vs/editor/test/common/services/testEditorWorkerService.ts | Updated test service signature to match new interface |
src/vs/base/test/common/color.test.ts | Added comprehensive tests for ARGB format parsing |
src/vs/editor/test/common/languages/defaultDocumentColorsComputer.test.ts | Added tests verifying both RGBA and ARGB format behavior |
| * Converts an Hex color value to a Color. | ||
| * returns r, g, and b are contained in the set [0, 255] | ||
| * @param hex string (#RGB, #RGBA, #RRGGBB or #RRGGBBAA). | ||
| * @param format 'rgba' (default) or 'argb' - controls how to interpret 8-char hex colors |
Copilot AI Dec 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JSDoc comment should be updated to reflect that both RGBA and ARGB formats are supported. The current description mentions "#RGB, #RGBA, #RRGGBB or #RRGGBBAA" but doesn't indicate that ARGB formats are also accepted when the format parameter is set to 'argb'.
| * Converts an Hex color value to a Color. | |
| * returns r, g, and b are contained in the set [0, 255] | |
| * @param hex string (#RGB, #RGBA, #RRGGBB or #RRGGBBAA). | |
| * @param format 'rgba' (default) or 'argb' - controls how to interpret 8-char hex colors | |
| * Converts a Hex color value to a Color. | |
| * Returns r, g, and b in the set [0, 255]. | |
| * @param hex string - Supported formats: | |
| * - When format is 'rgba' (default): #RGB, #RGBA, #RRGGBB, #RRGGBBAA | |
| * - When format is 'argb': #ARGB, #AARRGGBB | |
| * @param format 'rgba' (default) or 'argb' - controls how to interpret 4/8-char hex colors |
| @pgivel please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Fixes #282673
This PR adds support for ARGB hexadecimal color format (
#AARRGGBB) alongside the existing RGBA format (#RRGGBBAA).This is my first time contributing, feel free to correct anything that may not be right.
Changes
editor.colorDecoratorsHexFormatwith values'rgba'(default) and'argb'Color.Format.CSS.parseHex()to accept both formatsWhy ARGB?
Qt and some other frameworks use ARGB format where alpha comes first, while web/CSS uses RGBA where alpha comes last. This PR enables users working with Qt-based applications to have color decorators parse colors correctly.
Default behavior
The default remains
'rgba'to maintain backward compatibility. Users must explicitly seteditor.colorDecoratorsHexFormatto'argb'to use the alternative format.