mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 20:13:32 +01:00
Fixes #84695 - codicons in hovers
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user