disable horizontal scrolling while rename widget is active

fixes #71291
上级 32a0c9ed
...@@ -227,7 +227,6 @@ export class ListView<T> implements ISpliceable<T>, IDisposable { ...@@ -227,7 +227,6 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
private setRowLineHeight: boolean; private setRowLineHeight: boolean;
private setRowHeight: boolean; private setRowHeight: boolean;
private supportDynamicHeights: boolean; private supportDynamicHeights: boolean;
private horizontalScrolling: boolean;
private additionalScrollHeight: number; private additionalScrollHeight: number;
private accessibilityProvider: ListViewAccessibilityProvider<T>; private accessibilityProvider: ListViewAccessibilityProvider<T>;
private scrollWidth: number | undefined; private scrollWidth: number | undefined;
...@@ -249,6 +248,35 @@ export class ListView<T> implements ISpliceable<T>, IDisposable { ...@@ -249,6 +248,35 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
get onWillScroll(): Event<ScrollEvent> { return this.scrollableElement.onWillScroll; } get onWillScroll(): Event<ScrollEvent> { return this.scrollableElement.onWillScroll; }
get containerDomNode(): HTMLElement { return this.rowsContainer; } get containerDomNode(): HTMLElement { return this.rowsContainer; }
private _horizontalScrolling: boolean = false;
private get horizontalScrolling(): boolean { return this._horizontalScrolling; }
private set horizontalScrolling(value: boolean) {
if (value === this._horizontalScrolling) {
return;
}
if (value && this.supportDynamicHeights) {
throw new Error('Horizontal scrolling and dynamic heights not supported simultaneously');
}
this._horizontalScrolling = value;
DOM.toggleClass(this.domNode, 'horizontal-scrolling', this._horizontalScrolling);
if (this._horizontalScrolling) {
for (const item of this.items) {
this.measureItemWidth(item);
}
this.updateScrollWidth();
this.scrollableElement.setScrollDimensions({ width: DOM.getContentWidth(this.domNode) });
this.rowsContainer.style.width = `${Math.max(this.scrollWidth || 0, this.renderWidth)}px`;
} else {
this.scrollableElementWidthDelayer.cancel();
this.scrollableElement.setScrollDimensions({ width: this.renderWidth, scrollWidth: this.renderWidth });
this.rowsContainer.style.width = '';
}
}
constructor( constructor(
container: HTMLElement, container: HTMLElement,
private virtualDelegate: IListVirtualDelegate<T>, private virtualDelegate: IListVirtualDelegate<T>,
...@@ -280,8 +308,8 @@ export class ListView<T> implements ISpliceable<T>, IDisposable { ...@@ -280,8 +308,8 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
DOM.toggleClass(this.domNode, 'mouse-support', typeof options.mouseSupport === 'boolean' ? options.mouseSupport : true); DOM.toggleClass(this.domNode, 'mouse-support', typeof options.mouseSupport === 'boolean' ? options.mouseSupport : true);
this.horizontalScrolling = getOrDefault(options, o => o.horizontalScrolling, DefaultOptions.horizontalScrolling); this._horizontalScrolling = getOrDefault(options, o => o.horizontalScrolling, DefaultOptions.horizontalScrolling);
DOM.toggleClass(this.domNode, 'horizontal-scrolling', this.horizontalScrolling); DOM.toggleClass(this.domNode, 'horizontal-scrolling', this._horizontalScrolling);
this.additionalScrollHeight = typeof options.additionalScrollHeight === 'undefined' ? 0 : options.additionalScrollHeight; this.additionalScrollHeight = typeof options.additionalScrollHeight === 'undefined' ? 0 : options.additionalScrollHeight;
...@@ -338,27 +366,8 @@ export class ListView<T> implements ISpliceable<T>, IDisposable { ...@@ -338,27 +366,8 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
this.scrollable.setSmoothScrollDuration(options.smoothScrolling ? 125 : 0); this.scrollable.setSmoothScrollDuration(options.smoothScrolling ? 125 : 0);
} }
if (options.horizontalScrolling !== undefined && options.horizontalScrolling !== this.horizontalScrolling) { if (options.horizontalScrolling !== undefined) {
if (options.horizontalScrolling && this.supportDynamicHeights) {
throw new Error('Horizontal scrolling and dynamic heights not supported simultaneously');
}
this.horizontalScrolling = options.horizontalScrolling; this.horizontalScrolling = options.horizontalScrolling;
DOM.toggleClass(this.domNode, 'horizontal-scrolling', this.horizontalScrolling);
if (this.horizontalScrolling) {
for (const item of this.items) {
this.measureItemWidth(item);
}
this.updateScrollWidth();
this.scrollableElement.setScrollDimensions({ width: DOM.getContentWidth(this.domNode) });
this.rowsContainer.style.width = `${Math.max(this.scrollWidth || 0, this.renderWidth)}px`;
} else {
this.scrollableElementWidthDelayer.cancel();
this.scrollableElement.setScrollDimensions({ width: this.renderWidth, scrollWidth: this.renderWidth });
this.rowsContainer.style.width = '';
}
} }
} }
......
...@@ -962,6 +962,7 @@ export interface IAbstractTreeOptionsUpdate extends ITreeRendererOptions { ...@@ -962,6 +962,7 @@ export interface IAbstractTreeOptionsUpdate extends ITreeRendererOptions {
readonly filterOnType?: boolean; readonly filterOnType?: boolean;
readonly openOnSingleClick?: boolean; readonly openOnSingleClick?: boolean;
readonly smoothScrolling?: boolean; readonly smoothScrolling?: boolean;
readonly horizontalScrolling?: boolean;
} }
export interface IAbstractTreeOptions<T, TFilterData = void> extends IAbstractTreeOptionsUpdate, IListOptions<T> { export interface IAbstractTreeOptions<T, TFilterData = void> extends IAbstractTreeOptionsUpdate, IListOptions<T> {
......
...@@ -407,6 +407,10 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable ...@@ -407,6 +407,10 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
this.tree.updateOptions(options); this.tree.updateOptions(options);
} }
get options(): IAsyncDataTreeOptions<T, TFilterData> {
return this.tree.options as IAsyncDataTreeOptions<T, TFilterData>;
}
// Widget // Widget
getHTMLElement(): HTMLElement { getHTMLElement(): HTMLElement {
......
...@@ -141,9 +141,18 @@ export class VariablesView extends ViewPane { ...@@ -141,9 +141,18 @@ export class VariablesView extends ViewPane {
this.onFocusStackFrameScheduler.schedule(); this.onFocusStackFrameScheduler.schedule();
} }
})); }));
let horizontalScrolling: boolean | undefined;
this._register(this.debugService.getViewModel().onDidSelectExpression(e => { this._register(this.debugService.getViewModel().onDidSelectExpression(e => {
if (e instanceof Variable) { if (e instanceof Variable) {
horizontalScrolling = this.tree.options.horizontalScrolling;
if (horizontalScrolling) {
this.tree.updateOptions({ horizontalScrolling: false });
}
this.tree.rerender(e); this.tree.rerender(e);
} else if (!e && horizontalScrolling !== undefined) {
this.tree.updateOptions({ horizontalScrolling: horizontalScrolling });
horizontalScrolling = undefined;
} }
})); }));
this._register(this.debugService.onDidEndSession(() => { this._register(this.debugService.onDidEndSession(() => {
......
...@@ -134,9 +134,18 @@ export class WatchExpressionsView extends ViewPane { ...@@ -134,9 +134,18 @@ export class WatchExpressionsView extends ViewPane {
this.onWatchExpressionsUpdatedScheduler.schedule(); this.onWatchExpressionsUpdatedScheduler.schedule();
} }
})); }));
let horizontalScrolling: boolean | undefined;
this._register(this.debugService.getViewModel().onDidSelectExpression(e => { this._register(this.debugService.getViewModel().onDidSelectExpression(e => {
if (e instanceof Expression && e.name) { if (e instanceof Expression && e.name) {
horizontalScrolling = this.tree.options.horizontalScrolling;
if (horizontalScrolling) {
this.tree.updateOptions({ horizontalScrolling: false });
}
this.tree.rerender(e); this.tree.rerender(e);
} else if (!e && horizontalScrolling !== undefined) {
this.tree.updateOptions({ horizontalScrolling: horizontalScrolling });
horizontalScrolling = undefined;
} }
})); }));
} }
......
...@@ -140,6 +140,8 @@ export class ExplorerView extends ViewPane { ...@@ -140,6 +140,8 @@ export class ExplorerView extends ViewPane {
private compressedFocusFirstContext: IContextKey<boolean>; private compressedFocusFirstContext: IContextKey<boolean>;
private compressedFocusLastContext: IContextKey<boolean>; private compressedFocusLastContext: IContextKey<boolean>;
private horizontalScrolling: boolean | undefined;
// Refresh is needed on the initial explorer open // Refresh is needed on the initial explorer open
private shouldRefresh = true; private shouldRefresh = true;
private dragHandler!: DelayedDragHandler; private dragHandler!: DelayedDragHandler;
...@@ -309,8 +311,19 @@ export class ExplorerView extends ViewPane { ...@@ -309,8 +311,19 @@ export class ExplorerView extends ViewPane {
async setEditable(stat: ExplorerItem, isEditing: boolean): Promise<void> { async setEditable(stat: ExplorerItem, isEditing: boolean): Promise<void> {
if (isEditing) { if (isEditing) {
this.horizontalScrolling = this.tree.options.horizontalScrolling;
if (this.horizontalScrolling) {
this.tree.updateOptions({ horizontalScrolling: false });
}
await this.tree.expand(stat.parent!); await this.tree.expand(stat.parent!);
} else { } else {
if (this.horizontalScrolling !== undefined) {
this.tree.updateOptions({ horizontalScrolling: this.horizontalScrolling });
}
this.horizontalScrolling = undefined;
DOM.removeClass(this.treeContainer, 'highlight'); DOM.removeClass(this.treeContainer, 'highlight');
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册