File tree Expand file tree Collapse file tree
src/vs/base/browser/ui/grid Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -217,6 +217,8 @@ export class Grid<T extends IView = IView> extends Disposable {
217217
218218 get element ( ) : HTMLElement { return this . gridview . element ; }
219219
220+ private didLayout = false ;
221+
220222 constructor ( view : T , options : IGridOptions = { } ) {
221223 super ( ) ;
222224 this . gridview = new GridView ( options ) ;
@@ -237,6 +239,7 @@ export class Grid<T extends IView = IView> extends Disposable {
237239
238240 layout ( width : number , height : number ) : void {
239241 this . gridview . layout ( width , height ) ;
242+ this . didLayout = true ;
240243 }
241244
242245 hasView ( view : T ) : boolean {
@@ -344,6 +347,10 @@ export class Grid<T extends IView = IView> extends Disposable {
344347 }
345348
346349 getNeighborViews ( view : T , direction : Direction , wrap : boolean = false ) : T [ ] {
350+ if ( ! this . didLayout ) {
351+ throw new Error ( 'Can\'t call getNeighborViews before first layout' ) ;
352+ }
353+
347354 const location = this . getViewLocation ( view ) ;
348355 const root = this . getViews ( ) ;
349356 const node = getGridNode ( root , location ) ;
You can’t perform that action at this time.
0 commit comments