Add a context key for whether commenting is enabled
parent
fcdef2ecf1
commit
b4a9228df6
|
@ -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>();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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…
Reference in New Issue