Skip to content

Commit

Permalink
feat: ensure view priority used for viewChange events
Browse files Browse the repository at this point in the history
  • Loading branch information
mathuo committed Sep 30, 2023
1 parent 206255b commit 08ec3fd
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions packages/dockview-core/src/splitview/splitview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ export interface SplitViewOptions {
readonly proportionalLayout?: boolean;
readonly styles?: ISplitviewStyles;
}

export enum LayoutPriority {
Low = 'low',
High = 'high',
Normal = 'normal',
Low = 'low', // view is offered space last
High = 'high', // view is offered space first
Normal = 'normal', // view is offered space in view order
}

export interface IBaseView extends IDisposable {
Expand Down Expand Up @@ -340,7 +341,22 @@ export class Splitview {

item.size = size;

this.relayout([index]);
const indexes = range(this.viewItems.length).filter((i) => i !== index);
const lowPriorityIndexes = [
...indexes.filter(
(i) => this.viewItems[i].priority === LayoutPriority.Low
),
index,
];
const highPriorityIndexes = indexes.filter(
(i) => this.viewItems[i].priority === LayoutPriority.High
);

/**
* add this view we are changing to the low-index list since we have determined the size
* here and don't want it changed
*/
this.relayout([...lowPriorityIndexes, index], highPriorityIndexes);
}

public addView(
Expand Down

0 comments on commit 08ec3fd

Please sign in to comment.