Skip to content

Commit

Permalink
Merge pull request #90822 from jeanp413/zen-mode-linenumbers-1
Browse files Browse the repository at this point in the history
Properly reset editor.lineNumbers after disabling zen mode
  • Loading branch information
isidorn committed Feb 18, 2020
2 parents aa70f38 + 5037388 commit 70b5e93
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions src/vs/workbench/browser/layout.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -120,6 +121,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi

private workbenchGrid!: SerializableGrid<ISerializableView>;

private editorWidgetSet = new Set<IEditor>();

private disposed: boolean | undefined;

private titleBarPartView!: ISerializableView;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 70b5e93

Please sign in to comment.