vscode: Support languages.configuration.onEnterRules
and add OnEnterRule#previousLineText
#11225
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.
What it does
With this change, we read
languages.configuration.onEnterRules
defined via the package.json in a VS Code extension and pass them on to the language configuration for Monaco, which was previously only supported for programmatically added language configurations (#11202), and add support for the optional propertyOnEnterRule#previousLineText
in enter rules, which was missing before (#11131).Fixes #11202
Fixes #11131
Contributed on behalf of STMicroelectronics
How to test
The Theia example app includes the
vscode.python
extension, which defines the followingonEnterRules
in itspackage.json
.vscode.python
defines that hitting enter after e.g.if TRUE:
the next line should indent once:Before this change, the indentation didn't work:
After this change, the indentation should work:
To test
OnEnterRule#previousLineText
, we can add the following rule toplugins/vscode.python/extension/language-configuration.json
and restart the Theia backend:After that the
previousLineText
should be considered as follows:Finally, it'd be good to very that programmatically defined enter rules are still working as expected, which can be verified e.g. with an HTML file in the Theia example app:
Review checklist
Reminder for reviewers