From 5a5c5eca9960c8e2e5bfb98f55d70094d954d7dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Fri, 12 Jun 2020 17:18:55 +0200 Subject: [PATCH] disable horizontal scrolling while rename widget is active fixes #71291 --- src/vs/base/browser/ui/list/listView.ts | 55 +++++++++++-------- src/vs/base/browser/ui/tree/abstractTree.ts | 1 + src/vs/base/browser/ui/tree/asyncDataTree.ts | 4 ++ .../contrib/debug/browser/variablesView.ts | 9 +++ .../debug/browser/watchExpressionsView.ts | 9 +++ .../files/browser/views/explorerView.ts | 13 +++++ 6 files changed, 68 insertions(+), 23 deletions(-) diff --git a/src/vs/base/browser/ui/list/listView.ts b/src/vs/base/browser/ui/list/listView.ts index 46c13636605..e37d80fdd57 100644 --- a/src/vs/base/browser/ui/list/listView.ts +++ b/src/vs/base/browser/ui/list/listView.ts @@ -227,7 +227,6 @@ export class ListView implements ISpliceable, IDisposable { private setRowLineHeight: boolean; private setRowHeight: boolean; private supportDynamicHeights: boolean; - private horizontalScrolling: boolean; private additionalScrollHeight: number; private accessibilityProvider: ListViewAccessibilityProvider; private scrollWidth: number | undefined; @@ -249,6 +248,35 @@ export class ListView implements ISpliceable, IDisposable { get onWillScroll(): Event { return this.scrollableElement.onWillScroll; } 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( container: HTMLElement, private virtualDelegate: IListVirtualDelegate, @@ -280,8 +308,8 @@ export class ListView implements ISpliceable, IDisposable { DOM.toggleClass(this.domNode, 'mouse-support', typeof options.mouseSupport === 'boolean' ? options.mouseSupport : true); - this.horizontalScrolling = getOrDefault(options, o => o.horizontalScrolling, DefaultOptions.horizontalScrolling); - DOM.toggleClass(this.domNode, 'horizontal-scrolling', this.horizontalScrolling); + this._horizontalScrolling = getOrDefault(options, o => o.horizontalScrolling, DefaultOptions.horizontalScrolling); + DOM.toggleClass(this.domNode, 'horizontal-scrolling', this._horizontalScrolling); this.additionalScrollHeight = typeof options.additionalScrollHeight === 'undefined' ? 0 : options.additionalScrollHeight; @@ -338,27 +366,8 @@ export class ListView implements ISpliceable, IDisposable { this.scrollable.setSmoothScrollDuration(options.smoothScrolling ? 125 : 0); } - if (options.horizontalScrolling !== undefined && options.horizontalScrolling !== this.horizontalScrolling) { - if (options.horizontalScrolling && this.supportDynamicHeights) { - throw new Error('Horizontal scrolling and dynamic heights not supported simultaneously'); - } - + if (options.horizontalScrolling !== undefined) { 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 = ''; - } } } diff --git a/src/vs/base/browser/ui/tree/abstractTree.ts b/src/vs/base/browser/ui/tree/abstractTree.ts index ce980749702..1075cdd583e 100644 --- a/src/vs/base/browser/ui/tree/abstractTree.ts +++ b/src/vs/base/browser/ui/tree/abstractTree.ts @@ -962,6 +962,7 @@ export interface IAbstractTreeOptionsUpdate extends ITreeRendererOptions { readonly filterOnType?: boolean; readonly openOnSingleClick?: boolean; readonly smoothScrolling?: boolean; + readonly horizontalScrolling?: boolean; } export interface IAbstractTreeOptions extends IAbstractTreeOptionsUpdate, IListOptions { diff --git a/src/vs/base/browser/ui/tree/asyncDataTree.ts b/src/vs/base/browser/ui/tree/asyncDataTree.ts index 40ad61c10b2..0533836f822 100644 --- a/src/vs/base/browser/ui/tree/asyncDataTree.ts +++ b/src/vs/base/browser/ui/tree/asyncDataTree.ts @@ -407,6 +407,10 @@ export class AsyncDataTree implements IDisposable this.tree.updateOptions(options); } + get options(): IAsyncDataTreeOptions { + return this.tree.options as IAsyncDataTreeOptions; + } + // Widget getHTMLElement(): HTMLElement { diff --git a/src/vs/workbench/contrib/debug/browser/variablesView.ts b/src/vs/workbench/contrib/debug/browser/variablesView.ts index 71aa4f2a074..de19118f1b2 100644 --- a/src/vs/workbench/contrib/debug/browser/variablesView.ts +++ b/src/vs/workbench/contrib/debug/browser/variablesView.ts @@ -141,9 +141,18 @@ export class VariablesView extends ViewPane { this.onFocusStackFrameScheduler.schedule(); } })); + let horizontalScrolling: boolean | undefined; this._register(this.debugService.getViewModel().onDidSelectExpression(e => { if (e instanceof Variable) { + horizontalScrolling = this.tree.options.horizontalScrolling; + if (horizontalScrolling) { + this.tree.updateOptions({ horizontalScrolling: false }); + } + this.tree.rerender(e); + } else if (!e && horizontalScrolling !== undefined) { + this.tree.updateOptions({ horizontalScrolling: horizontalScrolling }); + horizontalScrolling = undefined; } })); this._register(this.debugService.onDidEndSession(() => { diff --git a/src/vs/workbench/contrib/debug/browser/watchExpressionsView.ts b/src/vs/workbench/contrib/debug/browser/watchExpressionsView.ts index e24c688f8d2..724ad7e72d8 100644 --- a/src/vs/workbench/contrib/debug/browser/watchExpressionsView.ts +++ b/src/vs/workbench/contrib/debug/browser/watchExpressionsView.ts @@ -134,9 +134,18 @@ export class WatchExpressionsView extends ViewPane { this.onWatchExpressionsUpdatedScheduler.schedule(); } })); + let horizontalScrolling: boolean | undefined; this._register(this.debugService.getViewModel().onDidSelectExpression(e => { if (e instanceof Expression && e.name) { + horizontalScrolling = this.tree.options.horizontalScrolling; + if (horizontalScrolling) { + this.tree.updateOptions({ horizontalScrolling: false }); + } + this.tree.rerender(e); + } else if (!e && horizontalScrolling !== undefined) { + this.tree.updateOptions({ horizontalScrolling: horizontalScrolling }); + horizontalScrolling = undefined; } })); } diff --git a/src/vs/workbench/contrib/files/browser/views/explorerView.ts b/src/vs/workbench/contrib/files/browser/views/explorerView.ts index ad6502951c0..f09336ff973 100644 --- a/src/vs/workbench/contrib/files/browser/views/explorerView.ts +++ b/src/vs/workbench/contrib/files/browser/views/explorerView.ts @@ -140,6 +140,8 @@ export class ExplorerView extends ViewPane { private compressedFocusFirstContext: IContextKey; private compressedFocusLastContext: IContextKey; + private horizontalScrolling: boolean | undefined; + // Refresh is needed on the initial explorer open private shouldRefresh = true; private dragHandler!: DelayedDragHandler; @@ -309,8 +311,19 @@ export class ExplorerView extends ViewPane { async setEditable(stat: ExplorerItem, isEditing: boolean): Promise { if (isEditing) { + this.horizontalScrolling = this.tree.options.horizontalScrolling; + + if (this.horizontalScrolling) { + this.tree.updateOptions({ horizontalScrolling: false }); + } + await this.tree.expand(stat.parent!); } else { + if (this.horizontalScrolling !== undefined) { + this.tree.updateOptions({ horizontalScrolling: this.horizontalScrolling }); + } + + this.horizontalScrolling = undefined; DOM.removeClass(this.treeContainer, 'highlight'); } -- GitLab