diff --git a/src/vs/workbench/parts/preferences/browser/settingsLayout.ts b/src/vs/workbench/parts/preferences/browser/settingsLayout.ts index 0a8e55fb0d0a00667e5b0fdeeebc9c937d8f1468..8d9d234324805b48d9b1037578894fd2decaacb0 100644 --- a/src/vs/workbench/parts/preferences/browser/settingsLayout.ts +++ b/src/vs/workbench/parts/preferences/browser/settingsLayout.ts @@ -48,7 +48,7 @@ export const tocData: ITOCEntry = { settings: ['editor.format*'] }, { - id: 'editor/diff', + id: 'editor/diffEditor', label: 'Diff Editor', settings: ['diffEditor.*'] }, diff --git a/src/vs/workbench/parts/preferences/browser/settingsTree.ts b/src/vs/workbench/parts/preferences/browser/settingsTree.ts index b24e857cb9755cb0bd5bd72eabc80212e1830b26..2ed588ef10652c2811e19614317ab44d07c3f1c1 100644 --- a/src/vs/workbench/parts/preferences/browser/settingsTree.ts +++ b/src/vs/workbench/parts/preferences/browser/settingsTree.ts @@ -288,13 +288,7 @@ export class SettingsDataSource implements IDataSource { } export function settingKeyToDisplayFormat(key: string, groupId = ''): { category: string, label: string } { - groupId = groupId.replace(/\//g, '.'); - - let label = key - .replace(/\.([a-z])/g, (match, p1) => `.${p1.toUpperCase()}`) - .replace(/([a-z])([A-Z])/g, '$1 $2') // fooBar => foo Bar - .replace(/^[a-z]/g, match => match.toUpperCase()); // foo => Foo - + let label = wordifyKey(key); const lastDotIdx = label.lastIndexOf('.'); let category = ''; if (lastDotIdx >= 0) { @@ -302,12 +296,22 @@ export function settingKeyToDisplayFormat(key: string, groupId = ''): { category label = label.substr(lastDotIdx + 1); } + groupId = wordifyKey(groupId.replace(/\//g, '.')); category = trimCategoryForGroup(category, groupId); return { category, label }; } +function wordifyKey(key: string): string { + return key + .replace(/\.([a-z])/g, (match, p1) => `.${p1.toUpperCase()}`) + .replace(/([a-z])([A-Z])/g, '$1 $2') // fooBar => foo Bar + .replace(/^[a-z]/g, match => match.toUpperCase()); // foo => Foo +} + function trimCategoryForGroup(category: string, groupId: string): string { + // const categoryWithoutSpaces = category.replace(/ /g, ''); + const doTrim = forward => { const parts = groupId.split('.'); while (parts.length) { @@ -316,6 +320,10 @@ function trimCategoryForGroup(category: string, groupId: string): string { return category.replace(reg, ''); } + // if (reg.test(categoryWithoutSpaces)) { + // return categoryWithoutSpaces.replace(reg, ''); + // } + if (forward) { parts.pop(); } else { diff --git a/src/vs/workbench/parts/preferences/test/browser/settingsTree.test.ts b/src/vs/workbench/parts/preferences/test/browser/settingsTree.test.ts index 10d464bb99e4ca558b3dac4f1866853c97554f12..a1d32f71ac6cf392cabc4630a254c3e75fecd743 100644 --- a/src/vs/workbench/parts/preferences/test/browser/settingsTree.test.ts +++ b/src/vs/workbench/parts/preferences/test/browser/settingsTree.test.ts @@ -81,5 +81,20 @@ suite('SettingsTree', () => { category: '', label: 'Etc' }); + + assert.deepEqual( + settingKeyToDisplayFormat('fooBar.etc', 'fooBar'), + { + category: '', + label: 'Etc' + }); + + + assert.deepEqual( + settingKeyToDisplayFormat('fooBar.somethingElse.etc', 'fooBar'), + { + category: 'Something Else', + label: 'Etc' + }); }); }); \ No newline at end of file