mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:04:14 +08:00
This commit is contained in:
parent
af5c09a10c
commit
c7e849f9be
@ -343,7 +343,7 @@ export namespace MarkdownString {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function fromStrict(value: string | types.MarkdownString): undefined | string | htmlContent.IMarkdownString {
|
||||
export function fromStrict(value: string | vscode.MarkdownString): undefined | string | htmlContent.IMarkdownString {
|
||||
if (!value) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -1276,7 +1276,9 @@ export class CodeLens {
|
||||
}
|
||||
|
||||
@es5ClassCompat
|
||||
export class MarkdownString extends BaseMarkdownString implements vscode.MarkdownString {
|
||||
export class MarkdownString implements vscode.MarkdownString {
|
||||
|
||||
readonly #delegate: BaseMarkdownString;
|
||||
|
||||
static isMarkdownString(thing: any): thing is vscode.MarkdownString {
|
||||
if (thing instanceof MarkdownString) {
|
||||
@ -1286,18 +1288,53 @@ export class MarkdownString extends BaseMarkdownString implements vscode.Markdow
|
||||
}
|
||||
|
||||
constructor(value?: string, supportThemeIcons: boolean = false) {
|
||||
super(value ?? '', { supportThemeIcons });
|
||||
this.#delegate = new BaseMarkdownString(value, { supportThemeIcons });
|
||||
}
|
||||
|
||||
get value(): string {
|
||||
return this.#delegate.value;
|
||||
}
|
||||
set value(value: string) {
|
||||
this.#delegate.value = value;
|
||||
}
|
||||
|
||||
get isTrusted(): boolean | undefined {
|
||||
return this.#delegate.isTrusted;
|
||||
}
|
||||
|
||||
set isTrusted(value: boolean | undefined) {
|
||||
this.#delegate.isTrusted = value;
|
||||
}
|
||||
|
||||
get supportThemeIcons(): boolean | undefined {
|
||||
return this.#delegate.supportThemeIcons;
|
||||
}
|
||||
|
||||
appendText(value: string): vscode.MarkdownString {
|
||||
this.#delegate.appendText(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
appendMarkdown(value: string): vscode.MarkdownString {
|
||||
this.#delegate.appendMarkdown(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
appendCodeblock(value: string, language?: string): vscode.MarkdownString {
|
||||
this.#delegate.appendCodeblock(language ?? '', value);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@es5ClassCompat
|
||||
export class ParameterInformation {
|
||||
|
||||
label: string | [number, number];
|
||||
documentation?: string | MarkdownString;
|
||||
documentation?: string | vscode.MarkdownString;
|
||||
|
||||
constructor(label: string | [number, number], documentation?: string | MarkdownString) {
|
||||
constructor(label: string | [number, number], documentation?: string | vscode.MarkdownString) {
|
||||
this.label = label;
|
||||
this.documentation = documentation;
|
||||
}
|
||||
@ -1307,11 +1344,11 @@ export class ParameterInformation {
|
||||
export class SignatureInformation {
|
||||
|
||||
label: string;
|
||||
documentation?: string | MarkdownString;
|
||||
documentation?: string | vscode.MarkdownString;
|
||||
parameters: ParameterInformation[];
|
||||
activeParameter?: number;
|
||||
|
||||
constructor(label: string, documentation?: string | MarkdownString) {
|
||||
constructor(label: string, documentation?: string | vscode.MarkdownString) {
|
||||
this.label = label;
|
||||
this.documentation = documentation;
|
||||
this.parameters = [];
|
||||
@ -1397,7 +1434,7 @@ export class CompletionItem implements vscode.CompletionItem {
|
||||
kind?: CompletionItemKind;
|
||||
tags?: CompletionItemTag[];
|
||||
detail?: string;
|
||||
documentation?: string | MarkdownString;
|
||||
documentation?: string | vscode.MarkdownString;
|
||||
sortText?: string;
|
||||
filterText?: string;
|
||||
preselect?: boolean;
|
||||
|
||||
@ -642,4 +642,10 @@ suite('ExtHostTypes', function () {
|
||||
1, 0, 3, 3, (1 << 2) | (1 << 4)
|
||||
]);
|
||||
});
|
||||
|
||||
test('Markdown codeblock rendering is swapped #111604', function () {
|
||||
const md = new types.MarkdownString().appendCodeblock('<img src=0 onerror="alert(1)">', 'html');
|
||||
assert.deepEqual(md.value, '\n```html\n<img src=0 onerror="alert(1)">\n```\n');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user