mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-09 17:52:34 -05:00
Merge from vscode 52dcb723a39ae75bee1bd56b3312d7fcdc87aeed (#6719)
This commit is contained in:
@@ -79,7 +79,7 @@ abstract class ViewItem {
|
||||
return typeof this._cachedVisibleSize === 'undefined';
|
||||
}
|
||||
|
||||
set visible(visible: boolean) {
|
||||
setVisible(visible: boolean, size?: number): void {
|
||||
if (visible === this.visible) {
|
||||
return;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ abstract class ViewItem {
|
||||
this.size = clamp(this._cachedVisibleSize!, this.viewMinimumSize, this.viewMaximumSize);
|
||||
this._cachedVisibleSize = undefined;
|
||||
} else {
|
||||
this._cachedVisibleSize = this.size;
|
||||
this._cachedVisibleSize = typeof size === 'number' ? size : this.size;
|
||||
this.size = 0;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,10 @@ abstract class ViewItem {
|
||||
dom.addClass(container, 'visible');
|
||||
}
|
||||
|
||||
abstract layout(): void;
|
||||
layout(): void {
|
||||
this.container.scrollTop = 0;
|
||||
this.container.scrollLeft = 0;
|
||||
}
|
||||
|
||||
layoutView(orientation: Orientation): void {
|
||||
this.view.layout(this.size, orientation);
|
||||
@@ -140,6 +143,7 @@ abstract class ViewItem {
|
||||
class VerticalViewItem extends ViewItem {
|
||||
|
||||
layout(): void {
|
||||
super.layout();
|
||||
this.container.style.height = `${this.size}px`;
|
||||
this.layoutView(Orientation.VERTICAL);
|
||||
}
|
||||
@@ -148,6 +152,7 @@ class VerticalViewItem extends ViewItem {
|
||||
class HorizontalViewItem extends ViewItem {
|
||||
|
||||
layout(): void {
|
||||
super.layout();
|
||||
this.container.style.width = `${this.size}px`;
|
||||
this.layoutView(Orientation.HORIZONTAL);
|
||||
}
|
||||
@@ -161,6 +166,7 @@ interface ISashItem {
|
||||
interface ISashDragSnapState {
|
||||
readonly index: number;
|
||||
readonly limitDelta: number;
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface ISashDragState {
|
||||
@@ -203,7 +209,7 @@ export class SplitView extends Disposable {
|
||||
private proportions: undefined | number[] = undefined;
|
||||
private viewItems: ViewItem[] = [];
|
||||
private sashItems: ISashItem[] = [];
|
||||
private sashDragState: ISashDragState;
|
||||
private sashDragState: ISashDragState | undefined;
|
||||
private state: State = State.Idle;
|
||||
private inverseAltBehavior: boolean;
|
||||
private proportionalLayout: boolean;
|
||||
@@ -414,9 +420,10 @@ export class SplitView extends Disposable {
|
||||
throw new Error('Cant modify splitview');
|
||||
}
|
||||
|
||||
const size = this.getViewSize(from);
|
||||
const cachedVisibleSize = this.getViewCachedVisibleSize(from);
|
||||
const sizing = typeof cachedVisibleSize === 'undefined' ? this.getViewSize(from) : Sizing.Invisible(cachedVisibleSize);
|
||||
const view = this.removeView(from);
|
||||
this.addView(view, size, to);
|
||||
this.addView(view, sizing, to);
|
||||
}
|
||||
|
||||
swapViews(from: number, to: number): void {
|
||||
@@ -452,10 +459,11 @@ export class SplitView extends Disposable {
|
||||
}
|
||||
|
||||
const viewItem = this.viewItems[index];
|
||||
viewItem.visible = visible;
|
||||
viewItem.setVisible(visible);
|
||||
|
||||
this.distributeEmptySpace(index);
|
||||
this.layoutViews();
|
||||
this.saveProportions();
|
||||
}
|
||||
|
||||
getViewCachedVisibleSize(index: number): number | undefined {
|
||||
@@ -499,8 +507,8 @@ export class SplitView extends Disposable {
|
||||
|
||||
// This way, we can press Alt while we resize a sash, macOS style!
|
||||
const disposable = combinedDisposable(
|
||||
domEvent(document.body, 'keydown')(e => resetSashDragState(this.sashDragState.current, e.altKey)),
|
||||
domEvent(document.body, 'keyup')(() => resetSashDragState(this.sashDragState.current, false))
|
||||
domEvent(document.body, 'keydown')(e => resetSashDragState(this.sashDragState!.current, e.altKey)),
|
||||
domEvent(document.body, 'keyup')(() => resetSashDragState(this.sashDragState!.current, false))
|
||||
);
|
||||
|
||||
const resetSashDragState = (start: number, alt: boolean) => {
|
||||
@@ -550,7 +558,8 @@ export class SplitView extends Disposable {
|
||||
|
||||
snapBefore = {
|
||||
index: snapBeforeIndex,
|
||||
limitDelta: viewItem.visible ? minDelta - halfSize : minDelta + halfSize
|
||||
limitDelta: viewItem.visible ? minDelta - halfSize : minDelta + halfSize,
|
||||
size: viewItem.size
|
||||
};
|
||||
}
|
||||
|
||||
@@ -560,7 +569,8 @@ export class SplitView extends Disposable {
|
||||
|
||||
snapAfter = {
|
||||
index: snapAfterIndex,
|
||||
limitDelta: viewItem.visible ? maxDelta + halfSize : maxDelta - halfSize
|
||||
limitDelta: viewItem.visible ? maxDelta + halfSize : maxDelta - halfSize,
|
||||
size: viewItem.size
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -572,8 +582,8 @@ export class SplitView extends Disposable {
|
||||
}
|
||||
|
||||
private onSashChange({ current }: ISashEvent): void {
|
||||
const { index, start, sizes, alt, minDelta, maxDelta, snapBefore, snapAfter } = this.sashDragState;
|
||||
this.sashDragState.current = current;
|
||||
const { index, start, sizes, alt, minDelta, maxDelta, snapBefore, snapAfter } = this.sashDragState!;
|
||||
this.sashDragState!.current = current;
|
||||
|
||||
const delta = current - start;
|
||||
const newDelta = this.resize(index, delta, sizes, undefined, undefined, minDelta, maxDelta, snapBefore, snapAfter);
|
||||
@@ -596,7 +606,7 @@ export class SplitView extends Disposable {
|
||||
|
||||
private onSashEnd(index: number): void {
|
||||
this._onDidSashChange.fire(index);
|
||||
this.sashDragState.disposable.dispose();
|
||||
this.sashDragState!.disposable.dispose();
|
||||
this.saveProportions();
|
||||
}
|
||||
|
||||
@@ -738,14 +748,14 @@ export class SplitView extends Disposable {
|
||||
const snapView = this.viewItems[snapBefore.index];
|
||||
const visible = delta >= snapBefore.limitDelta;
|
||||
snapped = visible !== snapView.visible;
|
||||
snapView.visible = visible;
|
||||
snapView.setVisible(visible, snapBefore.size);
|
||||
}
|
||||
|
||||
if (!snapped && snapAfter) {
|
||||
const snapView = this.viewItems[snapAfter.index];
|
||||
const visible = delta < snapAfter.limitDelta;
|
||||
snapped = visible !== snapView.visible;
|
||||
snapView.visible = visible;
|
||||
snapView.setVisible(visible, snapAfter.size);
|
||||
}
|
||||
|
||||
if (snapped) {
|
||||
|
||||
Reference in New Issue
Block a user