diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts index 66320713617fd..24c081dff7557 100644 --- a/src/vs/workbench/browser/layout.ts +++ b/src/vs/workbench/browser/layout.ts @@ -25,6 +25,7 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation import { LifecyclePhase, StartupKind, ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle'; import { MenuBarVisibility, getTitleBarStyle, getMenuBarVisibility } from 'vs/platform/windows/common/windows'; import { IHostService } from 'vs/workbench/services/host/browser/host'; +import { IEditor } from 'vs/editor/common/editorCommon'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { IEditorService, IResourceEditor } from 'vs/workbench/services/editor/common/editorService'; import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; @@ -120,6 +121,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi private workbenchGrid!: SerializableGrid; + private editorWidgetSet = new Set(); + private disposed: boolean | undefined; private titleBarPartView!: ISerializableView; @@ -690,18 +693,33 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi this.state.zenMode.active = !this.state.zenMode.active; this.state.zenMode.transitionDisposables.clear(); - const setLineNumbers = (lineNumbers?: any) => this.editorService.visibleTextEditorWidgets.forEach(editor => { - // To properly reset line numbers we need to read the configuration for each editor respecting it's uri. - if (!lineNumbers && isCodeEditor(editor) && editor.hasModel()) { - const model = editor.getModel(); - lineNumbers = this.configurationService.getValue('editor.lineNumbers', { resource: model.uri, overrideIdentifier: model.getModeId() }); - } + const setLineNumbers = (lineNumbers?: any) => { + const setEditorLineNumbers = (editor: IEditor) => { + // To properly reset line numbers we need to read the configuration for each editor respecting it's uri. + if (!lineNumbers && isCodeEditor(editor) && editor.hasModel()) { + const model = editor.getModel(); + lineNumbers = this.configurationService.getValue('editor.lineNumbers', { resource: model.uri, overrideIdentifier: model.getModeId() }); + } + if (!lineNumbers) { + lineNumbers = this.configurationService.getValue('editor.lineNumbers'); + } + + editor.updateOptions({ lineNumbers }); + }; + if (!lineNumbers) { - lineNumbers = this.configurationService.getValue('editor.lineNumbers'); + // Reset line numbers on all editors visible and non-visible + for (const editor of this.editorWidgetSet) { + setEditorLineNumbers(editor); + } + this.editorWidgetSet.clear(); + } else { + this.editorService.visibleTextEditorWidgets.forEach(editor => { + this.editorWidgetSet.add(editor); + setEditorLineNumbers(editor); + }); } - - editor.updateOptions({ lineNumbers }); - }); + }; // Check if zen mode transitioned to full screen and if now we are out of zen mode // -> we need to go out of full screen (same goes for the centered editor layout)