未验证 提交 02842368 编写于 作者: R Rachel Macfarlane 提交者: GitHub

Fix #74668, old comment API not adding comments

上级 d89187ed
...@@ -469,6 +469,9 @@ export class MainThreadComments extends Disposable implements MainThreadComments ...@@ -469,6 +469,9 @@ export class MainThreadComments extends Disposable implements MainThreadComments
private _handlers = new Map<number, string>(); private _handlers = new Map<number, string>();
private _commentControllers = new Map<number, MainThreadCommentController>(); private _commentControllers = new Map<number, MainThreadCommentController>();
private _activeCommentThread?: MainThreadCommentThread;
private _input?: modes.CommentInput;
private _openPanelListener: IDisposable | null; private _openPanelListener: IDisposable | null;
constructor( constructor(
...@@ -483,6 +486,26 @@ export class MainThreadComments extends Disposable implements MainThreadComments ...@@ -483,6 +486,26 @@ export class MainThreadComments extends Disposable implements MainThreadComments
this._disposables = []; this._disposables = [];
this._activeCommentThreadDisposables = []; this._activeCommentThreadDisposables = [];
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostComments); this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostComments);
this._disposables.push(this._commentService.onDidChangeActiveCommentThread(async thread => {
let handle = (thread as MainThreadCommentThread).controllerHandle;
let controller = this._commentControllers.get(handle);
if (!controller) {
return;
}
this._activeCommentThreadDisposables = dispose(this._activeCommentThreadDisposables);
this._activeCommentThread = thread as MainThreadCommentThread;
controller.activeCommentThread = this._activeCommentThread;
this._activeCommentThreadDisposables.push(this._activeCommentThread.onDidChangeInput(input => { // todo, dispose
this._input = input;
this._proxy.$onCommentWidgetInputChange(handle, URI.parse(this._activeCommentThread!.resource), this._activeCommentThread!.range, this._input ? this._input.value : undefined);
}));
await this._proxy.$onCommentWidgetInputChange(controller.handle, URI.parse(this._activeCommentThread!.resource), this._activeCommentThread.range, this._input ? this._input.value : undefined);
}));
} }
$registerCommentController(handle: number, id: string, label: string): void { $registerCommentController(handle: number, id: string, label: string): void {
......
...@@ -619,6 +619,7 @@ export class SimpleCommentService implements ICommentService { ...@@ -619,6 +619,7 @@ export class SimpleCommentService implements ICommentService {
onDidSetAllCommentThreads: Event<IWorkspaceCommentThreadsEvent> = Event.None; onDidSetAllCommentThreads: Event<IWorkspaceCommentThreadsEvent> = Event.None;
onDidUpdateCommentThreads: Event<ICommentThreadChangedEvent> = Event.None; onDidUpdateCommentThreads: Event<ICommentThreadChangedEvent> = Event.None;
onDidChangeActiveCommentingRange: Event<{ range: Range; commentingRangesInfo: CommentingRanges; }> = Event.None; onDidChangeActiveCommentingRange: Event<{ range: Range; commentingRangesInfo: CommentingRanges; }> = Event.None;
onDidChangeActiveCommentThread: Event<any> = Event.None;
onDidSetDataProvider: Event<void> = Event.None; onDidSetDataProvider: Event<void> = Event.None;
onDidDeleteDataProvider: Event<string> = Event.None; onDidDeleteDataProvider: Event<string> = Event.None;
setDocumentComments: any; setDocumentComments: any;
...@@ -649,6 +650,7 @@ export class SimpleCommentService implements ICommentService { ...@@ -649,6 +650,7 @@ export class SimpleCommentService implements ICommentService {
deleteReaction: any; deleteReaction: any;
getReactionGroup: any; getReactionGroup: any;
toggleReaction: any; toggleReaction: any;
setActiveCommentThread: any;
} }
registerSingleton(ICommentService, SimpleCommentService, true); registerSingleton(ICommentService, SimpleCommentService, true);
//#endregion //#endregion
......
...@@ -424,12 +424,14 @@ export class CommentNode extends Disposable { ...@@ -424,12 +424,14 @@ export class CommentNode extends Disposable {
uri: this._commentEditor.getModel()!.uri, uri: this._commentEditor.getModel()!.uri,
value: this.comment.body.value value: this.comment.body.value
}; };
this.commentService.setActiveCommentThread(commentThread);
this._commentEditorDisposables.push(this._commentEditor.onDidFocusEditorWidget(() => { this._commentEditorDisposables.push(this._commentEditor.onDidFocusEditorWidget(() => {
commentThread.input = { commentThread.input = {
uri: this._commentEditor!.getModel()!.uri, uri: this._commentEditor!.getModel()!.uri,
value: this.comment.body.value value: this.comment.body.value
}; };
this.commentService.setActiveCommentThread(commentThread);
})); }));
this._commentEditorDisposables.push(this._commentEditor.onDidChangeModelContent(e => { this._commentEditorDisposables.push(this._commentEditor.onDidChangeModelContent(e => {
...@@ -439,6 +441,7 @@ export class CommentNode extends Disposable { ...@@ -439,6 +441,7 @@ export class CommentNode extends Disposable {
let input = commentThread.input; let input = commentThread.input;
input.value = newVal; input.value = newVal;
commentThread.input = input; commentThread.input = input;
this.commentService.setActiveCommentThread(commentThread);
} }
} }
})); }));
...@@ -486,6 +489,7 @@ export class CommentNode extends Disposable { ...@@ -486,6 +489,7 @@ export class CommentNode extends Disposable {
uri: this._commentEditor.getModel()!.uri, uri: this._commentEditor.getModel()!.uri,
value: newBody value: newBody
}; };
this.commentService.setActiveCommentThread(commentThread);
let commandId = this.comment.editCommand.id; let commandId = this.comment.editCommand.id;
let args = this.comment.editCommand.arguments || []; let args = this.comment.editCommand.arguments || [];
...@@ -523,6 +527,7 @@ export class CommentNode extends Disposable { ...@@ -523,6 +527,7 @@ export class CommentNode extends Disposable {
if (result.confirmed) { if (result.confirmed) {
try { try {
if (this.comment.deleteCommand) { if (this.comment.deleteCommand) {
this.commentService.setActiveCommentThread(this.commentThread);
let commandId = this.comment.deleteCommand.id; let commandId = this.comment.deleteCommand.id;
let args = this.comment.deleteCommand.arguments || []; let args = this.comment.deleteCommand.arguments || [];
......
...@@ -38,6 +38,7 @@ export interface ICommentService { ...@@ -38,6 +38,7 @@ export interface ICommentService {
readonly onDidSetResourceCommentInfos: Event<IResourceCommentThreadEvent>; readonly onDidSetResourceCommentInfos: Event<IResourceCommentThreadEvent>;
readonly onDidSetAllCommentThreads: Event<IWorkspaceCommentThreadsEvent>; readonly onDidSetAllCommentThreads: Event<IWorkspaceCommentThreadsEvent>;
readonly onDidUpdateCommentThreads: Event<ICommentThreadChangedEvent>; readonly onDidUpdateCommentThreads: Event<ICommentThreadChangedEvent>;
readonly onDidChangeActiveCommentThread: Event<CommentThread | null>;
readonly onDidChangeActiveCommentingRange: Event<{ range: Range, commentingRangesInfo: CommentingRanges }>; readonly onDidChangeActiveCommentingRange: Event<{ range: Range, commentingRangesInfo: CommentingRanges }>;
readonly onDidSetDataProvider: Event<void>; readonly onDidSetDataProvider: Event<void>;
readonly onDidDeleteDataProvider: Event<string>; readonly onDidDeleteDataProvider: Event<string>;
...@@ -69,6 +70,7 @@ export interface ICommentService { ...@@ -69,6 +70,7 @@ export interface ICommentService {
deleteReaction(owner: string, resource: URI, comment: Comment, reaction: CommentReaction): Promise<void>; deleteReaction(owner: string, resource: URI, comment: Comment, reaction: CommentReaction): Promise<void>;
getReactionGroup(owner: string): CommentReaction[] | undefined; getReactionGroup(owner: string): CommentReaction[] | undefined;
toggleReaction(owner: string, resource: URI, thread: CommentThread2, comment: Comment, reaction: CommentReaction): Promise<void>; toggleReaction(owner: string, resource: URI, thread: CommentThread2, comment: Comment, reaction: CommentReaction): Promise<void>;
setActiveCommentThread(commentThread: CommentThread | null): void;
} }
export class CommentService extends Disposable implements ICommentService { export class CommentService extends Disposable implements ICommentService {
...@@ -89,6 +91,9 @@ export class CommentService extends Disposable implements ICommentService { ...@@ -89,6 +91,9 @@ export class CommentService extends Disposable implements ICommentService {
private readonly _onDidUpdateCommentThreads: Emitter<ICommentThreadChangedEvent> = this._register(new Emitter<ICommentThreadChangedEvent>()); private readonly _onDidUpdateCommentThreads: Emitter<ICommentThreadChangedEvent> = this._register(new Emitter<ICommentThreadChangedEvent>());
readonly onDidUpdateCommentThreads: Event<ICommentThreadChangedEvent> = this._onDidUpdateCommentThreads.event; readonly onDidUpdateCommentThreads: Event<ICommentThreadChangedEvent> = this._onDidUpdateCommentThreads.event;
private readonly _onDidChangeActiveCommentThread = this._register(new Emitter<CommentThread | null>());
readonly onDidChangeActiveCommentThread = this._onDidChangeActiveCommentThread.event;
private readonly _onDidChangeActiveCommentingRange: Emitter<{ private readonly _onDidChangeActiveCommentingRange: Emitter<{
range: Range, commentingRangesInfo: range: Range, commentingRangesInfo:
CommentingRanges CommentingRanges
...@@ -109,6 +114,10 @@ export class CommentService extends Disposable implements ICommentService { ...@@ -109,6 +114,10 @@ export class CommentService extends Disposable implements ICommentService {
super(); super();
} }
setActiveCommentThread(commentThread: CommentThread | null) {
this._onDidChangeActiveCommentThread.fire(commentThread);
}
setDocumentComments(resource: URI, commentInfos: ICommentInfo[]): void { setDocumentComments(resource: URI, commentInfos: ICommentInfo[]): void {
this._onDidSetResourceCommentInfos.fire({ resource, commentInfos }); this._onDidSetResourceCommentInfos.fire({ resource, commentInfos });
} }
......
...@@ -211,6 +211,10 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget ...@@ -211,6 +211,10 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
this._bodyElement = <HTMLDivElement>dom.$('.body'); this._bodyElement = <HTMLDivElement>dom.$('.body');
container.appendChild(this._bodyElement); container.appendChild(this._bodyElement);
dom.addDisposableListener(this._bodyElement, dom.EventType.FOCUS_IN, e => {
this.commentService.setActiveCommentThread(this._commentThread);
});
} }
protected _fillHead(container: HTMLElement): void { protected _fillHead(container: HTMLElement): void {
...@@ -265,6 +269,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget ...@@ -265,6 +269,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
} else { } else {
const deleteCommand = (this._commentThread as modes.CommentThread2).deleteCommand; const deleteCommand = (this._commentThread as modes.CommentThread2).deleteCommand;
if (deleteCommand) { if (deleteCommand) {
this.commentService.setActiveCommentThread(this._commentThread);
return this.commandService.executeCommand(deleteCommand.id, ...(deleteCommand.arguments || [])); return this.commandService.executeCommand(deleteCommand.id, ...(deleteCommand.arguments || []));
} else if (this._commentEditor.getValue() === '') { } else if (this._commentEditor.getValue() === '') {
this.commentService.disposeCommentThread(this._owner, this._commentThread.threadId!); this.commentService.disposeCommentThread(this._owner, this._commentThread.threadId!);
...@@ -516,6 +521,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget ...@@ -516,6 +521,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
uri: this._commentEditor.getModel()!.uri, uri: this._commentEditor.getModel()!.uri,
value: this._commentEditor.getValue() value: this._commentEditor.getValue()
}; };
this.commentService.setActiveCommentThread(this._commentThread);
})); }));
this._commentThreadDisposables.push(this._commentEditor.getModel()!.onDidChangeContent(() => { this._commentThreadDisposables.push(this._commentEditor.getModel()!.onDidChangeContent(() => {
...@@ -526,6 +532,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget ...@@ -526,6 +532,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
newInput.value = modelContent; newInput.value = modelContent;
thread.input = newInput; thread.input = newInput;
} }
this.commentService.setActiveCommentThread(this._commentThread);
})); }));
this._commentThreadDisposables.push((this._commentThread as modes.CommentThread2).onDidChangeInput(input => { this._commentThreadDisposables.push((this._commentThread as modes.CommentThread2).onDidChangeInput(input => {
...@@ -727,6 +734,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget ...@@ -727,6 +734,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
uri: this._commentEditor.getModel()!.uri, uri: this._commentEditor.getModel()!.uri,
value: this._commentEditor.getValue() value: this._commentEditor.getValue()
}; };
this.commentService.setActiveCommentThread(this._commentThread);
await this.commandService.executeCommand(acceptInputCommand.id, ...(acceptInputCommand.arguments || [])); await this.commandService.executeCommand(acceptInputCommand.id, ...(acceptInputCommand.arguments || []));
})); }));
...@@ -751,6 +759,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget ...@@ -751,6 +759,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
uri: this._commentEditor.getModel()!.uri, uri: this._commentEditor.getModel()!.uri,
value: this._commentEditor.getValue() value: this._commentEditor.getValue()
}; };
this.commentService.setActiveCommentThread(this._commentThread);
await this.commandService.executeCommand(command.id, ...(command.arguments || [])); await this.commandService.executeCommand(command.id, ...(command.arguments || []));
})); }));
}); });
...@@ -821,6 +830,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget ...@@ -821,6 +830,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
uri: this._commentEditor.getModel()!.uri, uri: this._commentEditor.getModel()!.uri,
value: this._commentEditor.getValue() value: this._commentEditor.getValue()
}; };
this.commentService.setActiveCommentThread(this._commentThread);
let commandId = commentThread.acceptInputCommand.id; let commandId = commentThread.acceptInputCommand.id;
let args = commentThread.acceptInputCommand.arguments || []; let args = commentThread.acceptInputCommand.arguments || [];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册