@opensumi/ide-editor 3.3.1-next-1725350427.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.d.ts +4 -2
- package/lib/browser/editor.view.d.ts.map +1 -1
- package/lib/browser/editor.view.js +6 -16
- 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 -71
- 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 +174 -183
- package/src/browser/workbench-editor.service.ts +105 -70
- 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,26 +605,47 @@ 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.
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
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;
|
|
594
615
|
}
|
|
595
616
|
});
|
|
596
617
|
}
|
|
597
|
-
|
|
618
|
+
_layoutEditorWorker() {
|
|
598
619
|
if (this.codeEditor) {
|
|
599
620
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.code) {
|
|
600
|
-
this.codeEditor.layout(
|
|
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(
|
|
630
|
+
this.diffEditor.layout();
|
|
631
|
+
this._diffEditorPendingLayout = false;
|
|
632
|
+
}
|
|
633
|
+
else {
|
|
634
|
+
this._diffEditorPendingLayout = true;
|
|
606
635
|
}
|
|
607
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;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
doLayoutEditors() {
|
|
648
|
+
this._layoutEditorWorker();
|
|
608
649
|
}
|
|
609
650
|
setContextKeys() {
|
|
610
651
|
var _a;
|
|
@@ -824,17 +865,15 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
824
865
|
[ide_core_browser_1.ServiceNames.CONTEXT_KEY_SERVICE]: this.contextKeyService.contextKeyService,
|
|
825
866
|
});
|
|
826
867
|
setTimeout(() => {
|
|
827
|
-
|
|
828
|
-
this.codeEditor.layout();
|
|
829
|
-
});
|
|
868
|
+
this.codeEditor.layout();
|
|
830
869
|
});
|
|
831
870
|
this.addDispose(this.codeEditor.onRefOpen(() => {
|
|
832
871
|
this.codeEditor.layout();
|
|
833
872
|
}));
|
|
834
|
-
this.
|
|
873
|
+
this.toDispose.push(this.codeEditor.onCursorPositionChanged((e) => {
|
|
835
874
|
this._onCurrentEditorCursorChange.fire(e);
|
|
836
875
|
}));
|
|
837
|
-
this.
|
|
876
|
+
this.toDispose.push(this.codeEditor.onSelectionsChanged((e) => {
|
|
838
877
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.code) {
|
|
839
878
|
this.eventBus.fire(new types_2.EditorSelectionChangeEvent({
|
|
840
879
|
group: this,
|
|
@@ -845,7 +884,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
845
884
|
}));
|
|
846
885
|
}
|
|
847
886
|
}));
|
|
848
|
-
this.
|
|
887
|
+
this.toDispose.push(this.codeEditor.onVisibleRangesChanged((e) => {
|
|
849
888
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.code) {
|
|
850
889
|
this.eventBus.fire(new types_2.EditorVisibleChangeEvent({
|
|
851
890
|
group: this,
|
|
@@ -855,7 +894,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
855
894
|
}));
|
|
856
895
|
}
|
|
857
896
|
}));
|
|
858
|
-
this.
|
|
897
|
+
this.toDispose.push(this.codeEditor.onConfigurationChanged(() => {
|
|
859
898
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.code) {
|
|
860
899
|
this.eventBus.fire(new types_2.EditorConfigurationChangedEvent({
|
|
861
900
|
group: this,
|
|
@@ -882,14 +921,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
882
921
|
[ide_core_browser_1.ServiceNames.CONTEXT_KEY_SERVICE]: this.contextKeyService.contextKeyService,
|
|
883
922
|
});
|
|
884
923
|
setTimeout(() => {
|
|
885
|
-
|
|
886
|
-
this.diffEditor.layout();
|
|
887
|
-
});
|
|
888
|
-
});
|
|
889
|
-
this.diffEditor.onRefOpen(() => {
|
|
890
|
-
ide_core_browser_1.fastdom.mutate(() => {
|
|
891
|
-
this.diffEditor.layout();
|
|
892
|
-
});
|
|
924
|
+
this.diffEditor.layout();
|
|
893
925
|
});
|
|
894
926
|
this.addDiffEditorEventListeners(this.diffEditor.originalEditor, 'original');
|
|
895
927
|
this.addDiffEditorEventListeners(this.diffEditor.modifiedEditor, 'modified');
|
|
@@ -906,7 +938,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
906
938
|
this.diffEditorReady.ready();
|
|
907
939
|
}
|
|
908
940
|
addDiffEditorEventListeners(editor, side) {
|
|
909
|
-
this.
|
|
941
|
+
this.toDispose.push(editor.onSelectionsChanged((e) => {
|
|
910
942
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.diff) {
|
|
911
943
|
this.eventBus.fire(new types_2.EditorSelectionChangeEvent({
|
|
912
944
|
group: this,
|
|
@@ -918,7 +950,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
918
950
|
}));
|
|
919
951
|
}
|
|
920
952
|
}));
|
|
921
|
-
this.
|
|
953
|
+
this.toDispose.push(editor.onVisibleRangesChanged((e) => {
|
|
922
954
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.diff) {
|
|
923
955
|
this.eventBus.fire(new types_2.EditorVisibleChangeEvent({
|
|
924
956
|
group: this,
|
|
@@ -928,7 +960,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
928
960
|
}));
|
|
929
961
|
}
|
|
930
962
|
}));
|
|
931
|
-
this.
|
|
963
|
+
this.toDispose.push(editor.onConfigurationChanged(() => {
|
|
932
964
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.diff) {
|
|
933
965
|
this.eventBus.fire(new types_2.EditorConfigurationChangedEvent({
|
|
934
966
|
group: this,
|
|
@@ -1435,7 +1467,11 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
1435
1467
|
this.resolveTabChanged(_resource, this.currentResource);
|
|
1436
1468
|
this._currentOpenType = activeOpenType;
|
|
1437
1469
|
this.notifyBodyChanged();
|
|
1438
|
-
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
|
+
}
|
|
1439
1475
|
this.cachedResourcesActiveOpenTypes.set(resource.uri.toString(), activeOpenType);
|
|
1440
1476
|
}
|
|
1441
1477
|
}
|
|
@@ -1792,6 +1828,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
1792
1828
|
super.dispose();
|
|
1793
1829
|
this.codeEditor && this.codeEditor.dispose();
|
|
1794
1830
|
this.diffEditor && this.diffEditor.dispose();
|
|
1831
|
+
this.toDispose.forEach((disposable) => disposable.dispose());
|
|
1795
1832
|
this.eventBus.fire(new types_2.EditorGroupDisposeEvent({
|
|
1796
1833
|
group: this,
|
|
1797
1834
|
}));
|
|
@@ -1992,6 +2029,16 @@ tslib_1.__decorate([
|
|
|
1992
2029
|
(0, di_1.Autowired)(ide_core_common_1.ILogger),
|
|
1993
2030
|
tslib_1.__metadata("design:type", Object)
|
|
1994
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);
|
|
1995
2042
|
tslib_1.__decorate([
|
|
1996
2043
|
(0, ide_core_common_1.OnEvent)(common_1.ResourceDecorationChangeEvent),
|
|
1997
2044
|
tslib_1.__metadata("design:type", Function),
|