gdscript: allow color picking#990
Open
paul-marechal wants to merge 4 commits intogodotengine:masterfrom
Open
Conversation
Author
|
Ideally this information should come from Godot itself through LSP? I had a lot of pain trying to implement an ad-hoc way of parsing expressions to allow editing arguments in place as I felt like this was a desirable behavior (being a user of the extension myself)... But honestly the code required to allow for this is a bit much so I'd understand if we'd want to scrap it. |
327faf4 to
c8b32f7
Compare
Collaborator
|
This looks good! I had starting building this feature last year but I got bogged down in supporting all the color formats and never finished it. Give me a chance to play with this but I like what I see. |
Implement `DocumentColorProvider` by extracting Color expressions, interpreting them, and replacing arguments in place when possible.
The idea is to break the potentially expensive for-loops to potentially catch cancellation requests. After some reading `setImmediate` should be better suited for this than `await Promise.resolve()`
c8b32f7 to
8a38f54
Compare
Author
|
Cleaned up a little and rebased on master. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement
DocumentColorProviderby extracting Color expressions, interpreting them, and replacing arguments in place when possible.Add the following configurations:
godotTools.colorPicker.precision: Controls how many decimals to include when applying edits.godotTools.colorPicker.padValues: Whether or not to pad decimal numbers.godotTools.colorPicker.uppercaseHex: Whether or not to write hexadecimals in uppercase when applying edits.It should now be possible to get a preview of the color expressed by common Color methods, as well as pick and choose from a color palette provided by VS Code.
Only static expressions are evaluated, if you use a variable as one of the parameters then it will be ignored.
Color constant expressions are considered "readonly": The palette will show but provide no edits.
Test file:
Illustration:
