Skip to content

Commit

Permalink
fix #126475
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Oct 19, 2021
1 parent 286370b commit f6de520
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/vs/workbench/api/browser/mainThreadComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ export class MainThreadCommentController {
}
}

updateCommentingRanges() {
this._commentService.updateCommentingRanges(this._uniqueId);
}

private getKnownThread(commentThreadHandle: number): MainThreadCommentThread {
const thread = this._threads.get(commentThreadHandle);
if (!thread) {
Expand Down Expand Up @@ -473,6 +477,16 @@ export class MainThreadComments extends Disposable implements MainThreadComments
return provider.deleteCommentThread(commentThreadHandle);
}

$updateCommentingRanges(handle: number) {
let provider = this._commentControllers.get(handle);

if (!provider) {
return;
}

provider.updateCommentingRanges();
}

private registerView(commentsViewAlreadyRegistered: boolean) {
if (!commentsViewAlreadyRegistered) {
const VIEW_CONTAINER: ViewContainer = Registry.as<IViewContainersRegistry>(ViewExtensions.ViewContainersRegistry).registerViewContainer({
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export interface MainThreadCommentsShape extends IDisposable {
$createCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange, extensionId: ExtensionIdentifier): modes.CommentThread | undefined;
$updateCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, changes: CommentThreadChanges): void;
$deleteCommentThread(handle: number, commentThreadHandle: number): void;
$updateCommentingRanges(handle: number): void;
$onDidCommentThreadsChange(handle: number, event: modes.CommentThreadChangedEvent): void;
}

Expand Down
11 changes: 10 additions & 1 deletion src/vs/workbench/api/common/extHostComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,16 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
}

private _threads: Map<number, ExtHostCommentThread> = new Map<number, ExtHostCommentThread>();
commentingRangeProvider?: vscode.CommentingRangeProvider;

private _commentingRangeProvider?: vscode.CommentingRangeProvider;
get commentingRangeProvider(): vscode.CommentingRangeProvider | undefined {
return this._commentingRangeProvider;
}

set commentingRangeProvider(provider: vscode.CommentingRangeProvider | undefined) {
this._commentingRangeProvider = provider;
proxy.$updateCommentingRanges(this.handle);
}

private _reactionHandler?: ReactionHandler;

Expand Down
9 changes: 9 additions & 0 deletions src/vs/workbench/contrib/comments/browser/commentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface ICommentService {
readonly onDidSetAllCommentThreads: Event<IWorkspaceCommentThreadsEvent>;
readonly onDidUpdateCommentThreads: Event<ICommentThreadChangedEvent>;
readonly onDidChangeActiveCommentThread: Event<CommentThread | null>;
readonly onDidUpdateCommentingRanges: Event<{ owner: string; }>
readonly onDidChangeActiveCommentingRange: Event<{ range: Range, commentingRangesInfo: CommentingRanges }>;
readonly onDidSetDataProvider: Event<void>;
readonly onDidDeleteDataProvider: Event<string>;
Expand All @@ -52,6 +53,7 @@ export interface ICommentService {
updateComments(ownerId: string, event: CommentThreadChangedEvent): void;
disposeCommentThread(ownerId: string, threadId: string): void;
getComments(resource: URI): Promise<(ICommentInfo | null)[]>;
updateCommentingRanges(ownerId: string): void;
getCommentingRanges(resource: URI): Promise<IRange[]>;
hasReactionHandler(owner: string): boolean;
toggleReaction(owner: string, resource: URI, thread: CommentThread, comment: Comment, reaction: CommentReaction): Promise<void>;
Expand All @@ -76,6 +78,9 @@ export class CommentService extends Disposable implements ICommentService {
private readonly _onDidUpdateCommentThreads: Emitter<ICommentThreadChangedEvent> = this._register(new Emitter<ICommentThreadChangedEvent>());
readonly onDidUpdateCommentThreads: Event<ICommentThreadChangedEvent> = this._onDidUpdateCommentThreads.event;

private readonly _onDidUpdateCommentingRanges: Emitter<{ owner: string; }> = this._register(new Emitter<{ owner: string; }>());
readonly onDidUpdateCommentingRanges: Event<{ owner: string; }> = this._onDidUpdateCommentingRanges.event;

private readonly _onDidChangeActiveCommentThread = this._register(new Emitter<CommentThread | null>());
readonly onDidChangeActiveCommentThread = this._onDidChangeActiveCommentThread.event;

Expand Down Expand Up @@ -169,6 +174,10 @@ export class CommentService extends Disposable implements ICommentService {
this._onDidUpdateCommentThreads.fire(evt);
}

updateCommentingRanges(ownerId: string) {
this._onDidUpdateCommentingRanges.fire({ owner: ownerId });
}

async toggleReaction(owner: string, resource: URI, thread: CommentThread, comment: Comment, reaction: CommentReaction): Promise<void> {
const commentController = this._commentControls.get(owner);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export class CommentController implements IEditorContribution {
this.beginCompute();
}));
this.globalToDispose.add(this.commentService.onDidSetDataProvider(_ => this.beginCompute()));
this.globalToDispose.add(this.commentService.onDidUpdateCommentingRanges(_ => this.beginCompute()));

this.globalToDispose.add(this.commentService.onDidSetResourceCommentInfos(e => {
const editorURI = this.editor && this.editor.hasModel() && this.editor.getModel().uri;
Expand Down

0 comments on commit f6de520

Please sign in to comment.