mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
Sort comments in view by resource
Part of microsoft/vscode-pull-request-github#3354
This commit is contained in:
parent
9422f0a568
commit
780cd3096b
|
@ -6,7 +6,7 @@
|
|||
import { URI } from 'vs/base/common/uri';
|
||||
import { IRange } from 'vs/editor/common/core/range';
|
||||
import { Comment, CommentThread, CommentThreadChangedEvent } from 'vs/editor/common/languages';
|
||||
import { groupBy, flatten } from 'vs/base/common/arrays';
|
||||
import { groupBy } from 'vs/base/common/arrays';
|
||||
import { localize } from 'vs/nls';
|
||||
|
||||
export interface ICommentThreadChangedEvent extends CommentThreadChangedEvent {
|
||||
|
@ -71,9 +71,16 @@ export class CommentsModel {
|
|||
this.commentThreadsMap = new Map<string, ResourceWithCommentThreads[]>();
|
||||
}
|
||||
|
||||
private updateResourceCommentThreads() {
|
||||
this.resourceCommentThreads = [...this.commentThreadsMap.values()].flat();
|
||||
this.resourceCommentThreads.sort((a, b) => {
|
||||
return a.resource.toString() > b.resource.toString() ? 1 : -1;
|
||||
});
|
||||
}
|
||||
|
||||
public setCommentThreads(owner: string, commentThreads: CommentThread[]): void {
|
||||
this.commentThreadsMap.set(owner, this.groupByResource(owner, commentThreads));
|
||||
this.resourceCommentThreads = flatten([...this.commentThreadsMap.values()]);
|
||||
this.updateResourceCommentThreads();
|
||||
}
|
||||
|
||||
public updateCommentThreads(event: ICommentThreadChangedEvent): boolean {
|
||||
|
@ -123,7 +130,7 @@ export class CommentsModel {
|
|||
});
|
||||
|
||||
this.commentThreadsMap.set(owner, threadsForOwner);
|
||||
this.resourceCommentThreads = flatten([...this.commentThreadsMap.values()]);
|
||||
this.updateResourceCommentThreads();
|
||||
|
||||
return removed.length > 0 || changed.length > 0 || added.length > 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue