Skip to content
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

Validate Preferences Used in Editor #10607

Merged
merged 8 commits into from
Feb 23, 2022

Conversation

colin-grant-work
Copy link
Contributor

@colin-grant-work colin-grant-work commented Jan 8, 2022

What it does

Fixes #10599 by adding a service to validate preference values used by Monaco.
Fixes #10678 by modifying the conditions for emitting events and the affects method of PreferenceProxies

It also improves the typing of JSON schemas and fixes some minor issues related to those typings.

How to test

  1. start the application with theia as a workspace.
  2. open the dev console to view logs.
  3. open the settings.json file for the user or workspace scope.
  4. add "editor.tabSize": 2 if it doesn't already exist - the application should work fine.
  5. update the value to "editor.tabSize": "true".
  6. Observe that application continues working normally as though the preference were set to its default value. There should also be a warning in the console describing the problem and explaining what value is being used.

Review checklist

Reminder for reviewers

@colin-grant-work colin-grant-work added preferences issues related to preferences monaco issues related to monaco labels Jan 8, 2022
@colin-grant-work colin-grant-work marked this pull request as ready for review January 8, 2022 01:23
@colin-grant-work
Copy link
Contributor Author

@vince-fugnitto, would you mind taking a look at this? If desired, I can remove the changes related to JSON schema typing - it was convenient when writing the validation, but I think the only actual problems it detected were in the plugin task system, where we were using the taskType (e.g. 'npm') as the schema type, rather than 'object'.

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed that the changes address the problem where invalid preferences values would break the app. The framework is now robust where we validate preferences, and fallback properly when incorrect 👍 I really like the tests as well! :)

@colin-grant-work colin-grant-work force-pushed the bugfix/bad-pref-values-in-editor branch 2 times, most recently from 95f6c5d to 3282d49 Compare January 17, 2022 23:05
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed that #10599 is resolved with the latest changes 👍

@colin-grant-work colin-grant-work force-pushed the bugfix/bad-pref-values-in-editor branch 2 times, most recently from 9c14b79 to 3861155 Compare January 28, 2022 16:59
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes work well for me 👍

I confirmed that the preferences are now correctly validated (for example in the case they are manually edited), and if a type or value is invalid the preference will default back to it's default value.

image

I also confirmed that my previous observation of the multiple logs has been fixed and only one validation message is displayed in the console. The marker in the editor is also present.

@colin-grant-work colin-grant-work merged commit 9a02be6 into master Feb 23, 2022
@colin-grant-work colin-grant-work deleted the bugfix/bad-pref-values-in-editor branch February 23, 2022 17:04
@github-actions github-actions bot added this to the 1.23.0 milestone Feb 23, 2022
@colin-grant-work colin-grant-work mentioned this pull request Jun 3, 2022
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
monaco issues related to monaco preferences issues related to preferences
Projects
None yet
2 participants