提交 b98a5ad0 编写于 作者: R rebornix

register comments panel when there is comment control registered

上级 d41ade21
......@@ -1318,22 +1318,22 @@ export interface CommentThreadChangedEvent {
/**
* Added comment threads.
*/
readonly added: CommentThread[];
readonly added: (CommentThread | CommentThread2)[];
/**
* Removed comment threads.
*/
readonly removed: CommentThread[];
readonly removed: (CommentThread | CommentThread2)[];
/**
* Changed comment threads.
*/
readonly changed: CommentThread[];
readonly changed: (CommentThread | CommentThread2)[];
/**
* changed draft mode.
*/
readonly draftMode: DraftMode;
readonly draftMode?: DraftMode;
}
/**
......
......@@ -793,6 +793,7 @@ declare module 'vscode' {
* Whether the thread should be collapsed or expanded when opening the document. Defaults to Collapsed.
*/
collapsibleState?: CommentThreadCollapsibleState;
dispose?(): void;
}
/**
......@@ -956,8 +957,8 @@ declare module 'vscode' {
readonly id: string;
readonly label: string;
/**
* The active (focused) comment widget.
*/
* The active (focused) comment widget.
*/
readonly widget?: CommentWidget;
createCommentThread(id: string, resource: Uri, range: Range, comments: Comment[], acceptInputCommands: Command[], collapsibleState?: CommentThreadCollapsibleState): CommentThread;
dispose(): void;
......
......@@ -165,6 +165,7 @@ export class MainThreadCommentControl {
private _threads: Map<number, MainThreadCommentThread> = new Map<number, MainThreadCommentThread>();
constructor(
private _proxy: ExtHostCommentsShape,
private _commentService: ICommentService,
private _handle: number,
private _id: string,
private _label: string
......@@ -184,12 +185,26 @@ export class MainThreadCommentControl {
);
this._threads.set(commentThreadHandle, thread);
this._commentService.updateComments(`${this.handle}`, {
added: [thread],
removed: [],
changed: [],
draftMode: modes.DraftMode.NotSupported
});
return thread;
}
deleteCommentThread(commentThreadHandle: number) {
let thread = this._threads.get(commentThreadHandle);
this._threads.delete(commentThreadHandle);
this._commentService.updateComments(`${this.handle}`, {
added: [],
removed: [thread],
changed: [],
draftMode: modes.DraftMode.NotSupported
});
thread.dispose();
}
......@@ -284,9 +299,15 @@ export class MainThreadComments extends Disposable implements MainThreadComments
}
$registerCommentControl(handle: number, id: string, label: string): void {
const provider = new MainThreadCommentControl(this._proxy, handle, id, label);
const provider = new MainThreadCommentControl(this._proxy, this._commentService, handle, id, label);
this._commentService.registerCommentControl(String(handle), provider);
this._commentControls.set(handle, provider);
const commentsPanelAlreadyConstructed = this._panelService.getPanels().some(panel => panel.id === COMMENTS_PANEL_ID);
if (!commentsPanelAlreadyConstructed) {
this.registerPanel(commentsPanelAlreadyConstructed);
}
this._commentService.setWorkspaceComments(String(handle), []);
}
$createCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange, comments: modes.Comment[], commands: modes.Command[], collapseState: modes.CommentThreadCollapsibleState): modes.CommentThread2 | undefined {
......@@ -350,6 +371,18 @@ export class MainThreadComments extends Disposable implements MainThreadComments
this._commentService.registerDataProvider(providerId, handler);
}
private registerPanel(commentsPanelAlreadyConstructed: boolean) {
if (!commentsPanelAlreadyConstructed) {
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescriptor(
CommentsPanel,
COMMENTS_PANEL_ID,
COMMENTS_PANEL_TITLE,
'commentsPanel',
10
));
}
}
/**
* If the comments panel has never been opened, the constructor for it has not yet run so it has
* no listeners for comment threads being set or updated. Listen for the panel opening for the
......@@ -383,13 +416,9 @@ export class MainThreadComments extends Disposable implements MainThreadComments
this._handlers.set(handle, providerId);
const commentsPanelAlreadyConstructed = this._panelService.getPanels().some(panel => panel.id === COMMENTS_PANEL_ID);
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescriptor(
CommentsPanel,
COMMENTS_PANEL_ID,
COMMENTS_PANEL_TITLE,
'commentsPanel',
10
));
if (!commentsPanelAlreadyConstructed) {
this.registerPanel(commentsPanelAlreadyConstructed);
}
const openPanel = this._configurationService.getValue<ICommentsConfiguration>('comments').openPanel;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册