diff --git a/src/vs/workbench/contrib/comments/browser/commentService.ts b/src/vs/workbench/contrib/comments/browser/commentService.ts index ca5a8aa59d9..b7d1cde9aea 100644 --- a/src/vs/workbench/contrib/comments/browser/commentService.ts +++ b/src/vs/workbench/contrib/comments/browser/commentService.ts @@ -167,6 +167,7 @@ export class CommentService extends Disposable implements ICommentService { private _commentMenus = new Map(); private _isCommentingEnabled: boolean = true; private _workspaceHasCommenting: IContextKey; + private _commentingEnabled: IContextKey; private _continueOnComments = new Map(); // uniqueOwner -> PendingCommentThread[] private _continueOnCommentProviders = new Set(); @@ -190,6 +191,7 @@ export class CommentService extends Disposable implements ICommentService { this._handleConfiguration(); this._handleZenMode(); this._workspaceHasCommenting = CommentContextKeys.WorkspaceHasCommenting.bindTo(contextKeyService); + this._commentingEnabled = CommentContextKeys.commentingEnabled.bindTo(contextKeyService); const storageListener = this._register(new DisposableStore()); const storageEvent = Event.debounce(this.storageService.onDidChangeValue(StorageScope.WORKSPACE, CONTINUE_ON_COMMENTS, storageListener), (last, event) => last?.external ? last : event, 500); @@ -277,6 +279,7 @@ export class CommentService extends Disposable implements ICommentService { enableCommenting(enable: boolean): void { if (enable !== this._isCommentingEnabled) { this._isCommentingEnabled = enable; + this._commentingEnabled.set(enable); this._onDidChangeCommentingEnabled.fire(enable); } } diff --git a/src/vs/workbench/contrib/comments/common/commentContextKeys.ts b/src/vs/workbench/contrib/comments/common/commentContextKeys.ts index 210465efe6f..2a5d0776c45 100644 --- a/src/vs/workbench/contrib/comments/common/commentContextKeys.ts +++ b/src/vs/workbench/contrib/comments/common/commentContextKeys.ts @@ -66,4 +66,12 @@ export namespace CommentContextKeys { * The comment widget is focused. */ export const commentFocused = new RawContextKey('commentFocused', false, { type: 'boolean', description: nls.localize('commentFocused', "Set when the comment is focused") }); + + /** + * A context key that is set when commenting is enabled. + */ + export const commentingEnabled = new RawContextKey('commentingEnabled', true, { + description: nls.localize('commentingEnabled', "Whether commenting functionality is enabled"), + type: 'boolean' + }); }