@opensumi/ide-editor 3.3.1-next-1725288439.0 → 3.3.1-next-1725363936.0
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/editor-collection.service.d.ts +1 -1
- package/lib/browser/editor-collection.service.d.ts.map +1 -1
- package/lib/browser/editor-collection.service.js +2 -2
- package/lib/browser/editor-collection.service.js.map +1 -1
- package/lib/browser/editor.module.less +1 -0
- package/lib/browser/editor.view.js.map +1 -1
- package/lib/browser/workbench-editor.service.d.ts +6 -1
- package/lib/browser/workbench-editor.service.d.ts.map +1 -1
- package/lib/browser/workbench-editor.service.js +118 -74
- package/lib/browser/workbench-editor.service.js.map +1 -1
- package/lib/common/editor.d.ts +1 -1
- package/lib/common/editor.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/browser/editor-collection.service.ts +2 -2
- package/src/browser/editor.module.less +1 -0
- package/src/browser/editor.view.tsx +1 -1
- package/src/browser/workbench-editor.service.ts +105 -75
- package/src/common/editor.ts +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EditorGroup = exports.WorkbenchEditorServiceImpl = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const mobx_1 = require("mobx");
|
|
5
6
|
const di_1 = require("@opensumi/di");
|
|
6
7
|
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
|
|
7
8
|
const resource_1 = require("@opensumi/ide-core-browser/lib/contextkey/resource");
|
|
@@ -120,37 +121,44 @@ let WorkbenchEditorServiceImpl = class WorkbenchEditorServiceImpl extends ide_co
|
|
|
120
121
|
createEditorGroup() {
|
|
121
122
|
const editorGroup = this.injector.get(EditorGroup, [this.generateRandomEditorGroupName(), this.editorGroupIdGen++]);
|
|
122
123
|
this.editorGroups.push(editorGroup);
|
|
123
|
-
editorGroup.
|
|
124
|
-
editorGroup.
|
|
125
|
-
if (editorGroup
|
|
126
|
-
|
|
127
|
-
// 暂时状态,不发事件
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
this._onActiveResourceChange.fire(editorGroup.currentResource);
|
|
131
|
-
}
|
|
124
|
+
const currentWatchDisposer = new ide_core_common_1.Disposable(editorGroup.onDidEditorGroupBodyChanged(() => {
|
|
125
|
+
if (editorGroup === this.currentEditorGroup) {
|
|
126
|
+
if (!editorGroup.currentOpenType && editorGroup.currentResource) {
|
|
127
|
+
// 暂时状态,不发事件
|
|
132
128
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
var _a;
|
|
136
|
-
if (editorGroup === this.currentEditorGroup) {
|
|
137
|
-
if (!editorGroup.currentOpenType && editorGroup.currentResource) {
|
|
138
|
-
// 暂时状态,不发事件
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
this._onActiveEditorUriChange.fire((_a = editorGroup.currentOrPreviousFocusedEditor) === null || _a === void 0 ? void 0 : _a.currentUri);
|
|
142
|
-
}
|
|
129
|
+
else {
|
|
130
|
+
this._onActiveResourceChange.fire(editorGroup.currentResource);
|
|
143
131
|
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this._onCursorChange.fire(e);
|
|
132
|
+
}
|
|
133
|
+
}), editorGroup.onDidEditorFocusChange(() => {
|
|
134
|
+
var _a;
|
|
135
|
+
if (editorGroup === this.currentEditorGroup) {
|
|
136
|
+
if (!editorGroup.currentOpenType && editorGroup.currentResource) {
|
|
137
|
+
// 暂时状态,不发事件
|
|
151
138
|
}
|
|
152
|
-
|
|
153
|
-
|
|
139
|
+
else {
|
|
140
|
+
this._onActiveEditorUriChange.fire((_a = editorGroup.currentOrPreviousFocusedEditor) === null || _a === void 0 ? void 0 : _a.currentUri);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}));
|
|
144
|
+
editorGroup.addDispose({
|
|
145
|
+
dispose: () => {
|
|
146
|
+
currentWatchDisposer.dispose();
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
const groupChangeDisposer = editorGroup.onDidEditorGroupTabChanged(() => {
|
|
150
|
+
this.saveOpenedResourceState();
|
|
151
|
+
});
|
|
152
|
+
editorGroup.addDispose({
|
|
153
|
+
dispose: () => {
|
|
154
|
+
groupChangeDisposer.dispose();
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
editorGroup.onCurrentEditorCursorChange((e) => {
|
|
158
|
+
if (this._currentEditorGroup === editorGroup) {
|
|
159
|
+
this._onCursorChange.fire(e);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
154
162
|
return editorGroup;
|
|
155
163
|
}
|
|
156
164
|
/**
|
|
@@ -489,22 +497,22 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
489
497
|
/**
|
|
490
498
|
* 当编辑器的tab部分发生变更
|
|
491
499
|
*/
|
|
492
|
-
this._onDidEditorGroupTabChanged =
|
|
500
|
+
this._onDidEditorGroupTabChanged = new ide_core_common_1.Emitter();
|
|
493
501
|
this.onDidEditorGroupTabChanged = this._onDidEditorGroupTabChanged.event;
|
|
494
502
|
/**
|
|
495
503
|
* 当编辑器的tab部分发生变更
|
|
496
504
|
*/
|
|
497
|
-
this._onDidEditorGroupTabOperation =
|
|
505
|
+
this._onDidEditorGroupTabOperation = new ide_core_common_1.Emitter();
|
|
498
506
|
this.onDidEditorGroupTabOperation = this._onDidEditorGroupTabOperation.event;
|
|
499
507
|
/**
|
|
500
508
|
* 当编辑器的主体部分发生变更
|
|
501
509
|
*/
|
|
502
|
-
this._onDidEditorGroupBodyChanged =
|
|
510
|
+
this._onDidEditorGroupBodyChanged = new ide_core_common_1.Emitter();
|
|
503
511
|
this.onDidEditorGroupBodyChanged = this._onDidEditorGroupBodyChanged.event;
|
|
504
512
|
/**
|
|
505
513
|
* 当编辑器有内容处于加载状态
|
|
506
514
|
*/
|
|
507
|
-
this._onDidEditorGroupContentLoading =
|
|
515
|
+
this._onDidEditorGroupContentLoading = new ide_core_common_1.Emitter();
|
|
508
516
|
this.onDidEditorGroupContentLoading = this._onDidEditorGroupContentLoading.event;
|
|
509
517
|
/**
|
|
510
518
|
* 每个group只能有一个preview
|
|
@@ -524,10 +532,14 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
524
532
|
this.activeComponents = new Map();
|
|
525
533
|
this.activateComponentsProps = new Map();
|
|
526
534
|
this.holdDocumentModelRefs = new Map();
|
|
535
|
+
this.toDispose = [];
|
|
527
536
|
this._prevDomHeight = 0;
|
|
528
537
|
this._prevDomWidth = 0;
|
|
538
|
+
this._codeEditorPendingLayout = false;
|
|
539
|
+
this._diffEditorPendingLayout = false;
|
|
540
|
+
this._mergeEditorPendingLayout = false;
|
|
529
541
|
// 当前为EditorComponent,且monaco光标变化时触发
|
|
530
|
-
this._onCurrentEditorCursorChange =
|
|
542
|
+
this._onCurrentEditorCursorChange = new ide_core_common_1.Emitter();
|
|
531
543
|
this.onCurrentEditorCursorChange = this._onCurrentEditorCursorChange.event;
|
|
532
544
|
this.resourceOpenHistory = [];
|
|
533
545
|
this._domNode = null;
|
|
@@ -541,24 +553,32 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
541
553
|
this.mergeEditorReady = new ide_core_common_1.ReadyEvent();
|
|
542
554
|
this.mergeEditorDomReady = new ide_core_common_1.ReadyEvent();
|
|
543
555
|
this._restoringState = false;
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
556
|
+
let toDispose;
|
|
557
|
+
this.eventBus.onDirective(ide_core_browser_1.ResizeEvent.createDirective((0, ide_core_browser_1.getSlotLocation)('@opensumi/ide-editor', this.config.layoutConfig)), () => {
|
|
558
|
+
if (toDispose) {
|
|
559
|
+
toDispose.dispose();
|
|
560
|
+
}
|
|
561
|
+
toDispose = ide_core_browser_1.fastdom.mutate(() => {
|
|
562
|
+
this._layoutEditorWorker();
|
|
563
|
+
});
|
|
564
|
+
});
|
|
565
|
+
this.eventBus.on(types_2.GridResizeEvent, (e) => {
|
|
548
566
|
if (e.payload.gridId === this.grid.uid) {
|
|
549
|
-
this.
|
|
567
|
+
this.doLayoutEditors();
|
|
550
568
|
}
|
|
551
|
-
})
|
|
552
|
-
this.
|
|
569
|
+
});
|
|
570
|
+
this.eventBus.on(types_2.EditorComponentDisposeEvent, (e) => {
|
|
553
571
|
this.activeComponents.delete(e.payload);
|
|
554
572
|
this.activateComponentsProps.delete(e.payload);
|
|
555
|
-
})
|
|
573
|
+
});
|
|
556
574
|
this.listenToExplorerAutoRevealConfig();
|
|
557
575
|
}
|
|
558
576
|
listenToExplorerAutoRevealConfig() {
|
|
559
577
|
this.explorerAutoRevealConfig = !!this.preferenceService.get('explorer.autoReveal');
|
|
560
|
-
this.disposables.push(this.preferenceService.
|
|
561
|
-
|
|
578
|
+
this.disposables.push(this.preferenceService.onPreferenceChanged((change) => {
|
|
579
|
+
if (change.preferenceName === 'explorer.autoReveal') {
|
|
580
|
+
this.explorerAutoRevealConfig = change.newValue;
|
|
581
|
+
}
|
|
562
582
|
}));
|
|
563
583
|
}
|
|
564
584
|
attachDiffEditorDom(domNode) {
|
|
@@ -585,30 +605,48 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
585
605
|
layoutEditors() {
|
|
586
606
|
ide_core_browser_1.fastdom.measure(() => {
|
|
587
607
|
if (this._domNode) {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
this.
|
|
608
|
+
const currentWidth = this._domNode.offsetWidth;
|
|
609
|
+
const currentHeight = this._domNode.offsetHeight;
|
|
610
|
+
if (currentWidth !== this._prevDomWidth || currentHeight !== this._prevDomHeight) {
|
|
611
|
+
this.doLayoutEditors();
|
|
612
|
+
}
|
|
613
|
+
this._prevDomWidth = currentWidth;
|
|
614
|
+
this._prevDomHeight = currentHeight;
|
|
591
615
|
}
|
|
592
616
|
});
|
|
593
617
|
}
|
|
594
|
-
|
|
618
|
+
_layoutEditorWorker() {
|
|
595
619
|
if (this.codeEditor) {
|
|
596
620
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.code) {
|
|
597
|
-
this.codeEditor.layout(
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
621
|
+
this.codeEditor.layout();
|
|
622
|
+
this._codeEditorPendingLayout = false;
|
|
623
|
+
}
|
|
624
|
+
else {
|
|
625
|
+
this._codeEditorPendingLayout = true;
|
|
601
626
|
}
|
|
602
627
|
}
|
|
603
628
|
if (this.diffEditor) {
|
|
604
629
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.diff) {
|
|
605
|
-
this.diffEditor.layout(
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
630
|
+
this.diffEditor.layout();
|
|
631
|
+
this._diffEditorPendingLayout = false;
|
|
632
|
+
}
|
|
633
|
+
else {
|
|
634
|
+
this._diffEditorPendingLayout = true;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
if (this.mergeEditor) {
|
|
638
|
+
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.mergeEditor) {
|
|
639
|
+
// this.mergeEditor.layout();
|
|
640
|
+
this._mergeEditorPendingLayout = false;
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
this._mergeEditorPendingLayout = true;
|
|
609
644
|
}
|
|
610
645
|
}
|
|
611
646
|
}
|
|
647
|
+
doLayoutEditors() {
|
|
648
|
+
this._layoutEditorWorker();
|
|
649
|
+
}
|
|
612
650
|
setContextKeys() {
|
|
613
651
|
var _a;
|
|
614
652
|
if (!this._resourceContext) {
|
|
@@ -827,17 +865,15 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
827
865
|
[ide_core_browser_1.ServiceNames.CONTEXT_KEY_SERVICE]: this.contextKeyService.contextKeyService,
|
|
828
866
|
});
|
|
829
867
|
setTimeout(() => {
|
|
830
|
-
|
|
831
|
-
this.codeEditor.layout();
|
|
832
|
-
});
|
|
868
|
+
this.codeEditor.layout();
|
|
833
869
|
});
|
|
834
870
|
this.addDispose(this.codeEditor.onRefOpen(() => {
|
|
835
871
|
this.codeEditor.layout();
|
|
836
872
|
}));
|
|
837
|
-
this.
|
|
873
|
+
this.toDispose.push(this.codeEditor.onCursorPositionChanged((e) => {
|
|
838
874
|
this._onCurrentEditorCursorChange.fire(e);
|
|
839
875
|
}));
|
|
840
|
-
this.
|
|
876
|
+
this.toDispose.push(this.codeEditor.onSelectionsChanged((e) => {
|
|
841
877
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.code) {
|
|
842
878
|
this.eventBus.fire(new types_2.EditorSelectionChangeEvent({
|
|
843
879
|
group: this,
|
|
@@ -848,7 +884,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
848
884
|
}));
|
|
849
885
|
}
|
|
850
886
|
}));
|
|
851
|
-
this.
|
|
887
|
+
this.toDispose.push(this.codeEditor.onVisibleRangesChanged((e) => {
|
|
852
888
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.code) {
|
|
853
889
|
this.eventBus.fire(new types_2.EditorVisibleChangeEvent({
|
|
854
890
|
group: this,
|
|
@@ -858,7 +894,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
858
894
|
}));
|
|
859
895
|
}
|
|
860
896
|
}));
|
|
861
|
-
this.
|
|
897
|
+
this.toDispose.push(this.codeEditor.onConfigurationChanged(() => {
|
|
862
898
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.code) {
|
|
863
899
|
this.eventBus.fire(new types_2.EditorConfigurationChangedEvent({
|
|
864
900
|
group: this,
|
|
@@ -885,14 +921,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
885
921
|
[ide_core_browser_1.ServiceNames.CONTEXT_KEY_SERVICE]: this.contextKeyService.contextKeyService,
|
|
886
922
|
});
|
|
887
923
|
setTimeout(() => {
|
|
888
|
-
|
|
889
|
-
this.diffEditor.layout();
|
|
890
|
-
});
|
|
891
|
-
});
|
|
892
|
-
this.diffEditor.onRefOpen(() => {
|
|
893
|
-
ide_core_browser_1.fastdom.mutate(() => {
|
|
894
|
-
this.diffEditor.layout();
|
|
895
|
-
});
|
|
924
|
+
this.diffEditor.layout();
|
|
896
925
|
});
|
|
897
926
|
this.addDiffEditorEventListeners(this.diffEditor.originalEditor, 'original');
|
|
898
927
|
this.addDiffEditorEventListeners(this.diffEditor.modifiedEditor, 'modified');
|
|
@@ -909,7 +938,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
909
938
|
this.diffEditorReady.ready();
|
|
910
939
|
}
|
|
911
940
|
addDiffEditorEventListeners(editor, side) {
|
|
912
|
-
this.
|
|
941
|
+
this.toDispose.push(editor.onSelectionsChanged((e) => {
|
|
913
942
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.diff) {
|
|
914
943
|
this.eventBus.fire(new types_2.EditorSelectionChangeEvent({
|
|
915
944
|
group: this,
|
|
@@ -921,7 +950,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
921
950
|
}));
|
|
922
951
|
}
|
|
923
952
|
}));
|
|
924
|
-
this.
|
|
953
|
+
this.toDispose.push(editor.onVisibleRangesChanged((e) => {
|
|
925
954
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.diff) {
|
|
926
955
|
this.eventBus.fire(new types_2.EditorVisibleChangeEvent({
|
|
927
956
|
group: this,
|
|
@@ -931,7 +960,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
931
960
|
}));
|
|
932
961
|
}
|
|
933
962
|
}));
|
|
934
|
-
this.
|
|
963
|
+
this.toDispose.push(editor.onConfigurationChanged(() => {
|
|
935
964
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.diff) {
|
|
936
965
|
this.eventBus.fire(new types_2.EditorConfigurationChangedEvent({
|
|
937
966
|
group: this,
|
|
@@ -1438,7 +1467,11 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
1438
1467
|
this.resolveTabChanged(_resource, this.currentResource);
|
|
1439
1468
|
this._currentOpenType = activeOpenType;
|
|
1440
1469
|
this.notifyBodyChanged();
|
|
1441
|
-
this.
|
|
1470
|
+
if ((!this._codeEditorPendingLayout && activeOpenType.type === types_2.EditorOpenType.code) ||
|
|
1471
|
+
(!this._diffEditorPendingLayout && activeOpenType.type === types_2.EditorOpenType.diff) ||
|
|
1472
|
+
(!this._mergeEditorPendingLayout && activeOpenType.type === types_2.EditorOpenType.mergeEditor)) {
|
|
1473
|
+
this.doLayoutEditors();
|
|
1474
|
+
}
|
|
1442
1475
|
this.cachedResourcesActiveOpenTypes.set(resource.uri.toString(), activeOpenType);
|
|
1443
1476
|
}
|
|
1444
1477
|
}
|
|
@@ -1795,6 +1828,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
1795
1828
|
super.dispose();
|
|
1796
1829
|
this.codeEditor && this.codeEditor.dispose();
|
|
1797
1830
|
this.diffEditor && this.diffEditor.dispose();
|
|
1831
|
+
this.toDispose.forEach((disposable) => disposable.dispose());
|
|
1798
1832
|
this.eventBus.fire(new types_2.EditorGroupDisposeEvent({
|
|
1799
1833
|
group: this,
|
|
1800
1834
|
}));
|
|
@@ -1995,6 +2029,16 @@ tslib_1.__decorate([
|
|
|
1995
2029
|
(0, di_1.Autowired)(ide_core_common_1.ILogger),
|
|
1996
2030
|
tslib_1.__metadata("design:type", Object)
|
|
1997
2031
|
], EditorGroup.prototype, "logger", void 0);
|
|
2032
|
+
tslib_1.__decorate([
|
|
2033
|
+
mobx_1.observable.shallow,
|
|
2034
|
+
tslib_1.__metadata("design:type", Array)
|
|
2035
|
+
], EditorGroup.prototype, "availableOpenTypes", void 0);
|
|
2036
|
+
tslib_1.__decorate([
|
|
2037
|
+
(0, ide_core_common_1.debounce)(16 * 5),
|
|
2038
|
+
tslib_1.__metadata("design:type", Function),
|
|
2039
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
2040
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
2041
|
+
], EditorGroup.prototype, "doLayoutEditors", null);
|
|
1998
2042
|
tslib_1.__decorate([
|
|
1999
2043
|
(0, ide_core_common_1.OnEvent)(common_1.ResourceDecorationChangeEvent),
|
|
2000
2044
|
tslib_1.__metadata("design:type", Function),
|