@opensumi/ide-editor 3.3.1-next-1725432779.0 → 3.3.1-next-1725462155.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 +124 -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 +113 -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;
|
|
@@ -725,6 +766,9 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
725
766
|
}
|
|
726
767
|
if (this.currentResource && this.currentResource.uri.isEqual(uri)) {
|
|
727
768
|
this._currentOpenType = null;
|
|
769
|
+
this._codeEditorPendingLayout = false;
|
|
770
|
+
this._diffEditorPendingLayout = false;
|
|
771
|
+
this._mergeEditorPendingLayout = false;
|
|
728
772
|
this.notifyBodyChanged();
|
|
729
773
|
this.displayResourceComponent(this.currentResource, {});
|
|
730
774
|
}
|
|
@@ -824,17 +868,15 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
824
868
|
[ide_core_browser_1.ServiceNames.CONTEXT_KEY_SERVICE]: this.contextKeyService.contextKeyService,
|
|
825
869
|
});
|
|
826
870
|
setTimeout(() => {
|
|
827
|
-
|
|
828
|
-
this.codeEditor.layout();
|
|
829
|
-
});
|
|
871
|
+
this.codeEditor.layout();
|
|
830
872
|
});
|
|
831
873
|
this.addDispose(this.codeEditor.onRefOpen(() => {
|
|
832
874
|
this.codeEditor.layout();
|
|
833
875
|
}));
|
|
834
|
-
this.
|
|
876
|
+
this.toDispose.push(this.codeEditor.onCursorPositionChanged((e) => {
|
|
835
877
|
this._onCurrentEditorCursorChange.fire(e);
|
|
836
878
|
}));
|
|
837
|
-
this.
|
|
879
|
+
this.toDispose.push(this.codeEditor.onSelectionsChanged((e) => {
|
|
838
880
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.code) {
|
|
839
881
|
this.eventBus.fire(new types_2.EditorSelectionChangeEvent({
|
|
840
882
|
group: this,
|
|
@@ -845,7 +887,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
845
887
|
}));
|
|
846
888
|
}
|
|
847
889
|
}));
|
|
848
|
-
this.
|
|
890
|
+
this.toDispose.push(this.codeEditor.onVisibleRangesChanged((e) => {
|
|
849
891
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.code) {
|
|
850
892
|
this.eventBus.fire(new types_2.EditorVisibleChangeEvent({
|
|
851
893
|
group: this,
|
|
@@ -855,7 +897,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
855
897
|
}));
|
|
856
898
|
}
|
|
857
899
|
}));
|
|
858
|
-
this.
|
|
900
|
+
this.toDispose.push(this.codeEditor.onConfigurationChanged(() => {
|
|
859
901
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.code) {
|
|
860
902
|
this.eventBus.fire(new types_2.EditorConfigurationChangedEvent({
|
|
861
903
|
group: this,
|
|
@@ -882,14 +924,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
882
924
|
[ide_core_browser_1.ServiceNames.CONTEXT_KEY_SERVICE]: this.contextKeyService.contextKeyService,
|
|
883
925
|
});
|
|
884
926
|
setTimeout(() => {
|
|
885
|
-
|
|
886
|
-
this.diffEditor.layout();
|
|
887
|
-
});
|
|
888
|
-
});
|
|
889
|
-
this.diffEditor.onRefOpen(() => {
|
|
890
|
-
ide_core_browser_1.fastdom.mutate(() => {
|
|
891
|
-
this.diffEditor.layout();
|
|
892
|
-
});
|
|
927
|
+
this.diffEditor.layout();
|
|
893
928
|
});
|
|
894
929
|
this.addDiffEditorEventListeners(this.diffEditor.originalEditor, 'original');
|
|
895
930
|
this.addDiffEditorEventListeners(this.diffEditor.modifiedEditor, 'modified');
|
|
@@ -906,7 +941,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
906
941
|
this.diffEditorReady.ready();
|
|
907
942
|
}
|
|
908
943
|
addDiffEditorEventListeners(editor, side) {
|
|
909
|
-
this.
|
|
944
|
+
this.toDispose.push(editor.onSelectionsChanged((e) => {
|
|
910
945
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.diff) {
|
|
911
946
|
this.eventBus.fire(new types_2.EditorSelectionChangeEvent({
|
|
912
947
|
group: this,
|
|
@@ -918,7 +953,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
918
953
|
}));
|
|
919
954
|
}
|
|
920
955
|
}));
|
|
921
|
-
this.
|
|
956
|
+
this.toDispose.push(editor.onVisibleRangesChanged((e) => {
|
|
922
957
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.diff) {
|
|
923
958
|
this.eventBus.fire(new types_2.EditorVisibleChangeEvent({
|
|
924
959
|
group: this,
|
|
@@ -928,7 +963,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
928
963
|
}));
|
|
929
964
|
}
|
|
930
965
|
}));
|
|
931
|
-
this.
|
|
966
|
+
this.toDispose.push(editor.onConfigurationChanged(() => {
|
|
932
967
|
if (this.currentOpenType && this.currentOpenType.type === types_2.EditorOpenType.diff) {
|
|
933
968
|
this.eventBus.fire(new types_2.EditorConfigurationChangedEvent({
|
|
934
969
|
group: this,
|
|
@@ -1435,7 +1470,11 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
1435
1470
|
this.resolveTabChanged(_resource, this.currentResource);
|
|
1436
1471
|
this._currentOpenType = activeOpenType;
|
|
1437
1472
|
this.notifyBodyChanged();
|
|
1438
|
-
this.
|
|
1473
|
+
if ((!this._codeEditorPendingLayout && activeOpenType.type === types_2.EditorOpenType.code) ||
|
|
1474
|
+
(!this._diffEditorPendingLayout && activeOpenType.type === types_2.EditorOpenType.diff) ||
|
|
1475
|
+
(!this._mergeEditorPendingLayout && activeOpenType.type === types_2.EditorOpenType.mergeEditor)) {
|
|
1476
|
+
this.doLayoutEditors();
|
|
1477
|
+
}
|
|
1439
1478
|
this.cachedResourcesActiveOpenTypes.set(resource.uri.toString(), activeOpenType);
|
|
1440
1479
|
}
|
|
1441
1480
|
}
|
|
@@ -1561,6 +1600,9 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
1561
1600
|
const oldResource = this._currentResource;
|
|
1562
1601
|
this._currentResource = null;
|
|
1563
1602
|
this._currentOpenType = null;
|
|
1603
|
+
this._codeEditorPendingLayout = false;
|
|
1604
|
+
this._diffEditorPendingLayout = false;
|
|
1605
|
+
this._mergeEditorPendingLayout = false;
|
|
1564
1606
|
this.notifyTabChanged();
|
|
1565
1607
|
this.notifyBodyChanged();
|
|
1566
1608
|
this._currentOrPreviousFocusedEditor = null;
|
|
@@ -1792,6 +1834,7 @@ let EditorGroup = class EditorGroup extends ide_core_common_1.WithEventBus {
|
|
|
1792
1834
|
super.dispose();
|
|
1793
1835
|
this.codeEditor && this.codeEditor.dispose();
|
|
1794
1836
|
this.diffEditor && this.diffEditor.dispose();
|
|
1837
|
+
this.toDispose.forEach((disposable) => disposable.dispose());
|
|
1795
1838
|
this.eventBus.fire(new types_2.EditorGroupDisposeEvent({
|
|
1796
1839
|
group: this,
|
|
1797
1840
|
}));
|
|
@@ -1992,6 +2035,16 @@ tslib_1.__decorate([
|
|
|
1992
2035
|
(0, di_1.Autowired)(ide_core_common_1.ILogger),
|
|
1993
2036
|
tslib_1.__metadata("design:type", Object)
|
|
1994
2037
|
], EditorGroup.prototype, "logger", void 0);
|
|
2038
|
+
tslib_1.__decorate([
|
|
2039
|
+
mobx_1.observable.shallow,
|
|
2040
|
+
tslib_1.__metadata("design:type", Array)
|
|
2041
|
+
], EditorGroup.prototype, "availableOpenTypes", void 0);
|
|
2042
|
+
tslib_1.__decorate([
|
|
2043
|
+
(0, ide_core_common_1.debounce)(16 * 5),
|
|
2044
|
+
tslib_1.__metadata("design:type", Function),
|
|
2045
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
2046
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
2047
|
+
], EditorGroup.prototype, "doLayoutEditors", null);
|
|
1995
2048
|
tslib_1.__decorate([
|
|
1996
2049
|
(0, ide_core_common_1.OnEvent)(common_1.ResourceDecorationChangeEvent),
|
|
1997
2050
|
tslib_1.__metadata("design:type", Function),
|