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

Requesting setting to hide discussion bar #167051

Merged
merged 1 commit into from Nov 23, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 31 additions & 4 deletions src/vs/workbench/contrib/comments/browser/commentService.ts
Expand Up @@ -14,6 +14,8 @@ import { ICommentThreadChangedEvent } from 'vs/workbench/contrib/comments/common
import { CommentMenus } from 'vs/workbench/contrib/comments/browser/commentMenus';
import { ICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { COMMENTS_SECTION, ICommentsConfiguration } from 'vs/workbench/contrib/comments/common/commentsConfiguration';

export const ICommentService = createDecorator<ICommentService>('commentService');

Expand Down Expand Up @@ -145,15 +147,40 @@ export class CommentService extends Disposable implements ICommentService {
private _isCommentingEnabled: boolean = true;

constructor(
@IInstantiationService protected instantiationService: IInstantiationService,
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService
@IInstantiationService protected readonly instantiationService: IInstantiationService,
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
@IConfigurationService private readonly configurationService: IConfigurationService
) {
super();
this._register(layoutService.onDidChangeZenMode(e => {
this.enableCommenting(!e);
this._handleConfiguration();
this._handleZenMode();
}

private _handleConfiguration() {
this._isCommentingEnabled = this._defaultCommentingEnablement;
this._register(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('comments.visible')) {
this.enableCommenting(this._defaultCommentingEnablement);
}
}));
}

private _handleZenMode() {
let preZenModeValue: boolean = this._isCommentingEnabled;
this._register(this.layoutService.onDidChangeZenMode(e => {
if (e) {
preZenModeValue = this._isCommentingEnabled;
this.enableCommenting(false);
} else {
this.enableCommenting(preZenModeValue);
}
}));
}

private get _defaultCommentingEnablement(): boolean {
return !!this.configurationService.getValue<ICommentsConfiguration>(COMMENTS_SECTION).visible;
}

get isCommentingEnabled(): boolean {
return this._isCommentingEnabled;
}
Expand Down
Expand Up @@ -34,6 +34,11 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
type: 'boolean',
default: true,
description: nls.localize('useRelativeTime', "Determines if relative time will be used in comment timestamps (ex. '1 day ago').")
},
'comments.visible': {
type: 'boolean',
default: true,
description: nls.localize('comments.visible', "Controls the visibility of the comments bar and comment threads in editors that have commenting ranges and comments.")
}
}
});
Expand Down
Expand Up @@ -6,6 +6,7 @@
export interface ICommentsConfiguration {
openView: 'never' | 'file' | 'firstFile';
useRelativeTime: boolean;
visible: boolean;
}

export const COMMENTS_SECTION = 'comments';