Allow individual comments to be marked as draft (#173305)

* Allow individual comments to be marked as draft

This is a proposal for #171166.

* Remove `hasDraftComments` from `CommentThread`

* Rename `CommentVisibility` to `CommentState`

* Rename `CommentVisibility` to `CommentState`

* Add api proposal check

---------

Co-authored-by: Alex Ross <alros@microsoft.com>
This commit is contained in:
Hermann Loose
2023-03-28 19:18:22 +02:00
committed by GitHub
parent 0a3470a001
commit de3b0db8e8
7 changed files with 41 additions and 2 deletions

View File

@@ -491,7 +491,7 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
}
if (modified('comments')) {
formattedModifications.comments =
this._comments.map(cmt => convertToDTOComment(this, cmt, this._commentsMap));
this._comments.map(cmt => convertToDTOComment(this, cmt, this._commentsMap, this.extensionDescription));
}
if (modified('collapsibleState')) {
formattedModifications.collapseState = convertToCollapsibleState(this._collapseState);
@@ -666,13 +666,17 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
}
}
function convertToDTOComment(thread: ExtHostCommentThread, vscodeComment: vscode.Comment, commentsMap: Map<vscode.Comment, number>): CommentChanges {
function convertToDTOComment(thread: ExtHostCommentThread, vscodeComment: vscode.Comment, commentsMap: Map<vscode.Comment, number>, extension: IExtensionDescription): CommentChanges {
let commentUniqueId = commentsMap.get(vscodeComment)!;
if (!commentUniqueId) {
commentUniqueId = ++thread.commentHandle;
commentsMap.set(vscodeComment, commentUniqueId);
}
if (vscodeComment.state !== undefined) {
checkProposedApiEnabled(extension, 'commentsDraftState');
}
return {
mode: vscodeComment.mode,
contextValue: vscodeComment.contextValue,
@@ -682,6 +686,7 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
userIconPath: vscodeComment.author.iconPath,
label: vscodeComment.label,
commentReactions: vscodeComment.reactions ? vscodeComment.reactions.map(reaction => convertToReaction(reaction)) : undefined,
state: vscodeComment.state,
timestamp: vscodeComment.timestamp?.toJSON()
};
}