Skip to content

Commit

Permalink
Settings editor - fix extension category prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Jul 31, 2018
1 parent e466293 commit 0001469
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/vs/workbench/parts/preferences/browser/settingsTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,17 +402,18 @@ export class SettingsDataSource implements IDataSource {
}

export function settingKeyToDisplayFormat(key: string, groupId = ''): { category: string, label: string } {
let label = wordifyKey(key);
const lastDotIdx = label.lastIndexOf('.');
const lastDotIdx = key.lastIndexOf('.');
let category = '';
if (lastDotIdx >= 0) {
category = label.substr(0, lastDotIdx);
label = label.substr(lastDotIdx + 1);
category = key.substr(0, lastDotIdx);
key = key.substr(lastDotIdx + 1);
}

groupId = wordifyKey(groupId.replace(/\//g, '.'));
groupId = groupId.replace(/\//g, '.');
category = trimCategoryForGroup(category, groupId);
category = wordifyKey(category);

const label = wordifyKey(key);
return { category, label };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ suite('SettingsTree', () => {
label: 'Bar'
});

assert.deepEqual(
settingKeyToDisplayFormat('disableligatures.ligatures', 'disableligatures'),
{
category: '',
label: 'Ligatures'
});

assert.deepEqual(
settingKeyToDisplayFormat('foo.bar.etc', 'foo'),
{
Expand All @@ -62,14 +69,14 @@ suite('SettingsTree', () => {
});

assert.deepEqual(
settingKeyToDisplayFormat('foo.bar.etc', 'foo.bar'),
settingKeyToDisplayFormat('foo.bar.etc', 'foo/bar'),
{
category: '',
label: 'Etc'
});

assert.deepEqual(
settingKeyToDisplayFormat('foo.bar.etc', 'something.foo'),
settingKeyToDisplayFormat('foo.bar.etc', 'something/foo'),
{
category: 'Bar',
label: 'Etc'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ configurationExtPoint.setHandler(extensions => {

validateProperties(configuration, extension);

configuration.id = node.id || extension.description.uuid || extension.description.id;
configuration.id = node.id || extension.description.id || extension.description.uuid;
configuration.contributedByExtension = true;
configuration.title = configuration.title || extension.description.displayName || extension.description.id;
configurations.push(configuration);
Expand Down

0 comments on commit 0001469

Please sign in to comment.