提交 8a07c8d9 编写于 作者: R Rob Lourens

Settings editor - fix setting key formatter, add test

上级 43f69550
......@@ -856,9 +856,9 @@ class ButtonRowRenderer implements IRenderer<IButtonRowEntry, IButtonRowTemplate
}
}
function settingKeyToDisplayFormat(key: string): { category: string, label: string } {
export function settingKeyToDisplayFormat(key: string): { category: string, label: string } {
let label = key
.replace(/\.([a-z])/, (match, p1) => `.${p1.toUpperCase()}`)
.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
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import { settingKeyToDisplayFormat } from 'vs/workbench/parts/preferences/browser/settingsEditor2';
suite('SettingsEditor', () => {
test('settingKeyToDisplayFormat', () => {
assert.deepEqual(
settingKeyToDisplayFormat('foo.bar'),
{
category: 'Foo',
label: 'Bar'
});
assert.deepEqual(
settingKeyToDisplayFormat('foo.bar.etc'),
{
category: 'Foo.Bar',
label: 'Etc'
});
assert.deepEqual(
settingKeyToDisplayFormat('fooBar.etcSomething'),
{
category: 'Foo Bar',
label: 'Etc Something'
});
assert.deepEqual(
settingKeyToDisplayFormat('foo'),
{
category: '',
label: 'Foo'
});
});
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册