Skip to content

Conversation

@pgivel
Copy link

@pgivel pgivel commented Dec 11, 2025

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

  • New setting: editor.colorDecoratorsHexFormat with values 'rgba' (default) and 'argb'
  • Color parsing: Modified Color.Format.CSS.parseHex() to accept both formats
  • Service chain: Updated worker services to propagate format parameter (Not sure about this, maybe there could be a better way)
  • Tests: Added tests for both 4-digit (#ARGB) and 8-digit (#AARRGGBB) formats

Why 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 set editor.colorDecoratorsHexFormat to 'argb' to use the alternative format.

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
Copilot AI review requested due to automatic review settings December 11, 2025 10:54
Copy link
Contributor

Copilot AI left a 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.colorDecoratorsHexFormat with 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

Comment on lines 858 to +861
* 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
Copy link

Copilot AI Dec 11, 2025

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'.

Suggested change
* 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

Copilot uses AI. Check for mistakes.
@pgivel
Copy link
Author

pgivel commented Dec 12, 2025

@microsoft-github-policy-service agree company="Genymobile SAS"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a setting for color picker to parse ARGB instead of RGBA

2 participants