Skip to content

Commit dd2f554

Browse files
authored
Requesting setting to hide discussion bar (microsoft#167051)
Fixes microsoft#162352
1 parent 87f9ab2 commit dd2f554

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

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

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { ICommentThreadChangedEvent } from 'vs/workbench/contrib/comments/common
1414
import { CommentMenus } from 'vs/workbench/contrib/comments/browser/commentMenus';
1515
import { ICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
1616
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
17+
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
18+
import { COMMENTS_SECTION, ICommentsConfiguration } from 'vs/workbench/contrib/comments/common/commentsConfiguration';
1719

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

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

147149
constructor(
148-
@IInstantiationService protected instantiationService: IInstantiationService,
149-
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService
150+
@IInstantiationService protected readonly instantiationService: IInstantiationService,
151+
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
152+
@IConfigurationService private readonly configurationService: IConfigurationService
150153
) {
151154
super();
152-
this._register(layoutService.onDidChangeZenMode(e => {
153-
this.enableCommenting(!e);
155+
this._handleConfiguration();
156+
this._handleZenMode();
157+
}
158+
159+
private _handleConfiguration() {
160+
this._isCommentingEnabled = this._defaultCommentingEnablement;
161+
this._register(this.configurationService.onDidChangeConfiguration(e => {
162+
if (e.affectsConfiguration('comments.visible')) {
163+
this.enableCommenting(this._defaultCommentingEnablement);
164+
}
154165
}));
155166
}
156167

168+
private _handleZenMode() {
169+
let preZenModeValue: boolean = this._isCommentingEnabled;
170+
this._register(this.layoutService.onDidChangeZenMode(e => {
171+
if (e) {
172+
preZenModeValue = this._isCommentingEnabled;
173+
this.enableCommenting(false);
174+
} else {
175+
this.enableCommenting(preZenModeValue);
176+
}
177+
}));
178+
}
179+
180+
private get _defaultCommentingEnablement(): boolean {
181+
return !!this.configurationService.getValue<ICommentsConfiguration>(COMMENTS_SECTION).visible;
182+
}
183+
157184
get isCommentingEnabled(): boolean {
158185
return this._isCommentingEnabled;
159186
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
3434
type: 'boolean',
3535
default: true,
3636
description: nls.localize('useRelativeTime', "Determines if relative time will be used in comment timestamps (ex. '1 day ago').")
37+
},
38+
'comments.visible': {
39+
type: 'boolean',
40+
default: true,
41+
description: nls.localize('comments.visible', "Controls the visibility of the comments bar and comment threads in editors that have commenting ranges and comments.")
3742
}
3843
}
3944
});

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
export interface ICommentsConfiguration {
77
openView: 'never' | 'file' | 'firstFile';
88
useRelativeTime: boolean;
9+
visible: boolean;
910
}
1011

1112
export const COMMENTS_SECTION = 'comments';

0 commit comments

Comments
 (0)