提交 801d3eaa 编写于 作者: R Rachel Macfarlane

Add onDidCommentThreadsChange

上级 99ce8b1b
......@@ -158,7 +158,11 @@ export class PRProvider implements vscode.TreeDataProvider<PRGroupTreeItem | Pul
}
];
const _onDidChangeCommentThreads = new vscode.EventEmitter<vscode.CommentThreadChangedEvent>();
setTimeout(() => _onDidChangeCommentThreads.fire({ changed: [], added: [], removed: [] }), 5000);
vscode.workspace.registerCommentProvider({
onDidChangeCommentThreads: _onDidChangeCommentThreads.event,
provideNewCommentRange: async (document: vscode.TextDocument, token: vscode.CancellationToken) => {
if (document.uri.scheme === 'pr') {
let params = JSON.parse(document.uri.query);
......
......@@ -170,7 +170,9 @@ export class ReviewMode {
return ret;
}
this._commentProvider = vscode.workspace.registerCommentProvider({
const _onDidChangeCommentThreads = new vscode.EventEmitter<vscode.CommentThreadChangedEvent>();
vscode.workspace.registerCommentProvider({
onDidChangeCommentThreads: _onDidChangeCommentThreads.event,
provideNewCommentRange: async (document: vscode.TextDocument, token: vscode.CancellationToken) => {
if (document.uri.scheme === 'review' || document.uri.scheme === 'file') {
let lastLine = document.lineCount;
......
......@@ -957,10 +957,29 @@ export interface Comment {
readonly gravatar: string;
}
export interface CommentThreadChangedEvent {
/**
* Added comment threads.
*/
readonly added: CommentThread[];
/**
* Removed comment threads.
*/
readonly removed: CommentThread[];
/**
* Changed comment threads.
*/
readonly changed: CommentThread[];
}
export interface CommentProvider {
provideComments(model: model.ITextModel, token: CancellationToken): CommentThread[];
provideNewCommentRange(model: model.ITextModel, token: CancellationToken): Promise<NewCommentAction>;
provideAllComments(token: CancellationToken): Promise<CommentThread[]>;
onDidChangeCommentThreads(): Event<CommentThreadChangedEvent>;
}
export interface ICodeLensSymbol {
......
......@@ -5047,10 +5047,26 @@ declare namespace monaco.languages {
readonly gravatar: string;
}
export interface CommentThreadChangedEvent {
/**
* Added comment threads.
*/
readonly added: CommentThread[];
/**
* Removed comment threads.
*/
readonly removed: CommentThread[];
/**
* Changed comment threads.
*/
readonly changed: CommentThread[];
}
export interface CommentProvider {
provideComments(model: editor.ITextModel, token: CancellationToken): CommentThread[];
provideNewCommentRange(model: editor.ITextModel, token: CancellationToken): Promise<NewCommentAction>;
provideAllComments(token: CancellationToken): Promise<CommentThread[]>;
onDidChangeCommentThreads(): IEvent<CommentThreadChangedEvent>;
}
export interface ICodeLensSymbol {
......
......@@ -789,6 +789,23 @@ declare module 'vscode' {
gravatar: string;
}
export interface CommentThreadChangedEvent {
/**
* Added comment threads.
*/
readonly added: CommentThread[];
/**
* Removed comment threads.
*/
readonly removed: CommentThread[];
/**
* Changed comment threads.
*/
readonly changed: CommentThread[];
}
/**
* TODO: force update event?
* TODO: resolve step?
......@@ -797,6 +814,7 @@ declare module 'vscode' {
provideComments(document: TextDocument, token: CancellationToken): Promise<CommentThread[]>;
provideNewCommentRange(document: TextDocument, token: CancellationToken): Promise<NewCommentAction>;
provideAllComments?(token: CancellationToken): Promise<CommentThread[]>;
onDidChangeCommentThreads?: Event<CommentThreadChangedEvent>;
}
namespace workspace {
......
......@@ -67,8 +67,10 @@ export class MainThreadComments extends Disposable implements MainThreadComments
this._panelService.setPanelEnablement(COMMENTS_PANEL_ID, true);
}
});
}
$onDidCommentThreadsChange(handle: number, event: modes.CommentThreadChangedEvent) {
// notify comment service
}
$unregisterCommentProvider(handle: number): void {
......
......@@ -107,6 +107,7 @@ export interface MainThreadCommandsShape extends IDisposable {
export interface MainThreadCommentsShape extends IDisposable {
$registerCommentProvider(handle: number): void;
$unregisterCommentProvider(handle: number): void;
$onDidCommentThreadsChange(handle: number, event: modes.CommentThreadChangedEvent): void;
}
export interface MainThreadConfigurationShape extends IDisposable {
......
......@@ -37,6 +37,15 @@ export class ExtHostComments implements ExtHostCommentsShape {
this._providers.set(handle, provider);
this._proxy.$registerCommentProvider(handle);
provider.onDidChangeCommentThreads(event => {
this._proxy.$onDidCommentThreadsChange(handle, {
changed: event.changed.map(x => convertCommentThread(x, this._commandsConverter)),
added: event.added.map(x => convertCommentThread(x, this._commandsConverter)),
removed: event.removed.map(x => convertCommentThread(x, this._commandsConverter))
});
});
return {
dispose: () => {
this._proxy.$unregisterCommentProvider(handle);
......@@ -45,6 +54,10 @@ export class ExtHostComments implements ExtHostCommentsShape {
};
}
$onDidCommentThreadsChange(handle: number, commentThreadEvent: vscode.CommentThreadChangedEvent) {
return TPromise.as(null);
}
$provideComments(handle: number, uri: UriComponents): TPromise<modes.CommentThread[]> {
const data = this._documents.getDocumentData(URI.revive(uri));
if (!data || !data.document) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册