Skip to content

Commit 77882bf

Browse files
committed
zenMode: hide line numbers
fixes microsoft#31609
1 parent f572364 commit 77882bf

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/vs/workbench/electron-browser/main.contribution.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,11 @@ configurationRegistry.registerConfiguration({
886886
'default': true,
887887
'description': nls.localize('zenMode.hideActivityBar', "Controls whether turning on Zen Mode also hides the activity bar at the left of the workbench.")
888888
},
889+
'zenMode.hideLineNumbers': {
890+
'type': 'boolean',
891+
'default': true,
892+
'description': nls.localize('zenMode.hideLineNumbers', "Controls whether turning on Zen Mode also hides the editor line numbers.")
893+
},
889894
'zenMode.restore': {
890895
'type': 'boolean',
891896
'default': false,

src/vs/workbench/electron-browser/workbench.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/work
113113
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
114114
import { FileDialogService } from 'vs/workbench/services/dialogs/electron-browser/dialogService';
115115
import { LogStorageAction } from 'vs/platform/storage/node/storageService';
116+
import { IEditor } from 'vs/editor/common/editorCommon';
116117

117118
interface WorkbenchParams {
118119
configuration: IWindowConfiguration;
@@ -125,6 +126,7 @@ interface IZenModeSettings {
125126
hideTabs: boolean;
126127
hideActivityBar: boolean;
127128
hideStatusBar: boolean;
129+
hideLineNumbers: boolean;
128130
restore: boolean;
129131
}
130132

@@ -1236,6 +1238,14 @@ export class Workbench extends Disposable implements IPartService {
12361238
// Check if zen mode transitioned to full screen and if now we are out of zen mode
12371239
// -> we need to go out of full screen (same goes for the centered editor layout)
12381240
let toggleFullScreen = false;
1241+
const setLineNumbers = (lineNumbers: any) => {
1242+
this.editorService.visibleControls.forEach(editor => {
1243+
const control = <IEditor>editor.getControl();
1244+
if (control) {
1245+
control.updateOptions({ lineNumbers });
1246+
}
1247+
});
1248+
};
12391249

12401250
// Zen Mode Active
12411251
if (this.zenMode.active) {
@@ -1258,6 +1268,11 @@ export class Workbench extends Disposable implements IPartService {
12581268
this.setStatusBarHidden(true, true);
12591269
}
12601270

1271+
if (config.hideLineNumbers) {
1272+
setLineNumbers('off');
1273+
this.zenMode.transitionDisposeables.push(this.editorService.onDidVisibleEditorsChange(() => setLineNumbers('off')));
1274+
}
1275+
12611276
if (config.hideTabs && this.editorPart.partOptions.showTabs) {
12621277
this.zenMode.transitionDisposeables.push(this.editorPart.enforcePartOptions({ showTabs: false }));
12631278
}
@@ -1280,6 +1295,7 @@ export class Workbench extends Disposable implements IPartService {
12801295
if (this.zenMode.transitionedToCenteredEditorLayout) {
12811296
this.centerEditorLayout(false, true);
12821297
}
1298+
setLineNumbers(this.configurationService.getValue('editor.lineNumbers'));
12831299

12841300
// Status bar and activity bar visibility come from settings -> update their visibility.
12851301
this.onDidUpdateConfiguration(true);

0 commit comments

Comments
 (0)