diff --git a/src/vs/editor/common/modes.ts b/src/vs/editor/common/modes.ts index b43e821fd80..faad9ab6da5 100644 --- a/src/vs/editor/common/modes.ts +++ b/src/vs/editor/common/modes.ts @@ -1495,13 +1495,13 @@ export interface CommentThread { comments: Comment[] | undefined; onDidChangeComments: Event; collapsibleState?: CommentThreadCollapsibleState; - readOnly: boolean; + canReply: boolean; input?: CommentInput; onDidChangeInput: Event; onDidChangeRange: Event; onDidChangeLabel: Event; onDidChangeCollasibleState: Event; - onDidChangeReadOnly: Event; + onDidChangeCanReply: Event; isDisposed: boolean; } diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index e12779c2dd5..71f18271110 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -2174,9 +2174,9 @@ declare module 'vscode' { export interface CommentThread { /** * Whether the thread supports reply. - * Defaults to false. + * Defaults to true. */ - readOnly: boolean; + canReply: boolean; } //#endregion } diff --git a/src/vs/workbench/api/browser/mainThreadComments.ts b/src/vs/workbench/api/browser/mainThreadComments.ts index b537782a2a3..b6b32841290 100644 --- a/src/vs/workbench/api/browser/mainThreadComments.ts +++ b/src/vs/workbench/api/browser/mainThreadComments.ts @@ -84,15 +84,15 @@ export class MainThreadCommentThread implements modes.CommentThread { return this._range; } - private readonly _onDidChangeReadOnly = new Emitter(); - get onDidChangeReadOnly(): Event { return this._onDidChangeReadOnly.event; } - set readOnly(state: boolean) { - this._readOnly = state; - this._onDidChangeReadOnly.fire(this._readOnly); + private readonly _onDidChangeCanReply = new Emitter(); + get onDidChangeCanReply(): Event { return this._onDidChangeCanReply.event; } + set canReply(state: boolean) { + this._canReply = state; + this._onDidChangeCanReply.fire(this._canReply); } - get readOnly() { - return this._readOnly; + get canReply() { + return this._canReply; } private readonly _onDidChangeRange = new Emitter(); @@ -124,7 +124,7 @@ export class MainThreadCommentThread implements modes.CommentThread { public threadId: string, public resource: string, private _range: IRange, - private _readOnly: boolean + private _canReply: boolean ) { this._isDisposed = false; } @@ -138,7 +138,7 @@ export class MainThreadCommentThread implements modes.CommentThread { if (modified('contextValue')) { this._contextValue = changes.contextValue; } if (modified('comments')) { this._comments = changes.comments; } if (modified('collapseState')) { this._collapsibleState = changes.collapseState; } - if (modified('readOnly')) { this.readOnly = changes.readOnly!; } + if (modified('canReply')) { this.canReply = changes.canReply!; } } dispose() { @@ -228,7 +228,7 @@ export class MainThreadCommentController { threadId, URI.revive(resource).toString(), range, - false + true ); this._threads.set(commentThreadHandle, thread); diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index 810df72d339..842a1cc47bd 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -144,7 +144,7 @@ export type CommentThreadChanges = Partial<{ contextValue: string, comments: modes.Comment[], collapseState: modes.CommentThreadCollapsibleState; - readOnly: boolean; + canReply: boolean; }>; export interface MainThreadCommentsShape extends IDisposable { diff --git a/src/vs/workbench/api/common/extHostComments.ts b/src/vs/workbench/api/common/extHostComments.ts index 3aedb8b1e5f..65f61f91c9c 100644 --- a/src/vs/workbench/api/common/extHostComments.ts +++ b/src/vs/workbench/api/common/extHostComments.ts @@ -219,7 +219,7 @@ type CommentThreadModification = Partial<{ contextValue: string | undefined, comments: vscode.Comment[], collapsibleState: vscode.CommentThreadCollapsibleState - readOnly: boolean; + canReply: boolean; }>; export class ExtHostCommentThread implements vscode.CommentThread { @@ -264,17 +264,17 @@ export class ExtHostCommentThread implements vscode.CommentThread { return this._range; } - private _readonly: boolean = false; + private _canReply: boolean = true; - set readOnly(state: boolean) { - if (this._readonly !== state) { - this._readonly = state; - this.modifications.readOnly = state; + set canReply(state: boolean) { + if (this._canReply !== state) { + this._canReply = state; + this.modifications.canReply = state; this._onDidUpdateCommentThread.fire(); } } - get readOnly() { - return this._readonly; + get canReply() { + return this._canReply; } private _label: string | undefined; @@ -401,8 +401,8 @@ export class ExtHostCommentThread implements vscode.CommentThread { if (modified('collapsibleState')) { formattedModifications.collapseState = convertToCollapsibleState(this._collapseState); } - if (modified('readOnly')) { - formattedModifications.readOnly = this.readOnly; + if (modified('canReply')) { + formattedModifications.canReply = this.canReply; } this.modifications = {}; diff --git a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts index d9dac1fcc97..c9de91d9b09 100644 --- a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts +++ b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts @@ -450,8 +450,8 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget } } - // create comment thread only when not readonly - if (!this._commentThread.readOnly) { + // create comment thread only when it supports reply + if (this._commentThread.canReply) { this.createCommentForm(); } @@ -470,7 +470,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget // If there are no existing comments, place focus on the text area. This must be done after show, which also moves focus. // if this._commentThread.comments is undefined, it doesn't finish initialization yet, so we don't focus the editor immediately. - if (!this._commentThread.readOnly && this._commentReplyComponent) { + if (this._commentThread.canReply && this._commentReplyComponent) { if (!this._commentThread.comments || !this._commentThread.comments.length) { this._commentReplyComponent.editor.focus(); } else if (this._commentReplyComponent.editor.getModel()!.getValueLength() > 0) { @@ -478,15 +478,15 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget } } - this._commentThreadDisposables.push(this._commentThread.onDidChangeReadOnly(() => { + this._commentThreadDisposables.push(this._commentThread.onDidChangeCanReply(() => { if (this._commentReplyComponent) { - if (this._commentThread.readOnly) { + if (!this._commentThread.canReply) { this._commentReplyComponent.form.style.display = 'none'; } else { this._commentReplyComponent.form.style.display = 'block'; } } else { - if (!this._commentThread.readOnly) { + if (this._commentThread.canReply) { this.createCommentForm(); } }