Skip to content

Commit e23a6b0

Browse files
authored
feat: support cache SplitPane Position of Panel and reset SplitPane p… (#161)
1 parent ad5319f commit e23a6b0

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/controller/workbench.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ import { singleton } from 'tsyringe';
33

44
export interface IWorkbenchController {
55
readonly splitPanePos: string[];
6+
readonly horizontalSplitPanePos: string[];
67
onPaneSizeChange?: (newSize: number) => void;
8+
onHorizontalPaneSizeChange?: (newSize: number) => void;
79
}
8-
910
@singleton()
1011
export class WorkbenchController
1112
extends Controller
1213
implements IWorkbenchController {
1314
// Group Pos locate here temporary, we can move it to state or localStorage in future.
1415
public splitPanePos: string[] = ['300px', 'auto'];
16+
public horizontalSplitPanePos: string[] = ['70%', 'auto'];
1517

1618
constructor() {
1719
super();
@@ -20,4 +22,7 @@ export class WorkbenchController
2022
public onPaneSizeChange = (newSize) => {
2123
this.splitPanePos = newSize;
2224
};
25+
26+
public onHorizontalPaneSizeChange = (newSize) =>
27+
(this.horizontalSplitPanePos = newSize);
2328
}

src/workbench/workbench.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ export function WorkbenchView(props: IWorkbench & IWorkbenchController) {
5757
sideBar,
5858
statusBar,
5959
onPaneSizeChange,
60+
onHorizontalPaneSizeChange,
6061
splitPanePos,
62+
horizontalSplitPanePos,
6163
} = props;
62-
6364
return (
6465
<div id={ID_APP} className={appClassName} tabIndex={0}>
6566
<div className={workbenchClassName}>
@@ -85,10 +86,15 @@ export function WorkbenchView(props: IWorkbench & IWorkbenchController) {
8586
primary="first"
8687
split="horizontal"
8788
allowResize={true}
89+
onChange={onHorizontalPaneSizeChange}
8890
>
8991
{!panel.maximize ? (
9092
<Pane
91-
initialSize="70%"
93+
initialSize={
94+
panel.hidden
95+
? '100%'
96+
: horizontalSplitPanePos[0]
97+
}
9298
maxSize="99%"
9399
minSize="10%"
94100
>

0 commit comments

Comments
 (0)