mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 20:13:32 +01:00
comments panel handle new comment thread registration.
This commit is contained in:
@@ -239,6 +239,13 @@ export class MainThreadCommentController {
|
||||
updateComments(commentThreadHandle: number, comments: modes.Comment[]) {
|
||||
let thread = this._threads.get(commentThreadHandle);
|
||||
thread.comments = comments;
|
||||
|
||||
this._commentService.updateComments(`${this.handle}`, {
|
||||
added: [],
|
||||
removed: [],
|
||||
changed: [thread],
|
||||
draftMode: modes.DraftMode.NotSupported
|
||||
});
|
||||
}
|
||||
|
||||
updateAcceptInputCommands(commentThreadHandle: number, acceptInputCommands: modes.Command[]) {
|
||||
@@ -289,6 +296,15 @@ export class MainThreadCommentController {
|
||||
};
|
||||
}
|
||||
|
||||
getAllComments(): MainThreadCommentThread[] {
|
||||
let ret = [];
|
||||
for (let thread of keys(this._threads)) {
|
||||
ret.push(this._threads.get(thread));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
toJSON(): any {
|
||||
return {
|
||||
$mid: 6,
|
||||
@@ -348,9 +364,13 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
this._commentService.registerCommentController(String(handle), provider);
|
||||
this._commentControllers.set(handle, provider);
|
||||
|
||||
const providerId = generateUuid();
|
||||
this._handlers.set(handle, providerId);
|
||||
|
||||
const commentsPanelAlreadyConstructed = this._panelService.getPanels().some(panel => panel.id === COMMENTS_PANEL_ID);
|
||||
if (!commentsPanelAlreadyConstructed) {
|
||||
this.registerPanel(commentsPanelAlreadyConstructed);
|
||||
this.registerOpenPanelListener(commentsPanelAlreadyConstructed);
|
||||
}
|
||||
this._commentService.setWorkspaceComments(String(handle), []);
|
||||
}
|
||||
@@ -466,6 +486,15 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
});
|
||||
});
|
||||
|
||||
keys(this._commentControllers).forEach(handle => {
|
||||
let threads = this._commentControllers.get(handle).getAllComments();
|
||||
|
||||
if (threads.length) {
|
||||
const providerId = this._handlers.get(handle);
|
||||
this._commentService.setWorkspaceComments(providerId, threads);
|
||||
}
|
||||
});
|
||||
|
||||
if (this._openPanelListener) {
|
||||
this._openPanelListener.dispose();
|
||||
this._openPanelListener = null;
|
||||
|
||||
@@ -106,9 +106,10 @@ export class ExtHostComments implements ExtHostCommentsShape {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
const document = this._documents.getDocument(URI.revive(uriComponents));
|
||||
return asPromise(() => {
|
||||
return commentController.commentingRangeProvider.provider(URI.revive(uriComponents), token);
|
||||
}).then(ranges => ranges.map(extHostTypeConverter.Range.from));
|
||||
return commentController.commentingRangeProvider.provider(document, token);
|
||||
}).then(ranges => ranges ? ranges.map(extHostTypeConverter.Range.from) : undefined);
|
||||
}
|
||||
|
||||
$createNewCommentWidgetCallback(commentControllerHandle: number, uriComponents: UriComponents, range: IRange, token: CancellationToken): void {
|
||||
@@ -118,7 +119,8 @@ export class ExtHostComments implements ExtHostCommentsShape {
|
||||
return;
|
||||
}
|
||||
|
||||
commentController.commentingRangeProvider.callback(URI.revive(uriComponents), extHostTypeConverter.Range.to(range));
|
||||
const document = this._documents.getDocument(URI.revive(uriComponents));
|
||||
commentController.commentingRangeProvider.callback(document, extHostTypeConverter.Range.to(range));
|
||||
}
|
||||
|
||||
registerWorkspaceCommentProvider(
|
||||
@@ -412,8 +414,8 @@ export class ExtHostCommentInputBox implements vscode.CommentInputBox {
|
||||
|
||||
class ExtHostCommentingRangeProvider {
|
||||
constructor(
|
||||
public provider: (uri: vscode.Uri, token: vscode.CancellationToken) => vscode.ProviderResult<vscode.Range[]>,
|
||||
public callback: (uri: vscode.Uri, range: vscode.Range) => void
|
||||
public provider: (document: vscode.TextDocument, token: vscode.CancellationToken) => vscode.ProviderResult<vscode.Range[]>,
|
||||
public callback: (document: vscode.TextDocument, range: vscode.Range) => void
|
||||
) {
|
||||
|
||||
}
|
||||
@@ -464,7 +466,7 @@ class ExtHostCommentController implements vscode.CommentController {
|
||||
return commentThread;
|
||||
}
|
||||
|
||||
registerCommentingRangeProvider(provider: (uri: vscode.Uri, token: vscode.CancellationToken) => vscode.ProviderResult<vscode.Range[]>, callback: (uri: vscode.Uri, range: vscode.Range) => void) {
|
||||
registerCommentingRangeProvider(provider: (document: vscode.TextDocument, token: vscode.CancellationToken) => vscode.ProviderResult<vscode.Range[]>, callback: (document: vscode.TextDocument, range: vscode.Range) => void) {
|
||||
this._commentingRangeProvider = new ExtHostCommentingRangeProvider(provider, callback);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user