mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-25 04:36:23 +00:00
@@ -601,7 +601,7 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
|
||||
|
||||
private _activeThread: vscode.CommentThread2 | undefined;
|
||||
|
||||
get activeThread(): vscode.CommentThread2 | undefined {
|
||||
get activeCommentThread(): vscode.CommentThread2 | undefined {
|
||||
checkProposedApiEnabled(this._extension, 'activeComment');
|
||||
return this._activeThread;
|
||||
}
|
||||
@@ -628,7 +628,7 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
|
||||
get reactionHandler(): ReactionHandler | undefined { return that.reactionHandler; },
|
||||
set reactionHandler(handler: ReactionHandler | undefined) { that.reactionHandler = handler; },
|
||||
// get activeComment(): vscode.Comment | undefined { return that.activeComment; },
|
||||
get activeThread(): vscode.CommentThread2 | undefined { return that.activeThread; },
|
||||
get activeCommentThread(): vscode.CommentThread2 | undefined { return that.activeCommentThread; },
|
||||
createCommentThread(uri: vscode.Uri, range: vscode.Range | undefined, comments: vscode.Comment[]): vscode.CommentThread | vscode.CommentThread2 {
|
||||
return that.createCommentThread(uri, range, comments).value;
|
||||
},
|
||||
|
||||
@@ -174,9 +174,6 @@ export class CommentNode<T extends IRange | ICellRange> extends Disposable {
|
||||
this._register(dom.addDisposableListener(this._domNode, dom.EventType.FOCUS_IN, () => {
|
||||
this.commentService.setActiveCommentAndThread(this.owner, { thread: this.commentThread, comment: this.comment });
|
||||
}, true));
|
||||
this._register(dom.addDisposableListener(this._domNode, dom.EventType.FOCUS_OUT, () => {
|
||||
this.commentService.setActiveCommentAndThread(this.owner, undefined);
|
||||
}, true));
|
||||
}
|
||||
|
||||
private createScroll(container: HTMLElement, body: HTMLElement) {
|
||||
|
||||
@@ -233,20 +233,12 @@ export class CommentReply<T extends IRange | ICellRange> extends Disposable {
|
||||
|
||||
private createTextModelListener(commentEditor: ICodeEditor, commentForm: HTMLElement) {
|
||||
this._commentThreadDisposables.push(commentEditor.onDidFocusEditorWidget(() => {
|
||||
// Add a setTimeout so that the blur event doesn't fire before the focus event
|
||||
// https://github.com/microsoft/vscode/blob/f6d945edbdc1b2e8a176624fdf612bb61468944f/src/vs/base/browser/dom.ts#L1322-L1328
|
||||
setTimeout(() => {
|
||||
this._commentThread.input = {
|
||||
uri: commentEditor.getModel()!.uri,
|
||||
value: commentEditor.getValue()
|
||||
};
|
||||
this.commentService.setActiveEditingCommentThread(this._commentThread);
|
||||
this.commentService.setActiveCommentAndThread(this.owner, { thread: this._commentThread });
|
||||
}, 0);
|
||||
}));
|
||||
|
||||
this._commentThreadDisposables.push(commentEditor.onDidBlurEditorWidget(() => {
|
||||
this.commentService.setActiveCommentAndThread(this.owner, undefined);
|
||||
this._commentThread.input = {
|
||||
uri: commentEditor.getModel()!.uri,
|
||||
value: commentEditor.getValue()
|
||||
};
|
||||
this.commentService.setActiveEditingCommentThread(this._commentThread);
|
||||
this.commentService.setActiveCommentAndThread(this.owner, { thread: this._commentThread });
|
||||
}));
|
||||
|
||||
this._commentThreadDisposables.push(commentEditor.getModel()!.onDidChangeContent(() => {
|
||||
|
||||
@@ -272,6 +272,7 @@ export class CommentService extends Disposable implements ICommentService {
|
||||
this._onDidChangeActiveEditingCommentThread.fire(commentThread);
|
||||
}
|
||||
|
||||
private _lastActiveCommentController: ICommentController | undefined;
|
||||
async setActiveCommentAndThread(owner: string, commentInfo: { thread: CommentThread<IRange>; comment?: Comment } | undefined) {
|
||||
const commentController = this._commentControls.get(owner);
|
||||
|
||||
@@ -279,13 +280,14 @@ export class CommentService extends Disposable implements ICommentService {
|
||||
return;
|
||||
}
|
||||
|
||||
if (commentController !== this._lastActiveCommentController) {
|
||||
await this._lastActiveCommentController?.setActiveCommentAndThread(undefined);
|
||||
}
|
||||
this._lastActiveCommentController = commentController;
|
||||
return commentController.setActiveCommentAndThread(commentInfo);
|
||||
}
|
||||
|
||||
setDocumentComments(resource: URI, commentInfos: ICommentInfo[]): void {
|
||||
if (commentInfos.length) {
|
||||
this._workspaceHasCommenting.set(true);
|
||||
}
|
||||
this._onDidSetResourceCommentInfos.fire({ resource, commentInfos });
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,9 @@ declare module 'vscode' {
|
||||
|
||||
/**
|
||||
* The currently active comment thread or `undefined`. The active comment thread is the one
|
||||
* that currently has focus or, when none has focus, undefined.
|
||||
* in the CommentController that most recently had focus or, when a different CommentController's
|
||||
* thread has most recently had focus, undefined.
|
||||
*/
|
||||
readonly activeThread: CommentThread | undefined;
|
||||
readonly activeCommentThread: CommentThread | undefined;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user