@@ -222,36 +222,45 @@ export async function activate(context: vscode.ExtensionContext) {
222222 { preserveFocus : true } ,
223223 ) ;
224224
225- const commentResp = await codingSrv . getMRComments ( mr . iid ) ;
226- const comments = ( commentResp . data as IDiffComment [ ] [ ] )
227- . filter ( ( i ) => {
228- const first = i [ 0 ] ;
229- return ! first . outdated && first . path === file . path ;
230- } , [ ] )
231- . map ( ( i ) => {
232- const root = i [ 0 ] ;
233- const isRight = root . change_type === 1 ;
234- const isLeft = root . change_type === 2 ;
235- const both = root . change_type === 3 ;
225+ try {
226+ const commentResp = await codingSrv . getMRComments ( mr . iid ) ;
227+ ( commentResp . data as IDiffComment [ ] [ ] )
228+ . filter ( ( i ) => {
229+ const first = i [ 0 ] ;
230+ return ! first . outdated && first . path === file . path ;
231+ } , [ ] )
232+ . forEach ( ( i ) => {
233+ const root = i [ 0 ] ;
234+ const isRight = root . change_type === 1 ;
235+ const isLeft = root . change_type === 2 ;
236+ const both = root . change_type === 3 ;
236237
237- const rootLine = root . diffFile . diffLines [ root . diffFile . diffLines . length - 1 ] ;
238- const lineNum = isLeft ? rootLine . leftNo : rootLine . rightNo ;
239- const range = new vscode . Range ( lineNum , 0 , lineNum , 0 ) ;
240- const commentList : vscode . Comment [ ] = i . map ( ( c ) => {
241- const body = new vscode . MarkdownString ( tdService . turndown ( c . content ) ) ;
242- body . isTrusted = true ;
243- const comment : vscode . Comment = {
244- mode : vscode . CommentMode . Preview ,
245- body,
246- author : {
247- name : `${ c . author . name } (${ c . author . global_key } )` ,
248- iconPath : vscode . Uri . parse ( c . author . avatar , false ) ,
249- } ,
250- } ;
251- return comment ;
238+ const rootLine = root . diffFile . diffLines [ root . diffFile . diffLines . length - 1 ] ;
239+ const lineNum = isLeft ? rootLine . leftNo : rootLine . rightNo ;
240+ const range = new vscode . Range ( lineNum - 1 , 0 , lineNum - 1 , 0 ) ;
241+
242+ const commentList : vscode . Comment [ ] = i . map ( ( c ) => {
243+ const body = new vscode . MarkdownString ( tdService . turndown ( c . content ) ) ;
244+ body . isTrusted = true ;
245+ const comment : vscode . Comment = {
246+ mode : vscode . CommentMode . Preview ,
247+ body,
248+ author : {
249+ name : `${ c . author . name } (${ c . author . global_key } )` ,
250+ iconPath : vscode . Uri . parse ( c . author . avatar , false ) ,
251+ } ,
252+ } ;
253+ return comment ;
254+ } ) ;
255+ const commentThread = commentController . createCommentThread (
256+ headUri ,
257+ range ,
258+ commentList ,
259+ ) ;
260+ commentThread . collapsibleState = vscode . CommentThreadCollapsibleState . Expanded ;
252261 } ) ;
253- commentController . createCommentThread ( headUri , range , commentList ) ;
254- } ) ;
262+ } finally {
263+ }
255264 } ,
256265 ) ,
257266 ) ;
0 commit comments