Skip to content

Commit

Permalink
Allow individual comments to be marked as draft
Browse files Browse the repository at this point in the history
This is a proposal for #171166.
  • Loading branch information
hermannloose committed Feb 13, 2023
1 parent e282742 commit 51396e6
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/vs/editor/common/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,14 @@ export enum CommentMode {
Preview = 1
}

/**
* @internal
*/
export enum CommentVisibility {
Published = 0,
Draft = 1
}

/**
* @internal
*/
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
ColorPresentation: extHostTypes.ColorPresentation,
ColorThemeKind: extHostTypes.ColorThemeKind,
CommentMode: extHostTypes.CommentMode,
CommentVisibility: extHostTypes.CommentVisibility,
CommentThreadCollapsibleState: extHostTypes.CommentThreadCollapsibleState,
CommentThreadState: extHostTypes.CommentThreadState,
CompletionItem: extHostTypes.CompletionItem,
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export interface CommentChanges {
readonly commentReactions?: languages.CommentReaction[];
readonly label?: string;
readonly mode?: languages.CommentMode;
readonly visibility?: languages.CommentVisibility;
readonly timestamp?: string;
}

Expand Down
6 changes: 6 additions & 0 deletions src/vs/workbench/api/common/extHostComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
this._onDidUpdateCommentThread.fire();
}

get hasDraftComments(): boolean {
return this._comments.some(comment => comment.visibility === types.CommentVisibility.Draft);
}

private _localDisposables: types.Disposable[];

private _isDiposed: boolean;
Expand Down Expand Up @@ -418,6 +422,7 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
set canReply(state: boolean) { that.canReply = state; },
get contextValue() { return that.contextValue; },
set contextValue(value: string | undefined) { that.contextValue = value; },
get hasDraftComments() { return that.hasDraftComments; },
get label() { return that.label; },
set label(value: string | undefined) { that.label = value; },
get state() { return that.state; },
Expand Down Expand Up @@ -662,6 +667,7 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
userIconPath: iconPath,
label: vscodeComment.label,
commentReactions: vscodeComment.reactions ? vscodeComment.reactions.map(reaction => convertToReaction(reaction)) : undefined,
visibility: vscodeComment.visibility,
timestamp: vscodeComment.timestamp?.toJSON()
};
}
Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/api/common/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3046,6 +3046,11 @@ export enum CommentMode {
Preview = 1
}

export enum CommentVisibility {
Published = 0,
Draft = 1
}

export enum CommentThreadState {
Unresolved = 0,
Resolved = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
export const allApiProposals = Object.freeze({
authSession: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.authSession.d.ts',
codiconDecoration: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.codiconDecoration.d.ts',
commentsDraftState: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.commentsDraftState.d.ts',
contribCommentEditorActionsMenu: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribCommentEditorActionsMenu.d.ts',
contribCommentPeekContext: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribCommentPeekContext.d.ts',
contribCommentThreadAdditionalMenu: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribCommentThreadAdditionalMenu.d.ts',
Expand Down
22 changes: 22 additions & 0 deletions src/vscode-dts/vscode.proposed.commentsDraftState.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

declare module 'vscode' {

// https://github.com/microsoft/vscode/issues/171166

export enum CommentVisibility {
Published = 0,
Draft = 1
}

export interface Comment {
visibility?: CommentVisibility;
}

export interface CommentThread {
readonly hasDraftComments: boolean;
}
}

0 comments on commit 51396e6

Please sign in to comment.