File tree Expand file tree Collapse file tree 5 files changed +16
-24
lines changed Expand file tree Collapse file tree 5 files changed +16
-24
lines changed Original file line number Diff line number Diff line change @@ -601,7 +601,7 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
601
601
602
602
private _activeThread : vscode . CommentThread2 | undefined ;
603
603
604
- get activeThread ( ) : vscode . CommentThread2 | undefined {
604
+ get activeCommentThread ( ) : vscode . CommentThread2 | undefined {
605
605
checkProposedApiEnabled ( this . _extension , 'activeComment' ) ;
606
606
return this . _activeThread ;
607
607
}
@@ -628,7 +628,7 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
628
628
get reactionHandler ( ) : ReactionHandler | undefined { return that . reactionHandler ; } ,
629
629
set reactionHandler ( handler : ReactionHandler | undefined ) { that . reactionHandler = handler ; } ,
630
630
// get activeComment(): vscode.Comment | undefined { return that.activeComment; },
631
- get activeThread ( ) : vscode . CommentThread2 | undefined { return that . activeThread ; } ,
631
+ get activeCommentThread ( ) : vscode . CommentThread2 | undefined { return that . activeCommentThread ; } ,
632
632
createCommentThread ( uri : vscode . Uri , range : vscode . Range | undefined , comments : vscode . Comment [ ] ) : vscode . CommentThread | vscode . CommentThread2 {
633
633
return that . createCommentThread ( uri , range , comments ) . value ;
634
634
} ,
Original file line number Diff line number Diff line change @@ -174,9 +174,6 @@ export class CommentNode<T extends IRange | ICellRange> extends Disposable {
174
174
this . _register ( dom . addDisposableListener ( this . _domNode , dom . EventType . FOCUS_IN , ( ) => {
175
175
this . commentService . setActiveCommentAndThread ( this . owner , { thread : this . commentThread , comment : this . comment } ) ;
176
176
} , true ) ) ;
177
- this . _register ( dom . addDisposableListener ( this . _domNode , dom . EventType . FOCUS_OUT , ( ) => {
178
- this . commentService . setActiveCommentAndThread ( this . owner , undefined ) ;
179
- } , true ) ) ;
180
177
}
181
178
182
179
private createScroll ( container : HTMLElement , body : HTMLElement ) {
Original file line number Diff line number Diff line change @@ -233,20 +233,12 @@ export class CommentReply<T extends IRange | ICellRange> extends Disposable {
233
233
234
234
private createTextModelListener ( commentEditor : ICodeEditor , commentForm : HTMLElement ) {
235
235
this . _commentThreadDisposables . push ( commentEditor . onDidFocusEditorWidget ( ( ) => {
236
- // Add a setTimeout so that the blur event doesn't fire before the focus event
237
- // https://github.com/microsoft/vscode/blob/f6d945edbdc1b2e8a176624fdf612bb61468944f/src/vs/base/browser/dom.ts#L1322-L1328
238
- setTimeout ( ( ) => {
239
- this . _commentThread . input = {
240
- uri : commentEditor . getModel ( ) ! . uri ,
241
- value : commentEditor . getValue ( )
242
- } ;
243
- this . commentService . setActiveEditingCommentThread ( this . _commentThread ) ;
244
- this . commentService . setActiveCommentAndThread ( this . owner , { thread : this . _commentThread } ) ;
245
- } , 0 ) ;
246
- } ) ) ;
247
-
248
- this . _commentThreadDisposables . push ( commentEditor . onDidBlurEditorWidget ( ( ) => {
249
- this . commentService . setActiveCommentAndThread ( this . owner , undefined ) ;
236
+ this . _commentThread . input = {
237
+ uri : commentEditor . getModel ( ) ! . uri ,
238
+ value : commentEditor . getValue ( )
239
+ } ;
240
+ this . commentService . setActiveEditingCommentThread ( this . _commentThread ) ;
241
+ this . commentService . setActiveCommentAndThread ( this . owner , { thread : this . _commentThread } ) ;
250
242
} ) ) ;
251
243
252
244
this . _commentThreadDisposables . push ( commentEditor . getModel ( ) ! . onDidChangeContent ( ( ) => {
Original file line number Diff line number Diff line change @@ -272,20 +272,22 @@ export class CommentService extends Disposable implements ICommentService {
272
272
this . _onDidChangeActiveEditingCommentThread . fire ( commentThread ) ;
273
273
}
274
274
275
+ private _lastActiveCommentController : ICommentController | undefined ;
275
276
async setActiveCommentAndThread ( owner : string , commentInfo : { thread : CommentThread < IRange > ; comment ?: Comment } | undefined ) {
276
277
const commentController = this . _commentControls . get ( owner ) ;
277
278
278
279
if ( ! commentController ) {
279
280
return ;
280
281
}
281
282
283
+ if ( commentController !== this . _lastActiveCommentController ) {
284
+ await this . _lastActiveCommentController ?. setActiveCommentAndThread ( undefined ) ;
285
+ }
286
+ this . _lastActiveCommentController = commentController ;
282
287
return commentController . setActiveCommentAndThread ( commentInfo ) ;
283
288
}
284
289
285
290
setDocumentComments ( resource : URI , commentInfos : ICommentInfo [ ] ) : void {
286
- if ( commentInfos . length ) {
287
- this . _workspaceHasCommenting . set ( true ) ;
288
- }
289
291
this . _onDidSetResourceCommentInfos . fire ( { resource, commentInfos } ) ;
290
292
}
291
293
Original file line number Diff line number Diff line change @@ -15,8 +15,9 @@ declare module 'vscode' {
15
15
16
16
/**
17
17
* The currently active comment thread or `undefined`. The active comment thread is the one
18
- * that currently has focus or, when none has focus, undefined.
18
+ * in the CommentController that most recently had focus or, when a different CommentController's
19
+ * thread has most recently had focus, undefined.
19
20
*/
20
- readonly activeThread : CommentThread | undefined ;
21
+ readonly activeCommentThread : CommentThread | undefined ;
21
22
}
22
23
}
You can’t perform that action at this time.
0 commit comments