diff --git a/src/sql/parts/query/editor/queryResultsView.ts b/src/sql/parts/query/editor/queryResultsView.ts index 4f795d9f75..c3aabda4e0 100644 --- a/src/sql/parts/query/editor/queryResultsView.ts +++ b/src/sql/parts/query/editor/queryResultsView.ts @@ -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 {