-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Integrate inline color boxes & API finalization. #32864
Conversation
@rebornix, thanks for your PR! By analyzing the history of the files in this pull request, we identified @joaomoreno and @jrieken to be potential reviewers. |
src/vs/vscode.proposed.d.ts
Outdated
@@ -168,14 +168,19 @@ declare module 'vscode' { | |||
availableFormats: ColorFormat[]; | |||
|
|||
/** | |||
* Controls whether the color decorator is rendered. | |||
*/ | |||
renderDecorator: boolean; |
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.
Shouldn't this be a user setting?
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.
Interesting... I wonder if this would function better as a user setting.
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.
Users need to have settings to control the visibility of color decorator, but I'd like to give the decision to extensions.
Right now, our internal CSS and JSON extensions have four settings for decorators rendering:
For pure CSS/JSON, the setting can be a single boolean. In this case, having a setting in the core which can be language-wise is good enough.
However, if the document has embedded languages, like CSS+JS in HTML, turning on Color Decorators only for CSS sounds fair and to make that happen in the core, we need either scoping, or asking the extension in which range should we render the decorators. Considering we already ask extensions for color range, we can ask them whether to render the inline color decorator for a specific range or not at the same time.
If we decide to make ColorPicker and Color Decorators two standalone features, then I prefer to have a user setting to control Color Decorators, and do following
- Configuration migration, from
css.colorDecorators.enable
to"[css]": { "editor.colorDecorators": true }
. - Maybe need a new API to ask extensions for which range of document are allowed to show inline decorators and what's the proper value they stand for.
#2 will make it pretty similar to what we already have. So my take here is
DocumentColorProvider
is for Color related features, including Color Picker, inline Color Decorator and even more in the future.- Give the decision to extensions: show inline Color Decorator or not, show Color Picker as Hoever or Peek, etc. Extensions decide what kind of settings they want to expose to users.
Look forward to your comments.
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.
Give the decision to extensions:
Disagree, we control the UI and the extensions just provide the data. I think a core experience of our editor is that it always behaves the same, no matter in what language you are coding.
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.
I'd go with a simple user setting for now, which can easily be language scoped, and wait for users requesting the very specific I want color boxes here but not there request. We can always add that later.
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.
I'm convinced of a core experience of our editor is that it always behaves the same
. I only have one question
we control the UI and the extensions just provide the data
Is it reasonable that the provider provides view state? AFAIK, we already did that in TreeDataProvider, which feeds us TreeItem
and TreeItem
has a view state collapsibleState
(whether it's collapsed or expanded). In our case, renderDecorator
decides the visibility of the inline color decorator. @jrieken thoughts?
Talked with @kieferrm about this and we thought adding a separate option for controlling the visibility of color decorator makes things more complex. Inline Color Box relies on Color Range, Color Range is controlled by extensions, allowing users to disable color box but no way to disable color picker seems weird. So we decided to keep the API clean:
If ppl think we should separate these two features, then we add options in the future. FYI @aeschli , I removed the color box decorations and use the new API instead. |
Do we really need a |
@joaomoreno Besides, if we listen to configuration change internally and ask for color ranges each time we receive a configuration change, |
Latest commit already covered Monaco API and what we discussed in #32235 (comment) . Speaking of Monaco API, one blocker is #32470. I already pushed a fix for it and let's see if that works perfectly. |
I don't understand why we'd need to keep JSON and CSS extension color-related settings. All color settings should be in core, and they should be customizable per language using scoping. JSON and CSS need to drop their own settings. The core should listen on the configuration change and, depending on its value, ask the providers to give it colors. |
+1 on Joaos suggestion. A new |
@rebornix I'm also looking to having the actual colors value (r/g/b) provided by the language server. That way we can get rid of the color parsing/convertion code in the client and can remove the Color.fromHex API. Let me know if I should wait for your change or if I should go ahead on the current state. |
The latest code change removes the onDidChange event, add new option
@aeschli feel free to make changes, no need to wait for this PR but I think it's pretty close to merge. This PR won't cover the Color Format discussion @joaomoreno |
Have the PR merged first, Monaco API will be marked as |
Fix #32295. Move inline color boxes rendering to core/contrib as we already ask for color ranges.
This adds a new option
renderDecorator
to color range, which decides whether we should render inline box for a color range. cc @jrieken @joaomoreno