提交 a7d9853f 编写于 作者: R Rob Lourens

Settings editor - better setting link format, write all enum values when one has an enumDescription

上级 7637cec0
......@@ -282,19 +282,19 @@ const editorConfiguration: IConfigurationNode = {
'type': 'number',
'default': EDITOR_MODEL_DEFAULTS.tabSize,
'minimum': 1,
'description': nls.localize('tabSize', "The number of spaces a tab is equal to. This setting is overridden based on the file contents when [`editor.detectIndentation`](#editor.detectIndentation) is on."),
'description': nls.localize('tabSize', "The number of spaces a tab is equal to. This setting is overridden based on the file contents when `#editor.detectIndentation#` is on."),
'errorMessage': nls.localize('tabSize.errorMessage', "Expected 'number'. Note that the value \"auto\" has been replaced by the `editor.detectIndentation` setting.")
},
'editor.insertSpaces': {
'type': 'boolean',
'default': EDITOR_MODEL_DEFAULTS.insertSpaces,
'description': nls.localize('insertSpaces', "Insert spaces when pressing Tab. This setting is overridden based on the file contents when [`editor.detectIndentation`](#editor.detectIndentation) is on."),
'description': nls.localize('insertSpaces', "Insert spaces when pressing Tab. This setting is overridden based on the file contents when `#editor.detectIndentation#` is on."),
'errorMessage': nls.localize('insertSpaces.errorMessage', "Expected 'boolean'. Note that the value \"auto\" has been replaced by the `editor.detectIndentation` setting.")
},
'editor.detectIndentation': {
'type': 'boolean',
'default': EDITOR_MODEL_DEFAULTS.detectIndentation,
'description': nls.localize('detectIndentation', "When opening a file, [`editor.tabSize`](#editor.tabSize) and [`editor.insertSpaces`](#editor.insertSpaces) will be detected based on the file contents.")
'description': nls.localize('detectIndentation', "When opening a file, `#editor.tabSize#` and `#editor.insertSpaces#` will be detected based on the file contents.")
},
'editor.roundedSelection': {
'type': 'boolean',
......@@ -385,14 +385,14 @@ const editorConfiguration: IConfigurationNode = {
comment: [
'- `editor.wordWrapColumn` refers to a different setting and should not be localized.'
]
}, "Lines will wrap at `editor.wordWrapColumn`."),
}, "Lines will wrap at `#editor.wordWrapColumn#`."),
nls.localize({
key: 'wordWrap.bounded',
comment: [
'- viewport means the edge of the visible window size.',
'- `editor.wordWrapColumn` refers to a different setting and should not be localized.'
]
}, "Lines will wrap at the minimum of viewport and `editor.wordWrapColumn`."),
}, "Lines will wrap at the minimum of viewport and `#editor.wordWrapColumn#`."),
],
'default': EDITOR_DEFAULTS.wordWrap,
'description': nls.localize({
......@@ -413,7 +413,7 @@ const editorConfiguration: IConfigurationNode = {
'- `editor.wordWrap` refers to a different setting and should not be localized.',
'- \'wordWrapColumn\' and \'bounded\' refer to values the different setting can take and should not be localized.'
]
}, "Controls the wrapping column of the editor when [`editor.wordWrap`](#editor.wordWrap) is `wordWrapColumn` or `bounded`.")
}, "Controls the wrapping column of the editor when `#editor.wordWrap#` is `wordWrapColumn` or `bounded`.")
},
'editor.wrappingIndent': {
'type': 'string',
......@@ -618,7 +618,7 @@ const editorConfiguration: IConfigurationNode = {
'editor.cursorWidth': {
'type': 'integer',
'default': EDITOR_DEFAULTS.viewInfo.cursorWidth,
'description': nls.localize('cursorWidth', "Controls the width of the cursor when [`editor.cursorStyle`](#editor.cursorStyle) is set to `line`.")
'description': nls.localize('cursorWidth', "Controls the width of the cursor when `#editor.cursorStyle#` is set to `line`.")
},
'editor.fontLigatures': {
'type': 'boolean',
......
......@@ -246,7 +246,7 @@ configurationRegistry.registerConfiguration({
'enum': [AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE],
'enumDescriptions': [
nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.off' }, "A dirty file is never automatically saved."),
nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.afterDelay' }, "A dirty file is automatically saved after the configured [`files.autoSaveDelay`](#files.autoSaveDelay)."),
nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.afterDelay' }, "A dirty file is automatically saved after the configured `#files.autoSaveDelay#`."),
nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.onFocusChange' }, "A dirty file is automatically saved when the editor loses focus."),
nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.onWindowChange' }, "A dirty file is automatically saved when the window loses focus.")
],
......@@ -256,7 +256,7 @@ configurationRegistry.registerConfiguration({
'files.autoSaveDelay': {
'type': 'number',
'default': 1000,
'description': nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'autoSaveDelay' }, "Controls the delay in ms after which a dirty file is saved automatically. Only applies when [`files.autoSave`](#files.autoSave) is set to `{0}`.", AutoSaveConfiguration.AFTER_DELAY)
'description': nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'autoSaveDelay' }, "Controls the delay in ms after which a dirty file is saved automatically. Only applies when `#files.autoSave#` is set to `{0}`.", AutoSaveConfiguration.AFTER_DELAY)
},
'files.watcherExclude': {
'type': 'object',
......
......@@ -847,13 +847,20 @@ export class SettingsRenderer implements IRenderer {
template.labelElement.textContent = element.displayLabel;
template.labelElement.title = titleTooltip;
const enumDescriptionText = element.setting.enumDescriptions && element.setting.enum && element.setting.enum.length < SettingsRenderer.MAX_ENUM_DESCRIPTIONS ?
'\n' + element.setting.enumDescriptions
.map((desc, i) => desc && ` - \`${element.setting.enum[i]}\`: ${desc}`)
let enumDescriptionText = '';
if (element.setting.enumDescriptions && element.setting.enum && element.setting.enum.length < SettingsRenderer.MAX_ENUM_DESCRIPTIONS) {
enumDescriptionText = '\n' + element.setting.enumDescriptions
.map((desc, i) => desc ?
` - \`${element.setting.enum[i]}\` :
${desc}` : ` - \`${element.setting.enum[i]}\``)
.filter(desc => !!desc)
.join('\n') :
'';
const descriptionText = element.description + enumDescriptionText;
.join('\n');
}
// Rewrite `#editor.fontSize#` to link format
const descriptionText = (element.description + enumDescriptionText)
.replace(/`#(.*)#`/g, (match, settingName) => `[\`${settingName}\`](#${settingName})`);
const renderedDescription = renderMarkdown({ value: descriptionText }, {
actionHandler: {
callback: (content: string) => {
......
......@@ -137,7 +137,7 @@ configurationRegistry.registerConfiguration({
default: true
},
'terminal.integrated.fontFamily': {
description: nls.localize('terminal.integrated.fontFamily', "Controls the font family of the terminal, this defaults to [`editor.fontFamily`](#editor.fontFamily)'s value."),
description: nls.localize('terminal.integrated.fontFamily', "Controls the font family of the terminal, this defaults to `#editor.fontFamily#`'s value."),
type: 'string'
},
// TODO: Support font ligatures
......
......@@ -849,22 +849,8 @@ class SettingsContentBuilder {
private pushSetting(setting: ISetting, indent: string): void {
const settingStart = this.lineCountWithOffset + 1;
setting.descriptionRanges = [];
const descriptionPreValue = indent + '// ';
for (const line of setting.description) {
this._contentByLines.push(descriptionPreValue + line);
setting.descriptionRanges.push({ startLineNumber: this.lineCountWithOffset, startColumn: this.lastLine.indexOf(line) + 1, endLineNumber: this.lineCountWithOffset, endColumn: this.lastLine.length });
}
if (setting.enumDescriptions && setting.enumDescriptions.some(desc => !!desc)) {
setting.enumDescriptions.forEach((desc, i) => {
if (desc) {
this._contentByLines.push(` // - ${setting.enum[i]}: ${desc}`);
} else {
this._contentByLines.push(` // - ${setting.enum[i]}`);
}
});
}
this.pushSettingDescription(setting, indent);
let preValueConent = indent;
const keyString = JSON.stringify(setting.key);
......@@ -881,6 +867,30 @@ class SettingsContentBuilder {
setting.range = { startLineNumber: settingStart, startColumn: 1, endLineNumber: this.lineCountWithOffset, endColumn: this.lastLine.length };
}
private pushSettingDescription(setting: ISetting, indent: string): void {
setting.descriptionRanges = [];
const descriptionPreValue = indent + '// ';
for (let line of setting.description) {
// Remove setting link tag
line = line.replace(/`#(.*)#`/g, (match, settingName) => `\`${settingName}\``);
this._contentByLines.push(descriptionPreValue + line);
setting.descriptionRanges.push({ startLineNumber: this.lineCountWithOffset, startColumn: this.lastLine.indexOf(line) + 1, endLineNumber: this.lineCountWithOffset, endColumn: this.lastLine.length });
}
if (setting.enumDescriptions && setting.enumDescriptions.some(desc => !!desc)) {
setting.enumDescriptions.forEach((desc, i) => {
const line = desc ?
`${setting.enum[i]}: ${desc}` :
setting.enum[i];
this._contentByLines.push(` // - ${line}`);
setting.descriptionRanges.push({ startLineNumber: this.lineCountWithOffset, startColumn: this.lastLine.indexOf(line) + 1, endLineNumber: this.lineCountWithOffset, endColumn: this.lastLine.length });
});
}
}
private pushValue(setting: ISetting, preValueConent: string, indent: string): void {
let valueString = JSON.stringify(setting.value, null, indent);
if (valueString && (typeof setting.value === 'object')) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册