Skip to content

Commit 6689cb8

Browse files
committed
Enable markdown alert syntax in PR comments
1 parent f4b2b24 commit 6689cb8

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"contribShareMenu",
3131
"diffCommand",
3232
"languageModelToolResultAudience",
33+
"markdownAlertSyntax",
3334
"quickDiffProvider",
3435
"remoteCodingAgents",
3536
"shareProvider",
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
declare module 'vscode' {
7+
8+
// @kycutler https://github.com/microsoft/vscode/issues/209652
9+
10+
export interface MarkdownString {
11+
12+
/**
13+
* Indicates that this markdown string can contain alert syntax. Defaults to `false`.
14+
*
15+
* When `supportAlertSyntax` is true, the markdown renderer will parse GitHub-style alert syntax:
16+
*
17+
* ```markdown
18+
* > [!NOTE]
19+
* > This is a note alert
20+
*
21+
* > [!WARNING]
22+
* > This is a warning alert
23+
* ```
24+
*
25+
* Supported alert types: `NOTE`, `TIP`, `IMPORTANT`, `WARNING`, `CAUTION`.
26+
*/
27+
supportAlertSyntax?: boolean;
28+
}
29+
}

src/github/prComment.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ export class TemporaryComment extends CommentBase {
190190
}
191191

192192
get body(): string | vscode.MarkdownString {
193-
return new vscode.MarkdownString(this.input);
193+
const s = new vscode.MarkdownString(this.input);
194+
s.supportAlertSyntax = true;
195+
return s;
194196
}
195197

196198
get author(): vscode.CommentAuthorInformation {
@@ -477,11 +479,15 @@ ${lineContents}
477479
if (this.mode === vscode.CommentMode.Editing) {
478480
return this._rawBody;
479481
}
480-
return new vscode.MarkdownString(this.replacedBody);
482+
const s = new vscode.MarkdownString(this.replacedBody);
483+
s.supportAlertSyntax = true;
484+
return s;
481485
}
482486

483487
protected getCancelEditBody() {
484-
return new vscode.MarkdownString(this.rawComment.body);
488+
const s = new vscode.MarkdownString(this.rawComment.body);
489+
s.supportAlertSyntax = true;
490+
return s;
485491
}
486492
}
487493

0 commit comments

Comments
 (0)