Skip to content

Commit

Permalink
Add a context key for whether commenting is enabled (#236679)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexr00 authored Dec 20, 2024
1 parent c1cff69 commit d239347
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/vs/workbench/contrib/comments/browser/commentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export class CommentService extends Disposable implements ICommentService {
private _commentMenus = new Map<string, CommentMenus>();
private _isCommentingEnabled: boolean = true;
private _workspaceHasCommenting: IContextKey<boolean>;
private _commentingEnabled: IContextKey<boolean>;

private _continueOnComments = new Map<string, PendingCommentThread[]>(); // uniqueOwner -> PendingCommentThread[]
private _continueOnCommentProviders = new Set<IContinueOnCommentProvider>();
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,12 @@ export namespace CommentContextKeys {
* The comment widget is focused.
*/
export const commentFocused = new RawContextKey<boolean>('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<boolean>('commentingEnabled', true, {
description: nls.localize('commentingEnabled', "Whether commenting functionality is enabled"),
type: 'boolean'
});
}

0 comments on commit d239347

Please sign in to comment.