@theia/core 1.74.0-next.17 → 1.74.0-next.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -355,6 +355,7 @@ export class ApplicationShell extends Widget {
355
355
  });
356
356
  }
357
357
  });
358
+ this.refreshBottomPanelToggleButton();
358
359
  this.initializedDeferred.resolve();
359
360
  }
360
361
 
@@ -689,14 +690,10 @@ export class ApplicationShell extends Widget {
689
690
  spacing: 0
690
691
  }, area => this.doToggleMaximized(area));
691
692
  dockPanel.id = BOTTOM_AREA_ID;
692
- dockPanel.widgetAdded.connect((sender, widget) => {
693
- this.refreshBottomPanelToggleButton();
694
- });
695
693
  dockPanel.widgetRemoved.connect((sender, widget) => {
696
694
  if (sender.isEmpty) {
697
695
  this.collapseBottomPanel();
698
696
  }
699
- this.refreshBottomPanelToggleButton();
700
697
  }, this);
701
698
  dockPanel.node.addEventListener('lm-dragenter', event => {
702
699
  // Make sure that the main panel hides its overlay when the bottom panel is expanded
@@ -887,7 +884,6 @@ export class ApplicationShell extends Widget {
887
884
  }
888
885
  });
889
886
  }
890
- this.refreshBottomPanelToggleButton();
891
887
  }
892
888
  // Proceed with the main panel once all others are set up
893
889
  await this.bottomPanelState.pendingUpdate;
@@ -1570,9 +1566,11 @@ export class ApplicationShell extends Widget {
1570
1566
  let size: number | undefined;
1571
1567
  if (bottomPanel.isEmpty) {
1572
1568
  bottomPanel.node.style.minHeight = '0';
1573
- size = this.options.bottomPanel.emptySize;
1574
- } else if (this.bottomPanelState.lastPanelSize) {
1569
+ }
1570
+ if (this.bottomPanelState.lastPanelSize) {
1575
1571
  size = this.bottomPanelState.lastPanelSize;
1572
+ } else if (bottomPanel.isEmpty) {
1573
+ size = this.options.bottomPanel.emptySize;
1576
1574
  } else {
1577
1575
  size = this.getDefaultBottomPanelSize();
1578
1576
  }
@@ -1631,24 +1629,20 @@ export class ApplicationShell extends Widget {
1631
1629
  * and refers to the command `core.toggle.bottom.panel`.
1632
1630
  */
1633
1631
  protected refreshBottomPanelToggleButton(): void {
1634
- if (this.bottomPanel.isEmpty) {
1635
- this.statusBar.removeElement(BOTTOM_PANEL_TOGGLE_ID);
1636
- } else {
1637
- const label = nls.localize('theia/core/common/collapseBottomPanel', 'Toggle Bottom Panel');
1638
- const element: StatusBarEntry = {
1639
- name: label,
1640
- text: '$(codicon-window)',
1641
- alignment: StatusBarAlignment.RIGHT,
1642
- tooltip: label,
1643
- command: 'core.toggle.bottom.panel',
1644
- accessibilityInformation: {
1645
- label: label,
1646
- role: 'button'
1647
- },
1648
- priority: -1000
1649
- };
1650
- this.statusBar.setElement(BOTTOM_PANEL_TOGGLE_ID, element);
1651
- }
1632
+ const label = nls.localize('theia/core/common/collapseBottomPanel', 'Toggle Bottom Panel');
1633
+ const element: StatusBarEntry = {
1634
+ name: label,
1635
+ text: '$(codicon-window)',
1636
+ alignment: StatusBarAlignment.RIGHT,
1637
+ tooltip: label,
1638
+ command: 'core.toggle.bottom.panel',
1639
+ accessibilityInformation: {
1640
+ label: label,
1641
+ role: 'button'
1642
+ },
1643
+ priority: -1000
1644
+ };
1645
+ this.statusBar.setElement(BOTTOM_PANEL_TOGGLE_ID, element);
1652
1646
  }
1653
1647
 
1654
1648
  /**
@@ -276,6 +276,11 @@
276
276
  background: inherit;
277
277
  }
278
278
 
279
+ /* Ensure the empty bottom panel keeps a top border separating it from the main panel. */
280
+ #theia-bottom-content-panel:not(:has(.lm-TabBar)) {
281
+ border-top: var(--theia-border-width) solid var(--theia-panel-border);
282
+ }
283
+
279
284
  #theia-bottom-content-panel .lm-TabBar-tab {
280
285
  background: inherit;
281
286
  }
@@ -64,28 +64,10 @@ export const TREE_NODE_CAPTION_CLASS = 'theia-TreeNodeCaption';
64
64
  export const TREE_NODE_INDENT_GUIDE_CLASS = 'theia-tree-node-indent';
65
65
 
66
66
  /**
67
- * Threshold in pixels to consider the view as being scrolled to the bottom
67
+ * Threshold in pixels to consider the view as being scrolled to the bottom.
68
68
  */
69
69
  export const SCROLL_BOTTOM_THRESHOLD = 30;
70
70
 
71
- /**
72
- * Tree scroll event data.
73
- */
74
- export interface TreeScrollEvent {
75
- readonly scrollTop: number;
76
- readonly scrollLeft: number;
77
- }
78
-
79
- /**
80
- * Tree scroll state data.
81
- */
82
- export interface TreeScrollState {
83
- readonly scrollTop: number;
84
- readonly isAtBottom: boolean;
85
- readonly scrollHeight?: number;
86
- readonly clientHeight?: number;
87
- }
88
-
89
71
  export const TreeProps = Symbol('TreeProps');
90
72
 
91
73
  /**
@@ -189,8 +171,8 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {
189
171
  protected searchBox: SearchBox;
190
172
  protected searchHighlights: Map<string, TreeDecoration.CaptionHighlight>;
191
173
 
192
- protected readonly onScrollEmitter = new Emitter<TreeScrollEvent>();
193
- readonly onScroll: TheiaEvent<TreeScrollEvent> = this.onScrollEmitter.event;
174
+ protected readonly onAtBottomStateChangeEmitter = new Emitter<boolean>();
175
+ readonly onAtBottomStateChange: TheiaEvent<boolean> = this.onAtBottomStateChangeEmitter.event;
194
176
 
195
177
  @inject(TreeDecoratorService)
196
178
  protected readonly decoratorService: TreeDecoratorService;
@@ -285,7 +267,7 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {
285
267
  this.node.addEventListener('mouseup', this.handleMiddleClickEvent.bind(this));
286
268
  this.node.addEventListener('auxclick', this.handleMiddleClickEvent.bind(this));
287
269
  this.toDispose.pushAll([
288
- this.onScrollEmitter,
270
+ this.onAtBottomStateChangeEmitter,
289
271
  this.model,
290
272
  this.model.onChanged(() => this.updateRows()),
291
273
  this.model.onSelectionChanged(() => this.scheduleUpdateScrollToRow({ resize: false })),
@@ -551,7 +533,7 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {
551
533
  rows={rows}
552
534
  renderNodeRow={this.renderNodeRow}
553
535
  scrollToRow={this.scrollToRow}
554
- onScrollEmitter={this.onScrollEmitter}
536
+ onAtBottomStateChangeEmitter={this.onAtBottomStateChangeEmitter}
555
537
  {...this.props.viewProps}
556
538
  />;
557
539
  }
@@ -1201,39 +1183,6 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {
1201
1183
  return this.node;
1202
1184
  }
1203
1185
 
1204
- /**
1205
- * Get the current scroll state from the virtualized view.
1206
- * This should be used instead of accessing the DOM scroll properties directly
1207
- * when the tree is virtualized.
1208
- */
1209
- protected getVirtualizedScrollState(): TreeScrollState | undefined {
1210
- return this.view?.getScrollState();
1211
- }
1212
-
1213
- /**
1214
- * Check if the tree is scrolled to the bottom.
1215
- * Works with both virtualized and non-virtualized trees.
1216
- */
1217
- isScrolledToBottom(): boolean {
1218
- if (this.props.virtualized !== false && this.view) {
1219
- // Use virtualized scroll state
1220
- const scrollState = this.getVirtualizedScrollState();
1221
- return scrollState?.isAtBottom ?? true;
1222
- } else {
1223
- // Fallback to DOM-based calculation for non-virtualized trees
1224
- const scrollContainer = this.node;
1225
- const scrollHeight = scrollContainer.scrollHeight;
1226
- const scrollTop = scrollContainer.scrollTop;
1227
- const clientHeight = scrollContainer.clientHeight;
1228
-
1229
- if (scrollHeight <= clientHeight) {
1230
- return true;
1231
- }
1232
-
1233
- return scrollHeight - scrollTop - clientHeight <= SCROLL_BOTTOM_THRESHOLD;
1234
- }
1235
- }
1236
-
1237
1186
  protected override onAfterAttach(msg: Message): void {
1238
1187
  const up = [
1239
1188
  Key.ARROW_UP,
@@ -1658,11 +1607,14 @@ export namespace TreeWidget {
1658
1607
  /**
1659
1608
  * Optional scroll event emitter.
1660
1609
  */
1661
- onScrollEmitter?: Emitter<TreeScrollEvent>
1610
+ /**
1611
+ * Optional emitter fired when the at-bottom state changes.
1612
+ */
1613
+ onAtBottomStateChangeEmitter?: Emitter<boolean>
1662
1614
  }
1663
1615
  export class View extends React.Component<ViewProps> {
1664
1616
  list: VirtuosoHandle | undefined;
1665
- private lastScrollState: TreeScrollState = { scrollTop: 0, isAtBottom: true, scrollHeight: 0, clientHeight: 0 };
1617
+
1666
1618
  /**
1667
1619
  * Ensure the selected row is scrolled into view when virtualization finishes updating.
1668
1620
  */
@@ -1687,28 +1639,14 @@ export namespace TreeWidget {
1687
1639
  }
1688
1640
 
1689
1641
  override render(): React.ReactNode {
1690
- const { rows, width, height, scrollToRow, renderNodeRow, onScrollEmitter, ...other } = this.props;
1642
+ const { rows, width, height, scrollToRow, renderNodeRow, onAtBottomStateChangeEmitter, ...other } = this.props;
1691
1643
  return <Virtuoso
1692
1644
  ref={(list: VirtuosoHandle | null) => {
1693
1645
  this.list = (list || undefined);
1694
1646
  this.scrollIntoViewIfNeeded();
1695
1647
  }}
1696
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1697
- onScroll={(e: any) => {
1698
- const scrollTop = e.target.scrollTop;
1699
- const scrollHeight = e.target.scrollHeight;
1700
- const clientHeight = e.target.clientHeight;
1701
- const isAtBottom = scrollHeight - scrollTop - clientHeight <= SCROLL_BOTTOM_THRESHOLD;
1702
-
1703
- // Store scroll state before firing the event to prevent jitter during inference and scrolling
1704
- this.lastScrollState = { scrollTop, isAtBottom, scrollHeight, clientHeight };
1705
- onScrollEmitter?.fire({ scrollTop, scrollLeft: e.target.scrollLeft || 0 });
1706
- }}
1707
1648
  atBottomStateChange={(atBottom: boolean) => {
1708
- this.lastScrollState = {
1709
- ...this.lastScrollState,
1710
- isAtBottom: atBottom
1711
- };
1649
+ onAtBottomStateChangeEmitter?.fire(atBottom);
1712
1650
  }}
1713
1651
  atBottomThreshold={SCROLL_BOTTOM_THRESHOLD}
1714
1652
  totalCount={rows.length}
@@ -1721,9 +1659,5 @@ export namespace TreeWidget {
1721
1659
  {...other}
1722
1660
  />;
1723
1661
  }
1724
-
1725
- getScrollState(): TreeScrollState {
1726
- return { ...this.lastScrollState };
1727
- }
1728
1662
  }
1729
1663
  }