Add minimum visible count to open editors (#147771)

This commit is contained in:
Logan Ramos
2022-04-21 10:17:48 -04:00
committed by GitHub
parent cff4c7d59b
commit 2fdb06ca28
2 changed files with 14 additions and 2 deletions
@@ -337,10 +337,16 @@ configurationRegistry.registerConfiguration({
'properties': {
'explorer.openEditors.visible': {
'type': 'number',
'description': nls.localize({ key: 'openEditorsVisible', comment: ['Open is an adjective'] }, "Number of editors shown in the Open Editors pane. Setting this to 0 hides the Open Editors pane."),
'description': nls.localize({ key: 'openEditorsVisible', comment: ['Open is an adjective'] }, "The maximum number of editors shown in the Open Editors pane. Setting this to 0 hides the Open Editors pane."),
'default': 9,
'minimum': 0
},
'explorer.openEditors.minVisible': {
'type': 'number',
'description': nls.localize({ key: 'openEditorsVisibleMin', comment: ['Open is an adjective'] }, "The minimum number of editor slots shown in the Open Editors pane. If set to 0 the Open Editors pane will dynamically resize based on the number of editors."),
'default': 0,
'minimum': 0
},
'explorer.openEditors.sortOrder': {
'type': 'string',
'enum': ['editorOrder', 'alphabetical', 'fullPath'],
@@ -59,6 +59,7 @@ const $ = dom.$;
export class OpenEditorsView extends ViewPane {
private static readonly DEFAULT_VISIBLE_OPEN_EDITORS = 9;
private static readonly DEFAULT_MIN_VISIBLE_OPEN_EDITORS = 0;
static readonly ID = 'workbench.explorer.openEditorsView';
static readonly NAME = nls.localize({ key: 'openEditors', comment: ['Open is an adjective'] }, "Open Editors");
@@ -466,12 +467,17 @@ export class OpenEditorsView extends ViewPane {
}
private getMaxExpandedBodySize(): number {
let minVisibleOpenEditors = this.configurationService.getValue<number>('explorer.openEditors.minVisible');
// If it's not a number setting it to 0 will result in dynamic resizing.
if (typeof minVisibleOpenEditors !== 'number') {
minVisibleOpenEditors = OpenEditorsView.DEFAULT_MIN_VISIBLE_OPEN_EDITORS;
}
const containerModel = this.viewDescriptorService.getViewContainerModel(this.viewDescriptorService.getViewContainerByViewId(this.id)!)!;
if (containerModel.visibleViewDescriptors.length <= 1) {
return Number.POSITIVE_INFINITY;
}
return this.elementCount * OpenEditorsDelegate.ITEM_HEIGHT;
return (Math.max(this.elementCount, minVisibleOpenEditors)) * OpenEditorsDelegate.ITEM_HEIGHT;
}
private getMinExpandedBodySize(): number {