@theia/core 1.78.0-next.19 → 1.78.0-next.23
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.
- package/lib/browser/catalog.json +39 -0
- package/lib/browser/shell/application-shell.d.ts.map +1 -1
- package/lib/browser/shell/application-shell.js +13 -1
- package/lib/browser/shell/application-shell.js.map +1 -1
- package/lib/browser/shell/tab-bars.d.ts +71 -1
- package/lib/browser/shell/tab-bars.d.ts.map +1 -1
- package/lib/browser/shell/tab-bars.js +243 -8
- package/lib/browser/shell/tab-bars.js.map +1 -1
- package/lib/browser/shell/tab-bars.spec.js +382 -2
- package/lib/browser/shell/tab-bars.spec.js.map +1 -1
- package/lib/browser/widgets/widget.d.ts.map +1 -1
- package/lib/browser/widgets/widget.js +34 -1
- package/lib/browser/widgets/widget.js.map +1 -1
- package/lib/common/core-preferences.d.ts +1 -0
- package/lib/common/core-preferences.d.ts.map +1 -1
- package/lib/common/core-preferences.js +10 -0
- package/lib/common/core-preferences.js.map +1 -1
- package/lib/common/messaging/socket-write-buffer.d.ts +8 -2
- package/lib/common/messaging/socket-write-buffer.d.ts.map +1 -1
- package/lib/common/messaging/socket-write-buffer.js +18 -12
- package/lib/common/messaging/socket-write-buffer.js.map +1 -1
- package/lib/common/messaging/socket-write-buffer.spec.d.ts +2 -0
- package/lib/common/messaging/socket-write-buffer.spec.d.ts.map +1 -0
- package/lib/common/messaging/socket-write-buffer.spec.js +72 -0
- package/lib/common/messaging/socket-write-buffer.spec.js.map +1 -0
- package/package.json +4 -4
- package/src/browser/shell/application-shell.ts +14 -1
- package/src/browser/shell/tab-bars.spec.ts +431 -2
- package/src/browser/shell/tab-bars.ts +261 -9
- package/src/browser/style/tabs.css +58 -3
- package/src/browser/widgets/widget.ts +36 -1
- package/src/common/core-preferences.ts +11 -0
- package/src/common/messaging/socket-write-buffer.spec.ts +90 -0
- package/src/common/messaging/socket-write-buffer.ts +18 -14
|
@@ -31,8 +31,8 @@ import { IconThemeService } from '../icon-theme-service.js';
|
|
|
31
31
|
import { BreadcrumbsRenderer, BreadcrumbsRendererFactory } from '../breadcrumbs/breadcrumbs-renderer.js';
|
|
32
32
|
import { NavigatableWidget } from '../navigatable-types.js';
|
|
33
33
|
import { Drag } from '@lumino/dragdrop';
|
|
34
|
-
import { isPinned, LOCKED_CLASS } from '../widgets/widget.js';
|
|
35
|
-
import { CorePreferences } from '../../common/core-preferences.js';
|
|
34
|
+
import { isPinned, LOCKED_CLASS, PINNED_CLASS, pin, unpin } from '../widgets/widget.js';
|
|
35
|
+
import { CoreConfiguration, CorePreferences } from '../../common/core-preferences.js';
|
|
36
36
|
import { HoverService } from '../hover-service.js';
|
|
37
37
|
import { Root, createRoot } from 'react-dom/client';
|
|
38
38
|
import { SelectComponent } from '../widgets/select-component.js';
|
|
@@ -737,18 +737,43 @@ export interface TabBarPrivateMethods {
|
|
|
737
737
|
_releaseMouse(): void;
|
|
738
738
|
}
|
|
739
739
|
|
|
740
|
+
/**
|
|
741
|
+
* Custom property carrying the sticky `left` offset of a shrunk pinned tab. It is
|
|
742
|
+
* consumed by the `theia-pinned-tab-shrink` rules in tabs.css. The offset is not
|
|
743
|
+
* applied as an inline `left` style because lumino positions the tabs with inline
|
|
744
|
+
* `left` styles while dragging, which would be confused with the sticky offset.
|
|
745
|
+
*/
|
|
746
|
+
const PINNED_TAB_OFFSET_PROPERTY = '--theia-pinned-tab-offset';
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* Custom property carrying the fixed width of a shrunk pinned tab. It is consumed
|
|
750
|
+
* by the `theia-pinned-tab-shrink` rules in tabs.css and set on the tab bar node
|
|
751
|
+
* from `ScrollableTabBar.DEFAULT_PINNED_TAB_SIZE`, so that the CSS rules and the
|
|
752
|
+
* tab layout logic share a single source for the value.
|
|
753
|
+
*/
|
|
754
|
+
const PINNED_TAB_SIZE_PROPERTY = '--theia-pinned-tab-size';
|
|
755
|
+
|
|
740
756
|
/**
|
|
741
757
|
* A specialized tab bar for the main and bottom areas.
|
|
742
758
|
*/
|
|
743
759
|
export class ScrollableTabBar extends TabBar<Widget> {
|
|
744
760
|
|
|
761
|
+
/**
|
|
762
|
+
* The fixed width of a shrunk pinned tab when no dynamic tab sizing is
|
|
763
|
+
* configured. Published to CSS as the `--theia-pinned-tab-size` custom property.
|
|
764
|
+
*/
|
|
765
|
+
static readonly DEFAULT_PINNED_TAB_SIZE = 80;
|
|
766
|
+
|
|
745
767
|
protected scrollBar: PerfectScrollbar | undefined;
|
|
746
768
|
|
|
747
769
|
protected pendingReveal?: Promise<void>;
|
|
748
770
|
protected isMouseOver = false;
|
|
749
771
|
protected needsRecompute = false;
|
|
750
772
|
protected tabSize = 0;
|
|
773
|
+
protected pinnedTabWidth = 0;
|
|
774
|
+
protected _pinnedTabSizingMode: ScrollableTabBar.PinnedTabSizingMode | undefined;
|
|
751
775
|
protected _dynamicTabOptions?: ScrollableTabBar.Options;
|
|
776
|
+
protected pinnedTabDragStartFrame?: number;
|
|
752
777
|
protected contentContainer: HTMLElement;
|
|
753
778
|
protected topRow: HTMLElement;
|
|
754
779
|
|
|
@@ -759,6 +784,8 @@ export class ScrollableTabBar extends TabBar<Widget> {
|
|
|
759
784
|
constructor(options?: TabBar.IOptions<Widget>, protected readonly scrollbarOptions?: PerfectScrollbar.Options, dynamicTabOptions?: ScrollableTabBar.Options) {
|
|
760
785
|
super(options);
|
|
761
786
|
this._dynamicTabOptions = dynamicTabOptions;
|
|
787
|
+
this.tabMoved.connect(this.onTabMoved, this);
|
|
788
|
+
this.node.style.setProperty(PINNED_TAB_SIZE_PROPERTY, `${ScrollableTabBar.DEFAULT_PINNED_TAB_SIZE}px`);
|
|
762
789
|
this.topRow = document.createElement('div');
|
|
763
790
|
this.topRow.classList.add('theia-tabBar-tab-row');
|
|
764
791
|
this.node.appendChild(this.topRow);
|
|
@@ -788,6 +815,141 @@ export class ScrollableTabBar extends TabBar<Widget> {
|
|
|
788
815
|
return this._dynamicTabOptions;
|
|
789
816
|
}
|
|
790
817
|
|
|
818
|
+
set pinnedTabSizingMode(mode: ScrollableTabBar.PinnedTabSizingMode | undefined) {
|
|
819
|
+
this._pinnedTabSizingMode = mode;
|
|
820
|
+
this.node.classList.remove('theia-pinned-tab-shrink');
|
|
821
|
+
if (mode === 'shrink') {
|
|
822
|
+
this.node.classList.add('theia-pinned-tab-shrink');
|
|
823
|
+
}
|
|
824
|
+
this.updateTabs();
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
get pinnedTabSizingMode(): ScrollableTabBar.PinnedTabSizingMode | undefined {
|
|
828
|
+
return this._pinnedTabSizingMode;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Updates both dynamic tab options and pinned tab sizing mode with a single tab bar refresh.
|
|
833
|
+
*/
|
|
834
|
+
updateTabOptions(dynamicTabOptions: ScrollableTabBar.Options | undefined, pinnedTabSizingMode: ScrollableTabBar.PinnedTabSizingMode | undefined): void {
|
|
835
|
+
this._dynamicTabOptions = dynamicTabOptions;
|
|
836
|
+
this._pinnedTabSizingMode = pinnedTabSizingMode;
|
|
837
|
+
this.node.classList.remove('theia-pinned-tab-shrink');
|
|
838
|
+
if (pinnedTabSizingMode === 'shrink') {
|
|
839
|
+
this.node.classList.add('theia-pinned-tab-shrink');
|
|
840
|
+
}
|
|
841
|
+
this.updateTabs();
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
override insertTab(index: number, value: Title<Widget> | Title.IOptions<Widget>): Title<Widget> {
|
|
845
|
+
return super.insertTab(this.adjustIndexForPinnedTabs(index, value), value);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Shrunk pinned tabs are sticky and aligned on the left edge of the tab bar, so pinned
|
|
850
|
+
* titles must always precede unpinned ones. Clamp the insertion index to keep an unpinned
|
|
851
|
+
* title from being placed within the pinned tabs, and a pinned title from being placed
|
|
852
|
+
* after unpinned ones.
|
|
853
|
+
*/
|
|
854
|
+
protected adjustIndexForPinnedTabs(index: number, value: Title<Widget> | Title.IOptions<Widget>): number {
|
|
855
|
+
if (this.pinnedTabSizingMode !== 'shrink') {
|
|
856
|
+
return index;
|
|
857
|
+
}
|
|
858
|
+
let title: Title<Widget> | undefined;
|
|
859
|
+
let pinned: boolean;
|
|
860
|
+
if (value instanceof Title) {
|
|
861
|
+
title = value;
|
|
862
|
+
pinned = isPinned(value);
|
|
863
|
+
} else {
|
|
864
|
+
pinned = value.closable === false && (value.className?.includes(PINNED_CLASS) ?? false);
|
|
865
|
+
}
|
|
866
|
+
let pinnedCount = 0;
|
|
867
|
+
for (const t of this.titles) {
|
|
868
|
+
if (isPinned(t)) {
|
|
869
|
+
pinnedCount++;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
if (pinned) {
|
|
873
|
+
// A pinned title that is already in the tab bar is moved rather than inserted,
|
|
874
|
+
// so it must not be counted when computing the size of the pinned group.
|
|
875
|
+
const moved = title !== undefined && this.titles.indexOf(title) !== -1;
|
|
876
|
+
return Math.max(0, Math.min(index, pinnedCount - (moved ? 1 : 0)));
|
|
877
|
+
}
|
|
878
|
+
return Math.max(index, pinnedCount);
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* Keep the pinned group consistent when tabs are dragged: an
|
|
883
|
+
* unpinned tab dropped in front of the pinned tabs is pinned, and a pinned tab
|
|
884
|
+
* dragged out of the pinned group is unpinned.
|
|
885
|
+
*/
|
|
886
|
+
protected onTabMoved(sender: TabBar<Widget>, args: TabBar.ITabMovedArgs<Widget>): void {
|
|
887
|
+
const title = args.title;
|
|
888
|
+
const pinnedCount = this.titles.filter(t => isPinned(t)).length;
|
|
889
|
+
if (isPinned(title) && args.toIndex >= pinnedCount) {
|
|
890
|
+
unpin(title);
|
|
891
|
+
} else if (!isPinned(title) && args.toIndex < pinnedCount) {
|
|
892
|
+
pin(title);
|
|
893
|
+
} else {
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
this.insertTab(args.toIndex, title);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* Move pinned titles to the start of the tab bar so that the sticky pinned tabs stay
|
|
901
|
+
* aligned on the left edge. Titles keep their relative order.
|
|
902
|
+
*/
|
|
903
|
+
protected enforcePinnedTabsFirst(): void {
|
|
904
|
+
if (this.pinnedTabSizingMode !== 'shrink') {
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
const titles = this.titles.slice();
|
|
908
|
+
let pinnedCount = 0;
|
|
909
|
+
for (let i = 0; i < titles.length; i++) {
|
|
910
|
+
const title = titles[i];
|
|
911
|
+
if (isPinned(title)) {
|
|
912
|
+
if (i !== pinnedCount) {
|
|
913
|
+
this.insertTab(pinnedCount, title);
|
|
914
|
+
}
|
|
915
|
+
pinnedCount++;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* Whether pinned tabs are shrunk and sticky: aligned on the left edge of a
|
|
922
|
+
* horizontal tab bar, where they must stack above the tabs scrolled underneath them.
|
|
923
|
+
*/
|
|
924
|
+
protected get pinnedTabsAreSticky(): boolean {
|
|
925
|
+
return this.pinnedTabSizingMode === 'shrink' && this.orientation === 'horizontal';
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
/**
|
|
929
|
+
* The width of a shrunk pinned tab: the dynamic tab size if configured,
|
|
930
|
+
* otherwise `DEFAULT_PINNED_TAB_SIZE`, applied to the tabs by CSS.
|
|
931
|
+
*/
|
|
932
|
+
protected getPinnedTabWidth(): number {
|
|
933
|
+
return this.pinnedTabWidth > 0 ? this.pinnedTabWidth : ScrollableTabBar.DEFAULT_PINNED_TAB_SIZE;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* The total width of the sticky pinned tabs aligned on the left edge of the
|
|
938
|
+
* tab bar, or 0 if pinned tabs are not shrunk and sticky.
|
|
939
|
+
*/
|
|
940
|
+
protected getPinnedTabsWidth(): number {
|
|
941
|
+
if (!this.pinnedTabsAreSticky) {
|
|
942
|
+
return 0;
|
|
943
|
+
}
|
|
944
|
+
let pinnedCount = 0;
|
|
945
|
+
for (const title of this.titles) {
|
|
946
|
+
if (isPinned(title)) {
|
|
947
|
+
pinnedCount++;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
return pinnedCount * this.getPinnedTabWidth();
|
|
951
|
+
}
|
|
952
|
+
|
|
791
953
|
override dispose(): void {
|
|
792
954
|
if (this.isDisposed) {
|
|
793
955
|
return;
|
|
@@ -813,6 +975,38 @@ export class ScrollableTabBar extends TabBar<Widget> {
|
|
|
813
975
|
(this as unknown as TabBarPrivateMethods)._releaseMouse();
|
|
814
976
|
}
|
|
815
977
|
|
|
978
|
+
override handleEvent(event: Event): void {
|
|
979
|
+
const wasDragging = this.node.classList.contains('lm-mod-dragging');
|
|
980
|
+
super.handleEvent(event);
|
|
981
|
+
// Lumino adds `lm-mod-dragging` to the tab bar once a tab drag is activated.
|
|
982
|
+
if (event.type === 'pointermove' && !wasDragging && this.pinnedTabSizingMode === 'shrink'
|
|
983
|
+
&& this.node.classList.contains('lm-mod-dragging')) {
|
|
984
|
+
this.suspendPinnedTabTransitionsOnDragStart();
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* Suspend the `left` transition of pinned tabs for the frame in which a drag
|
|
990
|
+
* starts. A pinned tab switches from sticky to relative positioning at drag
|
|
991
|
+
* start so that lumino's inline `left` drag positions apply, and that switch
|
|
992
|
+
* changes the meaning of the `left` offset: animating it would make the tab
|
|
993
|
+
* jump by its sticky offset and slide back. The class is removed again after
|
|
994
|
+
* the next frame, so lumino's `transition: left 150ms ease` slides the pinned
|
|
995
|
+
* tabs for the rest of the drag.
|
|
996
|
+
*/
|
|
997
|
+
protected suspendPinnedTabTransitionsOnDragStart(): void {
|
|
998
|
+
if (this.pinnedTabDragStartFrame !== undefined) {
|
|
999
|
+
window.cancelAnimationFrame(this.pinnedTabDragStartFrame);
|
|
1000
|
+
}
|
|
1001
|
+
this.node.classList.add('theia-pinned-tab-drag-start');
|
|
1002
|
+
this.pinnedTabDragStartFrame = window.requestAnimationFrame(() => {
|
|
1003
|
+
this.pinnedTabDragStartFrame = window.requestAnimationFrame(() => {
|
|
1004
|
+
this.pinnedTabDragStartFrame = undefined;
|
|
1005
|
+
this.node.classList.remove('theia-pinned-tab-drag-start');
|
|
1006
|
+
});
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
|
|
816
1010
|
protected override onAfterAttach(msg: Message): void {
|
|
817
1011
|
this.node.addEventListener('mouseenter', () => { this.isMouseOver = true; });
|
|
818
1012
|
this.node.addEventListener('mouseleave', () => {
|
|
@@ -836,6 +1030,7 @@ export class ScrollableTabBar extends TabBar<Widget> {
|
|
|
836
1030
|
}
|
|
837
1031
|
|
|
838
1032
|
protected updateTabs(): void {
|
|
1033
|
+
this.enforcePinnedTabsFirst();
|
|
839
1034
|
const content = [];
|
|
840
1035
|
if (this.dynamicTabOptions) {
|
|
841
1036
|
|
|
@@ -857,14 +1052,31 @@ export class ScrollableTabBar extends TabBar<Widget> {
|
|
|
857
1052
|
if (!this.openTabsContainer.classList.contains('lm-mod-hidden')) {
|
|
858
1053
|
availableWidth += this.openTabsContainer.getBoundingClientRect().width;
|
|
859
1054
|
}
|
|
860
|
-
|
|
1055
|
+
const pinnedTabSize = this.dynamicTabOptions.pinnedTabSize;
|
|
1056
|
+
const pinnedCount = pinnedTabSize ? this.titles.filter(t => isPinned(t)).length : 0;
|
|
1057
|
+
const unpinnedCount = this.titles.length - pinnedCount;
|
|
1058
|
+
const pinnedWidth = pinnedCount * (pinnedTabSize ?? 0);
|
|
1059
|
+
const requiredWidth = pinnedWidth + this.dynamicTabOptions.minimumTabSize * unpinnedCount;
|
|
1060
|
+
if (requiredWidth <= availableWidth) {
|
|
861
1061
|
effectiveWidth += this.openTabsContainer.getBoundingClientRect().width;
|
|
862
1062
|
this.openTabsContainer.classList.add('lm-mod-hidden');
|
|
863
1063
|
} else {
|
|
864
1064
|
this.openTabsContainer.classList.remove('lm-mod-hidden');
|
|
865
1065
|
}
|
|
866
|
-
|
|
867
|
-
this.
|
|
1066
|
+
if (pinnedCount > 0 && pinnedTabSize) {
|
|
1067
|
+
this.pinnedTabWidth = pinnedTabSize;
|
|
1068
|
+
if (unpinnedCount > 0) {
|
|
1069
|
+
const remainingWidth = effectiveWidth - pinnedWidth;
|
|
1070
|
+
this.tabSize = Math.max(Math.min(remainingWidth / unpinnedCount,
|
|
1071
|
+
this.dynamicTabOptions.defaultTabSize), this.dynamicTabOptions.minimumTabSize);
|
|
1072
|
+
} else {
|
|
1073
|
+
this.tabSize = this.dynamicTabOptions.defaultTabSize;
|
|
1074
|
+
}
|
|
1075
|
+
} else {
|
|
1076
|
+
this.pinnedTabWidth = 0;
|
|
1077
|
+
this.tabSize = Math.max(Math.min(effectiveWidth / this.titles.length,
|
|
1078
|
+
this.dynamicTabOptions.defaultTabSize), this.dynamicTabOptions.minimumTabSize);
|
|
1079
|
+
}
|
|
868
1080
|
}
|
|
869
1081
|
}
|
|
870
1082
|
this.node.classList.add('dynamic-tabs');
|
|
@@ -872,17 +1084,22 @@ export class ScrollableTabBar extends TabBar<Widget> {
|
|
|
872
1084
|
this.openTabsContainer.classList.add('lm-mod-hidden');
|
|
873
1085
|
this.node.classList.remove('dynamic-tabs');
|
|
874
1086
|
}
|
|
1087
|
+
const sticky = this.pinnedTabsAreSticky;
|
|
1088
|
+
const stickyPinnedCount = sticky ? this.titles.filter(t => isPinned(t)).length : 0;
|
|
875
1089
|
for (let i = 0, n = this.titles.length; i < n; ++i) {
|
|
876
1090
|
const title = this.titles[i];
|
|
877
1091
|
const current = title === this.currentTitle;
|
|
878
|
-
const zIndex = current ? n : n - i - 1;
|
|
1092
|
+
const zIndex = sticky && isPinned(title) ? n + stickyPinnedCount - i : current ? n : n - i - 1;
|
|
879
1093
|
const renderData: ScrollableRenderData = { title: title, current: current, zIndex: zIndex };
|
|
880
1094
|
if (this.dynamicTabOptions && this.orientation === 'horizontal') {
|
|
881
|
-
renderData.tabWidth = this.
|
|
1095
|
+
renderData.tabWidth = this.pinnedTabWidth > 0 && isPinned(title)
|
|
1096
|
+
? this.pinnedTabWidth
|
|
1097
|
+
: this.tabSize;
|
|
882
1098
|
}
|
|
883
1099
|
content[i] = this.renderer.renderTab(renderData);
|
|
884
1100
|
}
|
|
885
1101
|
VirtualDOM.render(content, this.contentNode);
|
|
1102
|
+
this.updatePinnedTabOffsets();
|
|
886
1103
|
if (this.scrollBar) {
|
|
887
1104
|
if (!(this.dynamicTabOptions && this.isMouseOver)) {
|
|
888
1105
|
this.scrollBar.update();
|
|
@@ -890,6 +1107,31 @@ export class ScrollableTabBar extends TabBar<Widget> {
|
|
|
890
1107
|
}
|
|
891
1108
|
}
|
|
892
1109
|
|
|
1110
|
+
/**
|
|
1111
|
+
* Apply the sticky offset of each shrunk pinned tab through the
|
|
1112
|
+
* `PINNED_TAB_OFFSET_PROPERTY` custom property, consumed by the
|
|
1113
|
+
* `theia-pinned-tab-shrink` rules in tabs.css. Sticky pinned tabs stack side
|
|
1114
|
+
* by side at the left edge of the tab bar: each pinned tab sticks at its own
|
|
1115
|
+
* natural position so that they do not overlap.
|
|
1116
|
+
*/
|
|
1117
|
+
protected updatePinnedTabOffsets(): void {
|
|
1118
|
+
const sticky = this.pinnedTabsAreSticky;
|
|
1119
|
+
const tabs = this.contentNode.children;
|
|
1120
|
+
let pinnedTabIndex = 0;
|
|
1121
|
+
for (let i = 0, n = this.titles.length; i < n; ++i) {
|
|
1122
|
+
const tab = tabs[i] as HTMLElement | undefined;
|
|
1123
|
+
if (!tab) {
|
|
1124
|
+
continue;
|
|
1125
|
+
}
|
|
1126
|
+
if (sticky && isPinned(this.titles[i])) {
|
|
1127
|
+
tab.style.setProperty(PINNED_TAB_OFFSET_PROPERTY, `${pinnedTabIndex * this.getPinnedTabWidth()}px`);
|
|
1128
|
+
pinnedTabIndex++;
|
|
1129
|
+
} else {
|
|
1130
|
+
tab.style.removeProperty(PINNED_TAB_OFFSET_PROPERTY);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
|
|
893
1135
|
protected override onResize(msg: Widget.ResizeMessage): void {
|
|
894
1136
|
super.onResize(msg);
|
|
895
1137
|
if (this.dynamicTabOptions) {
|
|
@@ -920,8 +1162,13 @@ export class ScrollableTabBar extends TabBar<Widget> {
|
|
|
920
1162
|
if (this.orientation === 'horizontal') {
|
|
921
1163
|
const scroll = parent.scrollLeft;
|
|
922
1164
|
const left = tab.offsetLeft;
|
|
923
|
-
|
|
924
|
-
|
|
1165
|
+
// Shrunk pinned tabs are sticky and cover the left edge of the tab bar.
|
|
1166
|
+
const pinnedWidth = this.getPinnedTabsWidth();
|
|
1167
|
+
if (pinnedWidth > 0 && isPinned(this.titles[index])) {
|
|
1168
|
+
// Sticky pinned tabs are always visible at the left edge: nothing to reveal.
|
|
1169
|
+
} else if (scroll > left - pinnedWidth) {
|
|
1170
|
+
// Reveal the tab to the right of the sticky pinned tabs.
|
|
1171
|
+
parent.scrollLeft = Math.max(0, left - pinnedWidth);
|
|
925
1172
|
} else {
|
|
926
1173
|
const right = left + tab.clientWidth - parent.clientWidth;
|
|
927
1174
|
if (scroll < right && tab.clientWidth < parent.clientWidth) {
|
|
@@ -957,7 +1204,12 @@ export namespace ScrollableTabBar {
|
|
|
957
1204
|
export interface Options {
|
|
958
1205
|
minimumTabSize: number;
|
|
959
1206
|
defaultTabSize: number;
|
|
1207
|
+
pinnedTabSize?: number;
|
|
960
1208
|
}
|
|
1209
|
+
|
|
1210
|
+
/** Sizing mode of pinned tabs, as configured by the `workbench.editor.pinnedTabSizing` preference. */
|
|
1211
|
+
export type PinnedTabSizingMode = CoreConfiguration['workbench.editor.pinnedTabSizing'];
|
|
1212
|
+
|
|
961
1213
|
export namespace Styles {
|
|
962
1214
|
|
|
963
1215
|
export const TAB_BAR_CONTENT_CONTAINER = 'lm-TabBar-content-container';
|
|
@@ -236,8 +236,8 @@
|
|
|
236
236
|
-ms-user-select: none;
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
.lm-TabBar.theia-app-centers .lm-TabBar-tab.lm-mod-closable.closeIcon-start
|
|
240
|
-
.lm-TabBar.theia-app-centers .lm-TabBar-tab.theia-mod-pinned.closeIcon-start
|
|
239
|
+
.lm-TabBar.theia-app-centers .lm-TabBar-tab.lm-mod-closable.closeIcon-start>.lm-TabBar-tabCloseIcon,
|
|
240
|
+
.lm-TabBar.theia-app-centers .lm-TabBar-tab.theia-mod-pinned.closeIcon-start>.lm-TabBar-tabCloseIcon {
|
|
241
241
|
margin-left: inherit;
|
|
242
242
|
margin-right: 4px;
|
|
243
243
|
}
|
|
@@ -287,6 +287,61 @@
|
|
|
287
287
|
content: "\ebb2";
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
+
/*
|
|
291
|
+
* Shrunk pinned tabs are sticky and aligned on the left edge of the tab bar. Each
|
|
292
|
+
* pinned tab sticks at its own natural position, carried by the
|
|
293
|
+
* `--theia-pinned-tab-offset` custom property set by the tab bar, so that the
|
|
294
|
+
* pinned tabs stack instead of overlapping.
|
|
295
|
+
*/
|
|
296
|
+
.lm-TabBar.theia-app-centers.theia-pinned-tab-shrink .lm-TabBar-tab.theia-mod-pinned {
|
|
297
|
+
position: sticky;
|
|
298
|
+
left: var(--theia-pinned-tab-offset, 0);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/*
|
|
302
|
+
* While a tab is being dragged, lumino positions the tabs with inline `left`
|
|
303
|
+
* styles (relative offsets, see `.lm-TabBar.lm-mod-dragging` in lumino's
|
|
304
|
+
* tabbar.css). The sticky offset must not apply then, and the sticky rule above
|
|
305
|
+
* has a higher specificity than lumino's dragging rules, so it is overridden
|
|
306
|
+
* here. The override is deliberately not `!important` so that lumino's inline
|
|
307
|
+
* drag positions still take precedence, and lumino's `transition: left` slides
|
|
308
|
+
* the pinned tabs for the rest of the drag.
|
|
309
|
+
*/
|
|
310
|
+
.lm-TabBar.theia-app-centers.theia-pinned-tab-shrink.lm-mod-dragging .lm-TabBar-tab.theia-mod-pinned {
|
|
311
|
+
position: relative;
|
|
312
|
+
left: 0;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/*
|
|
316
|
+
* Switching a pinned tab from sticky to relative positioning changes the
|
|
317
|
+
* meaning of its `left` offset, so the switch itself must not be animated:
|
|
318
|
+
* otherwise the tab would jump by its sticky offset and slide back. The tab bar
|
|
319
|
+
* adds this class for the first frame of a drag only.
|
|
320
|
+
*/
|
|
321
|
+
.lm-TabBar.theia-app-centers.theia-pinned-tab-shrink.lm-mod-dragging.theia-pinned-tab-drag-start .lm-TabBar-tab.theia-mod-pinned {
|
|
322
|
+
transition: none;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.lm-TabBar.theia-app-centers.theia-pinned-tab-shrink .lm-TabBar-tab.theia-mod-pinned>.lm-TabBar-tabCloseIcon {
|
|
326
|
+
display: inline-block;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/*
|
|
330
|
+
* The fixed width of a shrunk pinned tab is carried by the `--theia-pinned-tab-size`
|
|
331
|
+
* custom property, which the tab bar sets from `ScrollableTabBar.DEFAULT_PINNED_TAB_SIZE`,
|
|
332
|
+
* so that the CSS rules and the tab layout logic share a single source for the value.
|
|
333
|
+
*/
|
|
334
|
+
.lm-TabBar.theia-app-centers.theia-pinned-tab-shrink:not(.dynamic-tabs) .lm-TabBar-tab.theia-mod-pinned {
|
|
335
|
+
min-width: var(--theia-pinned-tab-size);
|
|
336
|
+
max-width: var(--theia-pinned-tab-size);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.lm-TabBar.theia-app-centers.theia-pinned-tab-shrink .lm-TabBar-tab.theia-mod-pinned .lm-TabBar-tabLabel {
|
|
340
|
+
overflow: hidden;
|
|
341
|
+
text-overflow: ellipsis;
|
|
342
|
+
white-space: nowrap;
|
|
343
|
+
}
|
|
344
|
+
|
|
290
345
|
.lm-TabBar-tabIcon.no-icon {
|
|
291
346
|
display: none !important;
|
|
292
347
|
}
|
|
@@ -417,7 +472,7 @@
|
|
|
417
472
|
cursor: pointer;
|
|
418
473
|
}
|
|
419
474
|
|
|
420
|
-
.lm-TabBar-toolbar
|
|
475
|
+
.lm-TabBar-toolbar> :not(.item.enabled)>.action-label {
|
|
421
476
|
background: transparent;
|
|
422
477
|
cursor: default;
|
|
423
478
|
}
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
18
18
|
|
|
19
19
|
import { injectable, decorate, unmanaged } from 'inversify';
|
|
20
|
-
import { Title, Widget } from '@lumino/widgets';
|
|
20
|
+
import { DockPanel, TabBar, Title, Widget } from '@lumino/widgets';
|
|
21
|
+
import { find } from '@lumino/algorithm';
|
|
21
22
|
import { Message, MessageLoop } from '@lumino/messaging';
|
|
22
23
|
import { Emitter, Event, Disposable, DisposableCollection, MaybePromise, isObject } from '../../common/index.js';
|
|
23
24
|
import { KeyCode, KeysOrKeyCodes } from '../keyboard/keys.js';
|
|
@@ -389,6 +390,38 @@ export function isPinned(title: Title<Widget>): boolean {
|
|
|
389
390
|
return pinnedState;
|
|
390
391
|
}
|
|
391
392
|
|
|
393
|
+
/**
|
|
394
|
+
* Find the tab bar containing the given title, if the title is docked in a dock panel.
|
|
395
|
+
*/
|
|
396
|
+
function findOwningTabBar(title: Title<Widget>): TabBar<Widget> | undefined {
|
|
397
|
+
let parent = title.owner.parent;
|
|
398
|
+
while (parent) {
|
|
399
|
+
if (parent instanceof DockPanel) {
|
|
400
|
+
return find(parent.tabBars(), bar => bar.titles.includes(title));
|
|
401
|
+
}
|
|
402
|
+
parent = parent.parent;
|
|
403
|
+
}
|
|
404
|
+
return undefined;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Move the title within its tab bar so that pinned titles precede unpinned ones,
|
|
409
|
+
* keeping the model order in sync with the visual order of the tab bar.
|
|
410
|
+
* A pinned title is placed at the end of the pinned group, an unpinned title
|
|
411
|
+
* at the start of the unpinned group.
|
|
412
|
+
*/
|
|
413
|
+
function moveToPinnedSection(title: Title<Widget>): void {
|
|
414
|
+
const tabBar = findOwningTabBar(title);
|
|
415
|
+
if (!tabBar) {
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
const titles = tabBar.titles;
|
|
419
|
+
const index = isPinned(title)
|
|
420
|
+
? titles.findIndex(t => !isPinned(t))
|
|
421
|
+
: titles.filter(t => isPinned(t)).length;
|
|
422
|
+
tabBar.insertTab(index === -1 ? titles.length : index, title);
|
|
423
|
+
}
|
|
424
|
+
|
|
392
425
|
export function pin(title: Title<Widget>): void {
|
|
393
426
|
const l = () => {
|
|
394
427
|
pinnedTitles.delete(title);
|
|
@@ -399,6 +432,7 @@ export function pin(title: Title<Widget>): void {
|
|
|
399
432
|
if (!title.className.includes(PINNED_CLASS)) {
|
|
400
433
|
title.className += ` ${PINNED_CLASS}`;
|
|
401
434
|
}
|
|
435
|
+
moveToPinnedSection(title);
|
|
402
436
|
}
|
|
403
437
|
|
|
404
438
|
export function unpin(title: Title<Widget>): void {
|
|
@@ -411,6 +445,7 @@ export function unpin(title: Title<Widget>): void {
|
|
|
411
445
|
title.closable = true;
|
|
412
446
|
}
|
|
413
447
|
title.className = title.className.replace(PINNED_CLASS, '').trim();
|
|
448
|
+
moveToPinnedSection(title);
|
|
414
449
|
}
|
|
415
450
|
|
|
416
451
|
export function isLocked(title: Title<Widget>): boolean {
|
|
@@ -324,6 +324,16 @@ export const corePreferenceSchema: PreferenceSchema = {
|
|
|
324
324
|
minimum: 10,
|
|
325
325
|
description: nls.localize('theia/core/tabDefaultSize', 'Specifies the default size for tabs.')
|
|
326
326
|
},
|
|
327
|
+
'workbench.editor.pinnedTabSizing': {
|
|
328
|
+
type: 'string',
|
|
329
|
+
enum: ['normal', 'shrink'],
|
|
330
|
+
default: 'normal',
|
|
331
|
+
markdownDescription: nls.localize('theia/core/pinnedTabSizing', 'Controls the size of pinned editor tabs. Pinned tabs typically do not close until unpinned. Pinning a tab moves it to the end of the pinned group at the beginning of the tab bar. When set to "shrink", pinned tabs are additionally shown at a compact fixed size.'),
|
|
332
|
+
enumDescriptions: [
|
|
333
|
+
nls.localizeByDefault('A pinned tab inherits the look of non pinned tabs.'),
|
|
334
|
+
nls.localizeByDefault('A pinned tab shrinks to a compact fixed size showing parts of the editor name.')
|
|
335
|
+
]
|
|
336
|
+
},
|
|
327
337
|
'workbench.editorAssociations': {
|
|
328
338
|
type: 'object',
|
|
329
339
|
markdownDescription: nls.localizeByDefault('Configure [glob patterns](https://aka.ms/vscode-glob-patterns) to editors (for example `"*.hex": "hexEditor.hexedit"`). These have precedence over the default behavior.'),
|
|
@@ -368,6 +378,7 @@ export interface CoreConfiguration {
|
|
|
368
378
|
'workbench.tab.shrinkToFit.enabled': boolean;
|
|
369
379
|
'workbench.tab.shrinkToFit.minimumSize': number;
|
|
370
380
|
'workbench.tab.shrinkToFit.defaultSize': number;
|
|
381
|
+
'workbench.editor.pinnedTabSizing': 'normal' | 'shrink';
|
|
371
382
|
}
|
|
372
383
|
|
|
373
384
|
export const CorePreferenceContribution = Symbol('CorePreferenceContribution');
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 CodeSignal and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { expect } from 'chai';
|
|
18
|
+
import { Uint8ArrayReadBuffer, Uint8ArrayWriteBuffer } from '../message-rpc/uint8-array-message-buffer.js';
|
|
19
|
+
import { SocketWriteBuffer } from './socket-write-buffer.js';
|
|
20
|
+
import { WebSocket } from './web-socket-channel.js';
|
|
21
|
+
|
|
22
|
+
function encode(text: string): Uint8Array {
|
|
23
|
+
const buffer = new Uint8ArrayWriteBuffer();
|
|
24
|
+
buffer.writeString(text);
|
|
25
|
+
return buffer.getCurrentContents();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function recordingSocket(): { socket: WebSocket, sent: string[] } {
|
|
29
|
+
const sent: string[] = [];
|
|
30
|
+
const socket = { send: (data: Uint8Array) => sent.push(new Uint8ArrayReadBuffer(data).readString()) } as unknown as WebSocket;
|
|
31
|
+
return { socket, sent };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
describe('SocketWriteBuffer', () => {
|
|
35
|
+
|
|
36
|
+
it('sends each buffered message as its own socket message', () => {
|
|
37
|
+
const buffer = new SocketWriteBuffer();
|
|
38
|
+
['one', 'two', 'three'].forEach(text => buffer.buffer(encode(text)));
|
|
39
|
+
const { socket, sent } = recordingSocket();
|
|
40
|
+
|
|
41
|
+
buffer.flush(socket);
|
|
42
|
+
|
|
43
|
+
expect(sent).to.deep.equal(['one', 'two', 'three']);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('sends nothing again on the next flush', () => {
|
|
47
|
+
const buffer = new SocketWriteBuffer();
|
|
48
|
+
buffer.buffer(encode('one'));
|
|
49
|
+
const { socket, sent } = recordingSocket();
|
|
50
|
+
|
|
51
|
+
buffer.flush(socket);
|
|
52
|
+
buffer.buffer(encode('two'));
|
|
53
|
+
buffer.flush(socket);
|
|
54
|
+
|
|
55
|
+
expect(sent).to.deep.equal(['one', 'two']);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('sends what was buffered even if the caller changes its buffer afterwards', () => {
|
|
59
|
+
const buffer = new SocketWriteBuffer();
|
|
60
|
+
const data = encode('one');
|
|
61
|
+
buffer.buffer(data);
|
|
62
|
+
data.set(encode('two'));
|
|
63
|
+
const { socket, sent } = recordingSocket();
|
|
64
|
+
|
|
65
|
+
buffer.flush(socket);
|
|
66
|
+
|
|
67
|
+
expect(sent).to.deep.equal(['one']);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('copies a Node Buffer too, whose slice() shares memory', () => {
|
|
71
|
+
const buffer = new SocketWriteBuffer();
|
|
72
|
+
const data = Buffer.from(encode('one'));
|
|
73
|
+
buffer.buffer(data);
|
|
74
|
+
data.set(encode('two'));
|
|
75
|
+
const { socket, sent } = recordingSocket();
|
|
76
|
+
|
|
77
|
+
buffer.flush(socket);
|
|
78
|
+
|
|
79
|
+
expect(sent).to.deep.equal(['one']);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('refuses a message that would take it past its size limit until drained', () => {
|
|
83
|
+
const buffer = new SocketWriteBuffer();
|
|
84
|
+
buffer.buffer(new Uint8Array(100 * 1024 - 1));
|
|
85
|
+
|
|
86
|
+
expect(() => buffer.buffer(new Uint8Array(2))).to.throw('Max disconnected buffer size exceeded');
|
|
87
|
+
buffer.drain();
|
|
88
|
+
expect(() => buffer.buffer(new Uint8Array(100 * 1024))).to.not.throw();
|
|
89
|
+
});
|
|
90
|
+
});
|