Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a context key for whether commenting is enabled #236679

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
});
}
Loading