Fixes #84695 - codicons in hovers

This commit is contained in:
Eric Amodio
2019-12-11 13:13:34 -05:00
parent cc70266d04
commit 7bb8b0084f
15 changed files with 271 additions and 71 deletions

View File

@@ -309,7 +309,7 @@ export namespace MarkdownString {
}
export function to(value: htmlContent.IMarkdownString): vscode.MarkdownString {
return new htmlContent.MarkdownString(value.value, value.isTrusted);
return new htmlContent.MarkdownString(value.value, { isTrusted: value.isTrusted, supportThemeIcons: value.supportThemeIcons });
}
export function fromStrict(value: string | types.MarkdownString): undefined | string | htmlContent.IMarkdownString {

View File

@@ -14,6 +14,7 @@ import { generateUuid } from 'vs/base/common/uuid';
import * as vscode from 'vscode';
import { FileSystemProviderErrorCode, markAsFileSystemProviderError } from 'vs/platform/files/common/files';
import { RemoteAuthorityResolverErrorCode } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { markdownUnescapeCodicons, escapeCodicons } from 'vs/base/common/codicons';
function es5ClassCompat(target: Function): any {
///@ts-ignore
@@ -1231,21 +1232,26 @@ export class MarkdownString {
value: string;
isTrusted?: boolean;
readonly supportThemeIcons?: boolean;
constructor(value?: string) {
this.value = value || '';
constructor(value?: string, { supportThemeIcons }: { supportThemeIcons?: boolean } = {}) {
this.value = value ?? '';
this.supportThemeIcons = supportThemeIcons ?? false;
}
appendText(value: string): MarkdownString {
// escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
this.value += value
value = value
.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&')
.replace('\n', '\n\n');
this.value += this.supportThemeIcons ? markdownUnescapeCodicons(value) : value;
return this;
}
appendMarkdown(value: string): MarkdownString {
this.value += value;
return this;
}
@@ -1257,6 +1263,10 @@ export class MarkdownString {
this.value += '\n```\n';
return this;
}
static escapeThemeIcons(value: string): string {
return escapeCodicons(value);
}
}
@es5ClassCompat