Skip to content

Commit d239347

Browse files
authored
Add a context key for whether commenting is enabled (microsoft#236679)
1 parent c1cff69 commit d239347

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/vs/workbench/contrib/comments/browser/commentService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export class CommentService extends Disposable implements ICommentService {
167167
private _commentMenus = new Map<string, CommentMenus>();
168168
private _isCommentingEnabled: boolean = true;
169169
private _workspaceHasCommenting: IContextKey<boolean>;
170+
private _commentingEnabled: IContextKey<boolean>;
170171

171172
private _continueOnComments = new Map<string, PendingCommentThread[]>(); // uniqueOwner -> PendingCommentThread[]
172173
private _continueOnCommentProviders = new Set<IContinueOnCommentProvider>();
@@ -190,6 +191,7 @@ export class CommentService extends Disposable implements ICommentService {
190191
this._handleConfiguration();
191192
this._handleZenMode();
192193
this._workspaceHasCommenting = CommentContextKeys.WorkspaceHasCommenting.bindTo(contextKeyService);
194+
this._commentingEnabled = CommentContextKeys.commentingEnabled.bindTo(contextKeyService);
193195
const storageListener = this._register(new DisposableStore());
194196

195197
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 {
277279
enableCommenting(enable: boolean): void {
278280
if (enable !== this._isCommentingEnabled) {
279281
this._isCommentingEnabled = enable;
282+
this._commentingEnabled.set(enable);
280283
this._onDidChangeCommentingEnabled.fire(enable);
281284
}
282285
}

src/vs/workbench/contrib/comments/common/commentContextKeys.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,12 @@ export namespace CommentContextKeys {
6666
* The comment widget is focused.
6767
*/
6868
export const commentFocused = new RawContextKey<boolean>('commentFocused', false, { type: 'boolean', description: nls.localize('commentFocused', "Set when the comment is focused") });
69+
70+
/**
71+
* A context key that is set when commenting is enabled.
72+
*/
73+
export const commentingEnabled = new RawContextKey<boolean>('commentingEnabled', true, {
74+
description: nls.localize('commentingEnabled', "Whether commenting functionality is enabled"),
75+
type: 'boolean'
76+
});
6977
}

0 commit comments

Comments
 (0)