Skip to content

Commit 5a5c5ec

Browse files
committed
disable horizontal scrolling while rename widget is active
fixes microsoft#71291
1 parent 32a0c9e commit 5a5c5ec

6 files changed

Lines changed: 68 additions & 23 deletions

File tree

src/vs/base/browser/ui/list/listView.ts

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
227227
private setRowLineHeight: boolean;
228228
private setRowHeight: boolean;
229229
private supportDynamicHeights: boolean;
230-
private horizontalScrolling: boolean;
231230
private additionalScrollHeight: number;
232231
private accessibilityProvider: ListViewAccessibilityProvider<T>;
233232
private scrollWidth: number | undefined;
@@ -249,6 +248,35 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
249248
get onWillScroll(): Event<ScrollEvent> { return this.scrollableElement.onWillScroll; }
250249
get containerDomNode(): HTMLElement { return this.rowsContainer; }
251250

251+
private _horizontalScrolling: boolean = false;
252+
private get horizontalScrolling(): boolean { return this._horizontalScrolling; }
253+
private set horizontalScrolling(value: boolean) {
254+
if (value === this._horizontalScrolling) {
255+
return;
256+
}
257+
258+
if (value && this.supportDynamicHeights) {
259+
throw new Error('Horizontal scrolling and dynamic heights not supported simultaneously');
260+
}
261+
262+
this._horizontalScrolling = value;
263+
DOM.toggleClass(this.domNode, 'horizontal-scrolling', this._horizontalScrolling);
264+
265+
if (this._horizontalScrolling) {
266+
for (const item of this.items) {
267+
this.measureItemWidth(item);
268+
}
269+
270+
this.updateScrollWidth();
271+
this.scrollableElement.setScrollDimensions({ width: DOM.getContentWidth(this.domNode) });
272+
this.rowsContainer.style.width = `${Math.max(this.scrollWidth || 0, this.renderWidth)}px`;
273+
} else {
274+
this.scrollableElementWidthDelayer.cancel();
275+
this.scrollableElement.setScrollDimensions({ width: this.renderWidth, scrollWidth: this.renderWidth });
276+
this.rowsContainer.style.width = '';
277+
}
278+
}
279+
252280
constructor(
253281
container: HTMLElement,
254282
private virtualDelegate: IListVirtualDelegate<T>,
@@ -280,8 +308,8 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
280308

281309
DOM.toggleClass(this.domNode, 'mouse-support', typeof options.mouseSupport === 'boolean' ? options.mouseSupport : true);
282310

283-
this.horizontalScrolling = getOrDefault(options, o => o.horizontalScrolling, DefaultOptions.horizontalScrolling);
284-
DOM.toggleClass(this.domNode, 'horizontal-scrolling', this.horizontalScrolling);
311+
this._horizontalScrolling = getOrDefault(options, o => o.horizontalScrolling, DefaultOptions.horizontalScrolling);
312+
DOM.toggleClass(this.domNode, 'horizontal-scrolling', this._horizontalScrolling);
285313

286314
this.additionalScrollHeight = typeof options.additionalScrollHeight === 'undefined' ? 0 : options.additionalScrollHeight;
287315

@@ -338,27 +366,8 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
338366
this.scrollable.setSmoothScrollDuration(options.smoothScrolling ? 125 : 0);
339367
}
340368

341-
if (options.horizontalScrolling !== undefined && options.horizontalScrolling !== this.horizontalScrolling) {
342-
if (options.horizontalScrolling && this.supportDynamicHeights) {
343-
throw new Error('Horizontal scrolling and dynamic heights not supported simultaneously');
344-
}
345-
369+
if (options.horizontalScrolling !== undefined) {
346370
this.horizontalScrolling = options.horizontalScrolling;
347-
DOM.toggleClass(this.domNode, 'horizontal-scrolling', this.horizontalScrolling);
348-
349-
if (this.horizontalScrolling) {
350-
for (const item of this.items) {
351-
this.measureItemWidth(item);
352-
}
353-
354-
this.updateScrollWidth();
355-
this.scrollableElement.setScrollDimensions({ width: DOM.getContentWidth(this.domNode) });
356-
this.rowsContainer.style.width = `${Math.max(this.scrollWidth || 0, this.renderWidth)}px`;
357-
} else {
358-
this.scrollableElementWidthDelayer.cancel();
359-
this.scrollableElement.setScrollDimensions({ width: this.renderWidth, scrollWidth: this.renderWidth });
360-
this.rowsContainer.style.width = '';
361-
}
362371
}
363372
}
364373

src/vs/base/browser/ui/tree/abstractTree.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,7 @@ export interface IAbstractTreeOptionsUpdate extends ITreeRendererOptions {
962962
readonly filterOnType?: boolean;
963963
readonly openOnSingleClick?: boolean;
964964
readonly smoothScrolling?: boolean;
965+
readonly horizontalScrolling?: boolean;
965966
}
966967

967968
export interface IAbstractTreeOptions<T, TFilterData = void> extends IAbstractTreeOptionsUpdate, IListOptions<T> {

src/vs/base/browser/ui/tree/asyncDataTree.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,10 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
407407
this.tree.updateOptions(options);
408408
}
409409

410+
get options(): IAsyncDataTreeOptions<T, TFilterData> {
411+
return this.tree.options as IAsyncDataTreeOptions<T, TFilterData>;
412+
}
413+
410414
// Widget
411415

412416
getHTMLElement(): HTMLElement {

src/vs/workbench/contrib/debug/browser/variablesView.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,18 @@ export class VariablesView extends ViewPane {
141141
this.onFocusStackFrameScheduler.schedule();
142142
}
143143
}));
144+
let horizontalScrolling: boolean | undefined;
144145
this._register(this.debugService.getViewModel().onDidSelectExpression(e => {
145146
if (e instanceof Variable) {
147+
horizontalScrolling = this.tree.options.horizontalScrolling;
148+
if (horizontalScrolling) {
149+
this.tree.updateOptions({ horizontalScrolling: false });
150+
}
151+
146152
this.tree.rerender(e);
153+
} else if (!e && horizontalScrolling !== undefined) {
154+
this.tree.updateOptions({ horizontalScrolling: horizontalScrolling });
155+
horizontalScrolling = undefined;
147156
}
148157
}));
149158
this._register(this.debugService.onDidEndSession(() => {

src/vs/workbench/contrib/debug/browser/watchExpressionsView.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,18 @@ export class WatchExpressionsView extends ViewPane {
134134
this.onWatchExpressionsUpdatedScheduler.schedule();
135135
}
136136
}));
137+
let horizontalScrolling: boolean | undefined;
137138
this._register(this.debugService.getViewModel().onDidSelectExpression(e => {
138139
if (e instanceof Expression && e.name) {
140+
horizontalScrolling = this.tree.options.horizontalScrolling;
141+
if (horizontalScrolling) {
142+
this.tree.updateOptions({ horizontalScrolling: false });
143+
}
144+
139145
this.tree.rerender(e);
146+
} else if (!e && horizontalScrolling !== undefined) {
147+
this.tree.updateOptions({ horizontalScrolling: horizontalScrolling });
148+
horizontalScrolling = undefined;
140149
}
141150
}));
142151
}

src/vs/workbench/contrib/files/browser/views/explorerView.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ export class ExplorerView extends ViewPane {
140140
private compressedFocusFirstContext: IContextKey<boolean>;
141141
private compressedFocusLastContext: IContextKey<boolean>;
142142

143+
private horizontalScrolling: boolean | undefined;
144+
143145
// Refresh is needed on the initial explorer open
144146
private shouldRefresh = true;
145147
private dragHandler!: DelayedDragHandler;
@@ -309,8 +311,19 @@ export class ExplorerView extends ViewPane {
309311

310312
async setEditable(stat: ExplorerItem, isEditing: boolean): Promise<void> {
311313
if (isEditing) {
314+
this.horizontalScrolling = this.tree.options.horizontalScrolling;
315+
316+
if (this.horizontalScrolling) {
317+
this.tree.updateOptions({ horizontalScrolling: false });
318+
}
319+
312320
await this.tree.expand(stat.parent!);
313321
} else {
322+
if (this.horizontalScrolling !== undefined) {
323+
this.tree.updateOptions({ horizontalScrolling: this.horizontalScrolling });
324+
}
325+
326+
this.horizontalScrolling = undefined;
314327
DOM.removeClass(this.treeContainer, 'highlight');
315328
}
316329

0 commit comments

Comments
 (0)