Skip to content

Commit

Permalink
Add markdownDeprecationMessage
Browse files Browse the repository at this point in the history
Fix bug with search + clicking setting name links
Fix #91618
  • Loading branch information
roblourens committed Apr 27, 2020
1 parent 6220e2b commit 0778354
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 28 deletions.
23 changes: 12 additions & 11 deletions src/vs/base/common/jsonSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,18 @@ export interface IJSONSchema {
then?: IJSONSchema;
else?: IJSONSchema;

// VSCode extensions
defaultSnippets?: IJSONSchemaSnippet[]; // VSCode extension
errorMessage?: string; // VSCode extension
patternErrorMessage?: string; // VSCode extension
deprecationMessage?: string; // VSCode extension
enumDescriptions?: string[]; // VSCode extension
markdownEnumDescriptions?: string[]; // VSCode extension
markdownDescription?: string; // VSCode extension
doNotSuggest?: boolean; // VSCode extension
allowComments?: boolean; // VSCode extension
allowTrailingCommas?: boolean; // VSCode extension
// VS Code extensions
defaultSnippets?: IJSONSchemaSnippet[];
errorMessage?: string;
patternErrorMessage?: string;
deprecationMessage?: string;
markdownDeprecationMessage?: string;
enumDescriptions?: string[];
markdownEnumDescriptions?: string[];
markdownDescription?: string;
doNotSuggest?: boolean;
allowComments?: boolean;
allowTrailingCommas?: boolean;
}

export interface IJSONSchemaMap {
Expand Down
14 changes: 7 additions & 7 deletions src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,14 @@ export class SettingsEditor2 extends BaseEditor {
private onDidClickSetting(evt: ISettingLinkClickEvent, recursed?: boolean): void {
const elements = this.currentSettingsModel.getElementsByName(evt.targetKey);
if (elements && elements[0]) {
let sourceTop = this.settingsTree.getRelativeTop(evt.source);
if (typeof sourceTop !== 'number') {
return;
}

if (sourceTop < 0) {
let sourceTop = 0.5;
try {
const _sourceTop = this.settingsTree.getRelativeTop(evt.source);
if (_sourceTop !== null) {
sourceTop = _sourceTop;
}
} catch {
// e.g. clicked a searched element, now the search has been cleared
sourceTop = 0.5;
}

this.settingsTree.reveal(elements[0], sourceTop);
Expand Down
15 changes: 11 additions & 4 deletions src/vs/workbench/contrib/preferences/browser/settingsTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,14 @@ export abstract class AbstractSettingRenderer extends Disposable implements ITre

const onChange = (value: any) => this._onDidChangeSetting.fire({ key: element.setting.key, value, type: template.context!.valueType });
const deprecationText = element.setting.deprecationMessage || '';
template.deprecationWarningElement.innerText = deprecationText;
if (deprecationText && element.setting.deprecationMessageIsMarkdown) {
const disposables = new DisposableStore();
template.elementDisposables.add(disposables);
template.deprecationWarningElement.innerHTML = '';
template.deprecationWarningElement.appendChild(this.renderSettingMarkdown(element, element.setting.deprecationMessage!, template.elementDisposables));
} else {
template.deprecationWarningElement.innerText = deprecationText;
}
DOM.toggleClass(template.containerElement, 'is-deprecated', !!deprecationText);

this.renderValue(element, <ISettingItemTemplate>template, onChange);
Expand All @@ -524,7 +531,7 @@ export abstract class AbstractSettingRenderer extends Disposable implements ITre
}));
}

private renderDescriptionMarkdown(element: SettingsTreeSettingElement, text: string, disposeables: DisposableStore): HTMLElement {
private renderSettingMarkdown(element: SettingsTreeSettingElement, text: string, disposeables: DisposableStore): HTMLElement {
// Rewrite `#editor.fontSize#` to link format
text = fixSettingLinks(text);

Expand All @@ -545,7 +552,7 @@ export abstract class AbstractSettingRenderer extends Disposable implements ITre
}
});

renderedMarkdown.classList.add('setting-item-description-markdown');
renderedMarkdown.classList.add('setting-item-markdown');
cleanRenderedMarkdown(renderedMarkdown);
return renderedMarkdown;
}
Expand Down Expand Up @@ -615,7 +622,7 @@ export abstract class AbstractSettingRenderer extends Disposable implements ITre

disposeElement(_element: ITreeNode<SettingsTreeElement>, _index: number, template: IDisposableTemplate, _height: number | undefined): void {
if ((template as ISettingItemTemplate).elementDisposables) {
dispose((template as ISettingItemTemplate).elementDisposables);
(template as ISettingItemTemplate).elementDisposables.clear();
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/vs/workbench/contrib/preferences/browser/settingsWidgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ registerThemingParticipant((theme: IColorTheme, collector: ICssStyleCollector) =

const link = theme.getColor(textLinkForeground);
if (link) {
collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .setting-item-contents .setting-item-description-markdown a { color: ${link}; }`);
collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .setting-item-contents .setting-item-description-markdown a > code { color: ${link}; }`);
collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .setting-item-contents .setting-item-markdown a { color: ${link}; }`);
collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .setting-item-contents .setting-item-markdown a > code { color: ${link}; }`);
collector.addRule(`.monaco-select-box-dropdown-container > .select-box-details-pane > .select-box-description-markdown a { color: ${link}; }`);
collector.addRule(`.monaco-select-box-dropdown-container > .select-box-details-pane > .select-box-description-markdown a > code { color: ${link}; }`);
}

const activeLink = theme.getColor(textLinkActiveForeground);
if (activeLink) {
collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .setting-item-contents .setting-item-description-markdown a:hover, .settings-editor > .settings-body > .settings-tree-container .setting-item-contents .setting-item-description-markdown a:active { color: ${activeLink}; }`);
collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .setting-item-contents .setting-item-description-markdown a:hover > code, .settings-editor > .settings-body > .settings-tree-container .setting-item-contents .setting-item-description-markdown a:active > code { color: ${activeLink}; }`);
collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .setting-item-contents .setting-item-markdown a:hover, .settings-editor > .settings-body > .settings-tree-container .setting-item-contents .setting-item-markdown a:active { color: ${activeLink}; }`);
collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .setting-item-contents .setting-item-markdown a:hover > code, .settings-editor > .settings-body > .settings-tree-container .setting-item-contents .setting-item-markdown a:active > code { color: ${activeLink}; }`);
collector.addRule(`.monaco-select-box-dropdown-container > .select-box-details-pane > .select-box-description-markdown a:hover, .monaco-select-box-dropdown-container > .select-box-details-pane > .select-box-description-markdown a:active { color: ${activeLink}; }`);
collector.addRule(`.monaco-select-box-dropdown-container > .select-box-details-pane > .select-box-description-markdown a:hover > code, .monaco-select-box-dropdown-container > .select-box-details-pane > .select-box-description-markdown a:active > code { color: ${activeLink}; }`);
}
Expand Down Expand Up @@ -126,7 +126,7 @@ registerThemingParticipant((theme: IColorTheme, collector: ICssStyleCollector) =

const codeTextForegroundColor = theme.getColor(textPreformatForeground);
if (codeTextForegroundColor) {
collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-description-markdown code { color: ${codeTextForegroundColor} }`);
collector.addRule(`.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-markdown code { color: ${codeTextForegroundColor} }`);
collector.addRule(`.monaco-select-box-dropdown-container > .select-box-details-pane > .select-box-description-markdown code { color: ${codeTextForegroundColor} }`);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface ISetting {
overrides?: ISetting[];
overrideOf?: ISetting;
deprecationMessage?: string;
deprecationMessageIsMarkdown?: boolean;

scope?: ConfigurationScope;
type?: string | string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,8 @@ export class DefaultSettings extends Disposable {
tags: prop.tags,
disallowSyncIgnore: prop.disallowSyncIgnore,
extensionInfo: extensionInfo,
deprecationMessage: prop.deprecationMessage,
deprecationMessage: prop.deprecationMessage || prop.markdownDeprecationMessage,
deprecationMessageIsMarkdown: !prop.deprecationMessage,
validator: createValidator(prop)
});
}
Expand Down

0 comments on commit 0778354

Please sign in to comment.