Fix sizing error when switching windows (#2544)

* add work around for when we need to resize while we don't have a dimension to resize off of

* formatting
This commit is contained in:
Anthony Dresser
2018-09-12 13:21:51 -07:00
committed by GitHub
parent d046b0a412
commit e18e0da0c1

View File

@@ -27,6 +27,7 @@ class ResultsView implements IPanelView {
private container = document.createElement('div');
private currentDimension: DOM.Dimension;
private isGridRendered = false;
private needsGridResize = false;
private lastGridHeight: number;
constructor(instantiationService: IInstantiationService) {
@@ -51,19 +52,34 @@ class ResultsView implements IPanelView {
this.isGridRendered = false;
}
} else {
if (size > 0) {
if (this.currentDimension) {
this.needsGridResize = false;
if (size > 0) {
this.panelViewlet.addPanels([
{ panel: this.gridPanel, index: 0, size: this.lastGridHeight || Math.round(this.currentDimension.height * .7) }
]);
this.isGridRendered = true;
}
} else {
this.panelViewlet.addPanels([
{ panel: this.gridPanel, index: 0, size: this.lastGridHeight || Math.round(this.currentDimension.height * .8) }
{ panel: this.gridPanel, index: 0, size: this.lastGridHeight || 200 }
]);
this.isGridRendered = true;
this.needsGridResize = true;
}
}
});
let gridResizeList = this.gridPanel.onDidChange(e => {
this.panelViewlet.resizePanel(this.gridPanel, Math.round(this.currentDimension.height * .8));
if (this.currentDimension) {
this.needsGridResize = false;
this.panelViewlet.resizePanel(this.gridPanel, Math.round(this.currentDimension.height * .7));
} else {
this.needsGridResize = true;
}
});
// once the user changes the sash we should stop trying to resize the grid
once(this.panelViewlet.onDidSashChange)(e => {
this.needsGridResize = false;
gridResizeList.dispose();
});
}
@@ -79,6 +95,9 @@ class ResultsView implements IPanelView {
this.gridPanel.layout(dimension.height);
}
this.currentDimension = dimension;
if (this.needsGridResize) {
this.panelViewlet.resizePanel(this.gridPanel, Math.round(this.currentDimension.height * .7));
}
}
remove(): void {