Skip to content

Commit a2daa8d

Browse files
committed
paddingTop/Bottom
1 parent e7dd992 commit a2daa8d

File tree

8 files changed

+38
-38
lines changed

8 files changed

+38
-38
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export interface IPagedListOptions<T> {
108108
readonly mouseSupport?: boolean;
109109
readonly horizontalScrolling?: boolean;
110110
readonly scrollByPage?: boolean;
111-
readonly additionalScrollHeight?: number;
111+
readonly paddingBottom?: number;
112112
}
113113

114114
function fromPagedListOptions<T>(modelProvider: () => IPagedModel<T>, options: IPagedListOptions<T>): IListOptions<number> {

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ export interface IListViewAccessibilityProvider<T> {
5656
}
5757

5858
export interface IListViewOptionsUpdate {
59-
readonly additionalScrollHeight?: number;
6059
readonly smoothScrolling?: boolean;
6160
readonly horizontalScrolling?: boolean;
6261
readonly scrollByPage?: boolean;
6362
readonly mouseWheelScrollSensitivity?: number;
6463
readonly fastScrollSensitivity?: number;
65-
readonly topPadding?: number;
64+
readonly paddingTop?: number;
65+
readonly paddingBottom?: number;
6666
}
6767

6868
export interface IListViewOptions<T> extends IListViewOptionsUpdate {
@@ -281,7 +281,7 @@ export class ListView<T> implements IListView<T> {
281281
private items: IItem<T>[];
282282
private itemId: number;
283283
private rangeMap: RangeMap;
284-
private topPadding: number;
284+
private paddingTop: number;
285285
private cache: RowCache<T>;
286286
private renderers = new Map<string, IListRenderer<any /* TODO@joao */, any>>();
287287
private lastRenderTop: number;
@@ -300,7 +300,7 @@ export class ListView<T> implements IListView<T> {
300300
private setRowLineHeight: boolean;
301301
private setRowHeight: boolean;
302302
private supportDynamicHeights: boolean;
303-
private additionalScrollHeight: number;
303+
private paddingBottom: number;
304304
private accessibilityProvider: ListViewAccessibilityProvider<T>;
305305
private scrollWidth: number | undefined;
306306

@@ -366,8 +366,8 @@ export class ListView<T> implements IListView<T> {
366366

367367
this.items = [];
368368
this.itemId = 0;
369-
this.topPadding = options.topPadding ?? 0;
370-
this.rangeMap = new RangeMap(this.topPadding);
369+
this.paddingTop = options.paddingTop ?? 0;
370+
this.rangeMap = new RangeMap(this.paddingTop);
371371

372372
for (const renderer of renderers) {
373373
this.renderers.set(renderer.templateId, renderer);
@@ -389,7 +389,7 @@ export class ListView<T> implements IListView<T> {
389389
this._horizontalScrolling = options.horizontalScrolling ?? DefaultOptions.horizontalScrolling;
390390
this.domNode.classList.toggle('horizontal-scrolling', this._horizontalScrolling);
391391

392-
this.additionalScrollHeight = typeof options.additionalScrollHeight === 'undefined' ? 0 : options.additionalScrollHeight;
392+
this.paddingBottom = typeof options.paddingBottom === 'undefined' ? 0 : options.paddingBottom;
393393

394394
this.accessibilityProvider = new ListViewAccessibilityProvider(options.accessibilityProvider);
395395

@@ -444,8 +444,8 @@ export class ListView<T> implements IListView<T> {
444444
}
445445

446446
updateOptions(options: IListViewOptionsUpdate) {
447-
if (options.additionalScrollHeight !== undefined) {
448-
this.additionalScrollHeight = options.additionalScrollHeight;
447+
if (options.paddingBottom !== undefined) {
448+
this.paddingBottom = options.paddingBottom;
449449
this.scrollableElement.setScrollDimensions({ scrollHeight: this.scrollHeight });
450450
}
451451

@@ -475,12 +475,12 @@ export class ListView<T> implements IListView<T> {
475475
this.scrollableElement.updateOptions(scrollableOptions);
476476
}
477477

478-
if (options.topPadding !== undefined && options.topPadding !== this.topPadding) {
478+
if (options.paddingTop !== undefined && options.paddingTop !== this.paddingTop) {
479479
// trigger a rerender
480-
this.topPadding = options.topPadding;
480+
this.paddingTop = options.paddingTop;
481481
const lastRenderRange = this.getRenderRange(this.lastRenderTop, this.lastRenderHeight);
482-
const offset = options.topPadding - this.rangeMap.topPadding;
483-
this.rangeMap.topPadding = options.topPadding;
482+
const offset = options.paddingTop - this.rangeMap.paddingTop;
483+
this.rangeMap.paddingTop = options.paddingTop;
484484

485485
this.render(lastRenderRange, Math.max(0, this.lastRenderTop + offset), this.lastRenderHeight, undefined, undefined, true);
486486
this.setScrollTop(this.lastRenderTop);
@@ -622,7 +622,7 @@ export class ListView<T> implements IListView<T> {
622622

623623
// TODO@joao: improve this optimization to catch even more cases
624624
if (start === 0 && deleteCount >= this.items.length) {
625-
this.rangeMap = new RangeMap(this.topPadding);
625+
this.rangeMap = new RangeMap(this.paddingTop);
626626
this.rangeMap.splice(0, 0, inserted);
627627
deleted = this.items;
628628
this.items = inserted;
@@ -1037,7 +1037,7 @@ export class ListView<T> implements IListView<T> {
10371037
}
10381038

10391039
get scrollHeight(): number {
1040-
return this._scrollHeight + (this.horizontalScrolling ? 10 : 0) + this.additionalScrollHeight;
1040+
return this._scrollHeight + (this.horizontalScrolling ? 10 : 0) + this.paddingBottom;
10411041
}
10421042

10431043
// Events

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -991,13 +991,13 @@ export interface IListOptions<T> extends IListOptionsUpdate {
991991
readonly mouseSupport?: boolean;
992992
readonly horizontalScrolling?: boolean;
993993
readonly scrollByPage?: boolean;
994-
readonly additionalScrollHeight?: number;
994+
readonly paddingBottom?: number;
995995
readonly transformOptimization?: boolean;
996996
readonly smoothScrolling?: boolean;
997997
readonly scrollableElementChangeOptions?: ScrollableElementChangeOptions;
998998
readonly alwaysConsumeMouseWheel?: boolean;
999999
readonly initialSize?: Dimension;
1000-
readonly topPadding?: number;
1000+
readonly paddingTop?: number;
10011001
}
10021002

10031003
export interface IListStyles {

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,20 @@ export class RangeMap {
9191

9292
private groups: IRangedGroup[] = [];
9393
private _size = 0;
94-
private _topPadding = 0;
94+
private _paddingTop = 0;
9595

96-
get topPadding() {
97-
return this._topPadding;
96+
get paddingTop() {
97+
return this._paddingTop;
9898
}
9999

100-
set topPadding(topPadding: number) {
101-
this._topPadding = topPadding;
102-
this._size = this._topPadding + this.groups.reduce((t, g) => t + (g.size * (g.range.end - g.range.start)), 0);
100+
set paddingTop(topPadding: number) {
101+
this._paddingTop = topPadding;
102+
this._size = this._paddingTop + this.groups.reduce((t, g) => t + (g.size * (g.range.end - g.range.start)), 0);
103103
}
104104

105105
constructor(topPadding?: number) {
106-
this._topPadding = topPadding || 0;
107-
this._size = this._topPadding;
106+
this._paddingTop = topPadding || 0;
107+
this._size = this._paddingTop;
108108
}
109109

110110
splice(index: number, deleteCount: number, items: IItem[] = []): void {
@@ -119,7 +119,7 @@ export class RangeMap {
119119
}));
120120

121121
this.groups = concat(before, middle, after);
122-
this._size = this._topPadding + this.groups.reduce((t, g) => t + (g.size * (g.range.end - g.range.start)), 0);
122+
this._size = this._paddingTop + this.groups.reduce((t, g) => t + (g.size * (g.range.end - g.range.start)), 0);
123123
}
124124

125125
/**
@@ -150,12 +150,12 @@ export class RangeMap {
150150
return -1;
151151
}
152152

153-
if (position < this._topPadding) {
153+
if (position < this._paddingTop) {
154154
return 0;
155155
}
156156

157157
let index = 0;
158-
let size = this._topPadding;
158+
let size = this._paddingTop;
159159

160160
for (const group of this.groups) {
161161
const count = group.range.end - group.range.start;
@@ -196,7 +196,7 @@ export class RangeMap {
196196
const newCount = count + groupCount;
197197

198198
if (index < newCount) {
199-
return this._topPadding + position + ((index - count) * group.size);
199+
return this._paddingTop + position + ((index - count) * group.size);
200200
}
201201

202202
position += groupCount * group.size;

src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
268268
mouseSupport: true,
269269
multipleSelectionSupport: false,
270270
typeNavigationEnabled: true,
271-
additionalScrollHeight: 0,
271+
paddingBottom: 0,
272272
// transformOptimization: (isMacintosh && isNative) || getTitleBarStyle(this.configurationService, this.environmentService) === 'native',
273273
styleController: (_suffix: string) => { return this._list!; },
274274
overrideStyles: {

src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,10 +869,10 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
869869
multipleSelectionSupport: true,
870870
selectionNavigation: true,
871871
typeNavigationEnabled: true,
872-
additionalScrollHeight: 0,
872+
paddingBottom: 0,
873873
transformOptimization: false, //(isMacintosh && isNative) || getTitleBarStyle(this.configurationService, this.environmentService) === 'native',
874874
initialSize: this._dimension,
875-
topPadding: this._notebookOptions.computeTopInsertToolbarHeight(this.viewModel?.viewType),
875+
paddingTop: this._notebookOptions.computeTopInsertToolbarHeight(this.viewModel?.viewType),
876876
styleController: (_suffix: string) => { return this._list; },
877877
overrideStyles: {
878878
listBackground: notebookEditorBackground,
@@ -1766,12 +1766,12 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
17661766
const newCellListHeight = newBodyHeight;
17671767
if (this._list.getRenderHeight() < newCellListHeight) {
17681768
// the new dimension is larger than the list viewport, update its additional height first, otherwise the list view will move down a bit (as the `scrollBottom` will move down)
1769-
this._list.updateOptions({ additionalScrollHeight: this._allowScrollBeyondLastLine() ? Math.max(0, (newCellListHeight - 50)) : 0, topPadding: topInserToolbarHeight });
1769+
this._list.updateOptions({ paddingBottom: this._allowScrollBeyondLastLine() ? Math.max(0, (newCellListHeight - 50)) : 0, paddingTop: topInserToolbarHeight });
17701770
this._list.layout(newCellListHeight, dimension.width);
17711771
} else {
17721772
// the new dimension is smaller than the list viewport, if we update the additional height, the `scrollBottom` will move up, which moves the whole list view upwards a bit. So we run a layout first.
17731773
this._list.layout(newCellListHeight, dimension.width);
1774-
this._list.updateOptions({ additionalScrollHeight: this._allowScrollBeyondLastLine() ? Math.max(0, (newCellListHeight - 50)) : 0, topPadding: topInserToolbarHeight });
1774+
this._list.updateOptions({ paddingBottom: this._allowScrollBeyondLastLine() ? Math.max(0, (newCellListHeight - 50)) : 0, paddingTop: topInserToolbarHeight });
17751775
}
17761776

17771777
this._overlayContainer.style.visibility = 'visible';

src/vs/workbench/contrib/notebook/test/browser/notebookCellList.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ suite('NotebookCellList', () => {
139139
});
140140

141141
const cellList = createNotebookCellList(instantiationService);
142-
// without additionalscrollheight, the last 20 px will always be hidden due to `topInsertToolbarHeight`
143-
cellList.updateOptions({ additionalScrollHeight: 100 });
142+
// without paddingBottom, the last 20 px will always be hidden due to `topInsertToolbarHeight`
143+
cellList.updateOptions({ paddingBottom: 100 });
144144
cellList.attachViewModel(viewModel);
145145

146146
// render height 210, it can render 3 full cells and 1 partial cell

src/vs/workbench/contrib/terminal/browser/terminalTabsList.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class TerminalTabList extends WorkbenchList<ITerminalInstance> {
9797
accessibilityProvider: instantiationService.createInstance(TerminalTabsAccessibilityProvider),
9898
smoothScrolling: _configurationService.getValue<boolean>('workbench.list.smoothScrolling'),
9999
multipleSelectionSupport: true,
100-
additionalScrollHeight: TerminalTabsListSizes.TabHeight,
100+
paddingBottom: TerminalTabsListSizes.TabHeight,
101101
dnd: instantiationService.createInstance(TerminalTabsDragAndDrop),
102102
openOnSingleClick: true
103103
},

0 commit comments

Comments
 (0)