-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Allow multiple languages in settings key #135368
Allow multiple languages in settings key #135368
Conversation
Based on the test already used for checking language specific settings I suggest adding this test to check if the latest: test('parse multiple resource languages settings override', () => {
const testObject = new ConfigurationModelParser('settings');
testObject.parse(JSON.stringify({ '[json, javascript]': { 'FolderSettingsModelParser.resource': 'resource', 'FolderSettingsModelParser.resourceLanguage': 'resourceLanguage' }, '[json]': { 'FolderSettingsModelParser.resourceLanguage': 'overrideResourceLanguage' } }), { scopes: [ConfigurationScope.RESOURCE, ConfigurationScope.LANGUAGE_OVERRIDABLE] });
const expected_json = Object.create(null);
expected_json['FolderSettingsModelParser'] = Object.create(null);
expected_json['FolderSettingsModelParser']['resource'] = 'resource';
expected_json['FolderSettingsModelParser']['resourceLanguage'] = 'overrideResourceLanguage';
const expected_javascript = Object.create(null);
expected_javascript['FolderSettingsModelParser'] = Object.create(null);
expected_javascript['FolderSettingsModelParser']['resource'] = 'resource';
expected_javascript['FolderSettingsModelParser']['resourceLanguage'] = 'resourceLanguage';
assert.deepStrictEqual(testObject.configurationModel.overrides, [{ 'contents': expected_json, 'identifiers': ['json'], 'keys': ['FolderSettingsModelParser.resource', 'FolderSettingsModelParser.resourceLanguage'] }, { 'contents': expected_javascript, 'identifiers': ['javascript'], 'keys': ['FolderSettingsModelParser.resource', 'FolderSettingsModelParser.resourceLanguage'] }]);
}); This does probably require that Also note that it seems the data structure was built to accommodate multiple language identifiers per override. ( (Test based on:) vscode/src/vs/workbench/services/configuration/test/common/configurationModels.test.ts Lines 74 to 84 in 423f89b
|
I know nothing about the inner workings of VScode and I was only looking at this PR because it seams like an awesome feature. But isn't the variable |
1 similar comment
I know nothing about the inner workings of VScode and I was only looking at this PR because it seams like an awesome feature. But isn't the variable |
Indeed it is. I fixed one such misspelling already but this one has seemed to have escaped me. This is the largest project I have ever contributed to and its a little confusing finding what I'm looking for. It Will be fixed next commit |
Thanks for your interest in supporting this feature and providing a PR. I see that it is not completely implemented and there are some open questions like how to support writing into multiple languages key programatically. I assume it is not as trivial as changing a string type to string array type and adopting it every where. I am planning to support this feature in this milestone (November 2021). Since it is not simple it might be time taking to get this feature contributed. Edit: So, I would build on top of your PR and finish this feature. Thanks for understanding. |
Sorry i have been a little inactive. Between crunch at work and very little free time in general it has had to take a back seat. some of the changes have already been added and the unit test was added although my logic was flawed and I decided to figure out what the ideal implementation would be. Since this has taken too long I understand if you want to just take over from here. However I am still very keen to keep working on it even if its not full time. Hoping I can help a little more than I already have |
b39e0b3
to
08b0de2
Compare
Thanks for offering help. I have already pushed some changes/refactorings which make it easy to implement this feature. I will be finishing the implementation today with tests and also taking care of most of the other gaps. Since changes are going orthogonal, I would like to close this PR. Again, thanks for the interest and help. |
This PR fixes #51935. Allowing for a single definition for multiple different languages is going to eliminate unnecessary config duplication.
vs
Unfortunately, I haven't been able to do extensive testing due to having troubles getting a dev environment up and running but the unit tests in place right now are still succeeding.
A few items that still need doing:
Any feedback is welcome 🙂