@@ -215,27 +215,53 @@ export class GHPRComment extends CommentBase {
215215 contextValues . push ( 'canDelete' ) ;
216216 }
217217
218+ if ( this . suggestion ) {
219+ contextValues . push ( 'hasSuggestion' ) ;
220+ }
221+
218222 this . contextValue = contextValues . join ( ',' ) ;
219223 this . timestamp = new Date ( comment . createdAt ) ;
220224 }
221225
226+ get suggestion ( ) : string | undefined {
227+ const suggestionBody = this . rawComment . body . match ( / ` ` ` s u g g e s t i o n ( \n | \r \n ) ( .* ) ( \n | \r \n ) ` ` ` / ) ;
228+ if ( suggestionBody ?. length === 4 ) {
229+ return suggestionBody [ 2 ] ;
230+ }
231+ }
232+
222233 public commentEditId ( ) {
223234 return this . commentId ;
224235 }
225236
237+ private replaceSuggestion ( body : string ) {
238+ return body . replace ( / ` ` ` s u g g e s t i o n ( \n | \r \n ) ( .* ) ( \n | \r \n ) ` ` ` / , ( _substring : string , ...args : any [ ] ) => {
239+ return `***
240+ Suggested change:
241+ \`\`\`
242+ ${ args [ 1 ] }
243+ \`\`\`
244+ ***` ;
245+ } ) ;
246+ }
247+
226248 set body ( body : string | vscode . MarkdownString ) {
227249 this . _rawBody = body ;
228250 }
229251
230252 get body ( ) : string | vscode . MarkdownString {
231- if ( this . _rawBody instanceof vscode . MarkdownString ) {
253+ if ( this . mode === vscode . CommentMode . Editing ) {
232254 return this . _rawBody ;
233255 }
256+ if ( this . _rawBody instanceof vscode . MarkdownString ) {
257+ return new vscode . MarkdownString ( this . replaceSuggestion ( this . _rawBody . value ) ) ;
258+ }
234259 const linkified = this . _rawBody . replace ( / ( [ ^ \[ ] | ^ ) \@ ( [ ^ \s ] + ) / , ( substring ) => {
235260 const username = substring . substring ( substring . startsWith ( '@' ) ? 1 : 2 ) ;
236261 return `${ substring . startsWith ( '@' ) ? '' : substring . charAt ( 0 ) } [@${ username } ](${ path . dirname ( this . rawComment . user ! . url ) } /${ username } )` ;
237262 } ) ;
238- return new vscode . MarkdownString ( linkified ) ;
263+
264+ return new vscode . MarkdownString ( this . replaceSuggestion ( linkified ) ) ;
239265 }
240266
241267 protected getCancelEditBody ( ) {
0 commit comments