Playground: Add Copy as pyproject.toml/ruff.toml and paste from TOML #13328
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.
Summary
This PR extends our playground so that you can paste a
pyproject.toml
orruff.toml
configuration into the settings panel andit automatically converts it to the JSON configuration.
This PR also adds a Copy as pyproject.toml and Copy as ruff.toml action that converts the JSON configuration to a TOML confguration.
The motivation for extending the playground is that it makes it easier to try out configurations provided by users and to share configurations verified in the playground in a format that's familiar to users.
I considered changing the settings a TOML file instead. However, monaco has no autocompletion or schema support for TOML files, which means that switching to TOML would lead to a worse overall editing experience.
The pasting could be "nicer" because the implementation let's monaco handle the paste and then replaces the pasted content if it is a TOML setting.
Users can see how the content change. I spent quiet a bit of time trying to figure out if there's a more official way of handling
pasting from the clip board in monaco and customizing the behavior by either overriding the standard paste operation or
adding a cutom paste action but was unsuccessful. That's why I ultimately went with the solution in this PR.
Test Plan
Screen.Recording.2024-09-11.at.14.47.42.mov