Skip to content

Commit c429b41

Browse files
committed
grid: should not allow call to getNeighborViews before first layout
1 parent 714f500 commit c429b41

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/vs/base/browser/ui/grid/grid.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)