@opensumi/ide-editor 3.3.0 → 3.3.1-next-1725288439.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 +0 -1
- package/lib/browser/editor.view.js.map +1 -1
- package/lib/browser/workbench-editor.service.d.ts +1 -6
- package/lib/browser/workbench-editor.service.d.ts.map +1 -1
- package/lib/browser/workbench-editor.service.js +74 -118
- 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 +0 -1
- package/src/browser/editor.view.tsx +1 -1
- package/src/browser/workbench-editor.service.ts +75 -105
- package/src/common/editor.ts +1 -1
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { observable } from 'mobx';
|
|
2
|
-
|
|
3
1
|
import { Autowired, INJECTOR_TOKEN, Injectable, Injector } from '@opensumi/di';
|
|
4
2
|
import {
|
|
5
3
|
AppConfig,
|
|
@@ -42,7 +40,6 @@ import {
|
|
|
42
40
|
StorageProvider,
|
|
43
41
|
URI,
|
|
44
42
|
WithEventBus,
|
|
45
|
-
debounce,
|
|
46
43
|
formatLocalize,
|
|
47
44
|
getDebugLogger,
|
|
48
45
|
isDefined,
|
|
@@ -280,7 +277,7 @@ export class WorkbenchEditorServiceImpl extends WithEventBus implements Workbenc
|
|
|
280
277
|
createEditorGroup(): EditorGroup {
|
|
281
278
|
const editorGroup = this.injector.get(EditorGroup, [this.generateRandomEditorGroupName(), this.editorGroupIdGen++]);
|
|
282
279
|
this.editorGroups.push(editorGroup);
|
|
283
|
-
|
|
280
|
+
editorGroup.addDispose([
|
|
284
281
|
editorGroup.onDidEditorGroupBodyChanged(() => {
|
|
285
282
|
if (editorGroup === this.currentEditorGroup) {
|
|
286
283
|
if (!editorGroup.currentOpenType && editorGroup.currentResource) {
|
|
@@ -299,25 +296,15 @@ export class WorkbenchEditorServiceImpl extends WithEventBus implements Workbenc
|
|
|
299
296
|
}
|
|
300
297
|
}
|
|
301
298
|
}),
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
editorGroup.addDispose({
|
|
312
|
-
dispose: () => {
|
|
313
|
-
groupChangeDisposer.dispose();
|
|
314
|
-
},
|
|
315
|
-
});
|
|
316
|
-
editorGroup.onCurrentEditorCursorChange((e) => {
|
|
317
|
-
if (this._currentEditorGroup === editorGroup) {
|
|
318
|
-
this._onCursorChange.fire(e);
|
|
319
|
-
}
|
|
320
|
-
});
|
|
299
|
+
editorGroup.onDidEditorGroupTabChanged(() => {
|
|
300
|
+
this.saveOpenedResourceState();
|
|
301
|
+
}),
|
|
302
|
+
editorGroup.onCurrentEditorCursorChange((e) => {
|
|
303
|
+
if (this._currentEditorGroup === editorGroup) {
|
|
304
|
+
this._onCursorChange.fire(e);
|
|
305
|
+
}
|
|
306
|
+
}),
|
|
307
|
+
]);
|
|
321
308
|
|
|
322
309
|
return editorGroup;
|
|
323
310
|
}
|
|
@@ -689,25 +676,25 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
689
676
|
/**
|
|
690
677
|
* 当编辑器的tab部分发生变更
|
|
691
678
|
*/
|
|
692
|
-
_onDidEditorGroupTabChanged = new EventEmitter<void>();
|
|
679
|
+
_onDidEditorGroupTabChanged = this.registerDispose(new EventEmitter<void>());
|
|
693
680
|
onDidEditorGroupTabChanged: Event<void> = this._onDidEditorGroupTabChanged.event;
|
|
694
681
|
|
|
695
682
|
/**
|
|
696
683
|
* 当编辑器的tab部分发生变更
|
|
697
684
|
*/
|
|
698
|
-
_onDidEditorGroupTabOperation = new EventEmitter<IResourceTabOperation>();
|
|
685
|
+
_onDidEditorGroupTabOperation = this.registerDispose(new EventEmitter<IResourceTabOperation>());
|
|
699
686
|
onDidEditorGroupTabOperation: Event<IResourceTabOperation> = this._onDidEditorGroupTabOperation.event;
|
|
700
687
|
|
|
701
688
|
/**
|
|
702
689
|
* 当编辑器的主体部分发生变更
|
|
703
690
|
*/
|
|
704
|
-
_onDidEditorGroupBodyChanged = new EventEmitter<void>();
|
|
691
|
+
_onDidEditorGroupBodyChanged = this.registerDispose(new EventEmitter<void>());
|
|
705
692
|
onDidEditorGroupBodyChanged: Event<void> = this._onDidEditorGroupBodyChanged.event;
|
|
706
693
|
|
|
707
694
|
/**
|
|
708
695
|
* 当编辑器有内容处于加载状态
|
|
709
696
|
*/
|
|
710
|
-
_onDidEditorGroupContentLoading = new EventEmitter<IResource>();
|
|
697
|
+
_onDidEditorGroupContentLoading = this.registerDispose(new EventEmitter<IResource>());
|
|
711
698
|
onDidEditorGroupContentLoading: Event<IResource> = this._onDidEditorGroupContentLoading.event;
|
|
712
699
|
|
|
713
700
|
/**
|
|
@@ -733,7 +720,6 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
733
720
|
|
|
734
721
|
private cachedResourcesOpenTypes = new Map<string, IEditorOpenType[]>();
|
|
735
722
|
|
|
736
|
-
@observable.shallow
|
|
737
723
|
availableOpenTypes: IEditorOpenType[] = [];
|
|
738
724
|
|
|
739
725
|
activeComponents = new Map<IEditorComponent, IResource[]>();
|
|
@@ -744,8 +730,6 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
744
730
|
|
|
745
731
|
private holdDocumentModelRefs: Map<string, IEditorDocumentModelRef> = new Map();
|
|
746
732
|
|
|
747
|
-
private readonly toDispose: monaco.IDisposable[] = [];
|
|
748
|
-
|
|
749
733
|
private _contextKeyService: IContextKeyService;
|
|
750
734
|
|
|
751
735
|
private _resourceContext: ResourceContextKey;
|
|
@@ -763,12 +747,8 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
763
747
|
private _prevDomHeight = 0;
|
|
764
748
|
private _prevDomWidth = 0;
|
|
765
749
|
|
|
766
|
-
private _codeEditorPendingLayout = false;
|
|
767
|
-
private _diffEditorPendingLayout = false;
|
|
768
|
-
private _mergeEditorPendingLayout = false;
|
|
769
|
-
|
|
770
750
|
// 当前为EditorComponent,且monaco光标变化时触发
|
|
771
|
-
private _onCurrentEditorCursorChange = new EventEmitter<CursorStatus>();
|
|
751
|
+
private _onCurrentEditorCursorChange = this.registerDispose(new EventEmitter<CursorStatus>());
|
|
772
752
|
public onCurrentEditorCursorChange = this._onCurrentEditorCursorChange.event;
|
|
773
753
|
|
|
774
754
|
private resourceOpenHistory: URI[] = [];
|
|
@@ -795,28 +775,28 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
795
775
|
|
|
796
776
|
constructor(public readonly name: string, public readonly groupId: number) {
|
|
797
777
|
super();
|
|
798
|
-
let toDispose: IDisposable | undefined;
|
|
799
|
-
this.eventBus.onDirective(
|
|
800
|
-
ResizeEvent.createDirective(getSlotLocation('@opensumi/ide-editor', this.config.layoutConfig)),
|
|
801
|
-
() => {
|
|
802
|
-
if (toDispose) {
|
|
803
|
-
toDispose.dispose();
|
|
804
|
-
}
|
|
805
778
|
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
779
|
+
this.addDispose(
|
|
780
|
+
this.eventBus.onDirective(
|
|
781
|
+
ResizeEvent.createDirective(getSlotLocation('@opensumi/ide-editor', this.config.layoutConfig)),
|
|
782
|
+
() => {
|
|
783
|
+
this.layoutEditors();
|
|
784
|
+
},
|
|
785
|
+
),
|
|
786
|
+
);
|
|
787
|
+
this.addDispose(
|
|
788
|
+
this.eventBus.on(GridResizeEvent, (e: GridResizeEvent) => {
|
|
789
|
+
if (e.payload.gridId === this.grid.uid) {
|
|
790
|
+
this.layoutEditors();
|
|
791
|
+
}
|
|
792
|
+
}),
|
|
793
|
+
);
|
|
794
|
+
this.addDispose(
|
|
795
|
+
this.eventBus.on(EditorComponentDisposeEvent, (e: EditorComponentDisposeEvent) => {
|
|
796
|
+
this.activeComponents.delete(e.payload);
|
|
797
|
+
this.activateComponentsProps.delete(e.payload);
|
|
798
|
+
}),
|
|
810
799
|
);
|
|
811
|
-
this.eventBus.on(GridResizeEvent, (e: GridResizeEvent) => {
|
|
812
|
-
if (e.payload.gridId === this.grid.uid) {
|
|
813
|
-
this.doLayoutEditors();
|
|
814
|
-
}
|
|
815
|
-
});
|
|
816
|
-
this.eventBus.on(EditorComponentDisposeEvent, (e: EditorComponentDisposeEvent) => {
|
|
817
|
-
this.activeComponents.delete(e.payload);
|
|
818
|
-
this.activateComponentsProps.delete(e.payload);
|
|
819
|
-
});
|
|
820
800
|
|
|
821
801
|
this.listenToExplorerAutoRevealConfig();
|
|
822
802
|
}
|
|
@@ -825,10 +805,8 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
825
805
|
private listenToExplorerAutoRevealConfig() {
|
|
826
806
|
this.explorerAutoRevealConfig = !!this.preferenceService.get<boolean>('explorer.autoReveal');
|
|
827
807
|
this.disposables.push(
|
|
828
|
-
this.preferenceService.
|
|
829
|
-
|
|
830
|
-
this.explorerAutoRevealConfig = change.newValue;
|
|
831
|
-
}
|
|
808
|
+
this.preferenceService.onSpecificPreferenceChange('explorer.autoReveal', (change) => {
|
|
809
|
+
this.explorerAutoRevealConfig = change.newValue;
|
|
832
810
|
}),
|
|
833
811
|
);
|
|
834
812
|
}
|
|
@@ -860,49 +838,38 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
860
838
|
layoutEditors() {
|
|
861
839
|
fastdom.measure(() => {
|
|
862
840
|
if (this._domNode) {
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
this.doLayoutEditors();
|
|
867
|
-
}
|
|
868
|
-
this._prevDomWidth = currentWidth;
|
|
869
|
-
this._prevDomHeight = currentHeight;
|
|
841
|
+
this._prevDomWidth = this._domNode.offsetWidth;
|
|
842
|
+
this._prevDomHeight = this._domNode.offsetHeight;
|
|
843
|
+
this.doLayoutEditors();
|
|
870
844
|
}
|
|
871
845
|
});
|
|
872
846
|
}
|
|
873
847
|
|
|
874
|
-
private
|
|
848
|
+
private doLayoutEditors() {
|
|
875
849
|
if (this.codeEditor) {
|
|
876
850
|
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.code) {
|
|
877
|
-
this.codeEditor.layout(
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
851
|
+
this.codeEditor.layout(
|
|
852
|
+
{
|
|
853
|
+
width: this._prevDomWidth,
|
|
854
|
+
height: this._prevDomHeight,
|
|
855
|
+
},
|
|
856
|
+
true,
|
|
857
|
+
);
|
|
881
858
|
}
|
|
882
859
|
}
|
|
883
860
|
if (this.diffEditor) {
|
|
884
861
|
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.diff) {
|
|
885
|
-
this.diffEditor.layout(
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.mergeEditor) {
|
|
893
|
-
// this.mergeEditor.layout();
|
|
894
|
-
this._mergeEditorPendingLayout = false;
|
|
895
|
-
} else {
|
|
896
|
-
this._mergeEditorPendingLayout = true;
|
|
862
|
+
this.diffEditor.layout(
|
|
863
|
+
{
|
|
864
|
+
width: this._prevDomWidth,
|
|
865
|
+
height: this._prevDomHeight,
|
|
866
|
+
},
|
|
867
|
+
true,
|
|
868
|
+
);
|
|
897
869
|
}
|
|
898
870
|
}
|
|
899
871
|
}
|
|
900
872
|
|
|
901
|
-
@debounce(16 * 5)
|
|
902
|
-
doLayoutEditors() {
|
|
903
|
-
this._layoutEditorWorker();
|
|
904
|
-
}
|
|
905
|
-
|
|
906
873
|
setContextKeys() {
|
|
907
874
|
if (!this._resourceContext) {
|
|
908
875
|
const getLanguageFromModel = (uri: URI) => {
|
|
@@ -1141,19 +1108,21 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1141
1108
|
);
|
|
1142
1109
|
|
|
1143
1110
|
setTimeout(() => {
|
|
1144
|
-
|
|
1111
|
+
fastdom.mutate(() => {
|
|
1112
|
+
this.codeEditor.layout();
|
|
1113
|
+
});
|
|
1145
1114
|
});
|
|
1146
1115
|
this.addDispose(
|
|
1147
1116
|
this.codeEditor.onRefOpen(() => {
|
|
1148
1117
|
this.codeEditor.layout();
|
|
1149
1118
|
}),
|
|
1150
1119
|
);
|
|
1151
|
-
this.
|
|
1120
|
+
this.addDispose(
|
|
1152
1121
|
this.codeEditor.onCursorPositionChanged((e) => {
|
|
1153
1122
|
this._onCurrentEditorCursorChange.fire(e);
|
|
1154
1123
|
}),
|
|
1155
1124
|
);
|
|
1156
|
-
this.
|
|
1125
|
+
this.addDispose(
|
|
1157
1126
|
this.codeEditor.onSelectionsChanged((e) => {
|
|
1158
1127
|
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.code) {
|
|
1159
1128
|
this.eventBus.fire(
|
|
@@ -1168,7 +1137,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1168
1137
|
}
|
|
1169
1138
|
}),
|
|
1170
1139
|
);
|
|
1171
|
-
this.
|
|
1140
|
+
this.addDispose(
|
|
1172
1141
|
this.codeEditor.onVisibleRangesChanged((e) => {
|
|
1173
1142
|
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.code) {
|
|
1174
1143
|
this.eventBus.fire(
|
|
@@ -1182,7 +1151,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1182
1151
|
}
|
|
1183
1152
|
}),
|
|
1184
1153
|
);
|
|
1185
|
-
this.
|
|
1154
|
+
this.addDispose(
|
|
1186
1155
|
this.codeEditor.onConfigurationChanged(() => {
|
|
1187
1156
|
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.code) {
|
|
1188
1157
|
this.eventBus.fire(
|
|
@@ -1225,7 +1194,15 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1225
1194
|
},
|
|
1226
1195
|
);
|
|
1227
1196
|
setTimeout(() => {
|
|
1228
|
-
|
|
1197
|
+
fastdom.mutate(() => {
|
|
1198
|
+
this.diffEditor.layout();
|
|
1199
|
+
});
|
|
1200
|
+
});
|
|
1201
|
+
|
|
1202
|
+
this.diffEditor.onRefOpen(() => {
|
|
1203
|
+
fastdom.mutate(() => {
|
|
1204
|
+
this.diffEditor.layout();
|
|
1205
|
+
});
|
|
1229
1206
|
});
|
|
1230
1207
|
|
|
1231
1208
|
this.addDiffEditorEventListeners(this.diffEditor.originalEditor, 'original');
|
|
@@ -1250,7 +1227,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1250
1227
|
}
|
|
1251
1228
|
|
|
1252
1229
|
private addDiffEditorEventListeners(editor: IEditor, side?: 'modified' | 'original') {
|
|
1253
|
-
this.
|
|
1230
|
+
this.addDispose(
|
|
1254
1231
|
editor.onSelectionsChanged((e) => {
|
|
1255
1232
|
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.diff) {
|
|
1256
1233
|
this.eventBus.fire(
|
|
@@ -1267,7 +1244,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1267
1244
|
}),
|
|
1268
1245
|
);
|
|
1269
1246
|
|
|
1270
|
-
this.
|
|
1247
|
+
this.addDispose(
|
|
1271
1248
|
editor.onVisibleRangesChanged((e) => {
|
|
1272
1249
|
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.diff) {
|
|
1273
1250
|
this.eventBus.fire(
|
|
@@ -1282,7 +1259,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1282
1259
|
}),
|
|
1283
1260
|
);
|
|
1284
1261
|
|
|
1285
|
-
this.
|
|
1262
|
+
this.addDispose(
|
|
1286
1263
|
editor.onConfigurationChanged(() => {
|
|
1287
1264
|
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.diff) {
|
|
1288
1265
|
this.eventBus.fire(
|
|
@@ -1838,13 +1815,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1838
1815
|
this._currentOpenType = activeOpenType;
|
|
1839
1816
|
this.notifyBodyChanged();
|
|
1840
1817
|
|
|
1841
|
-
|
|
1842
|
-
(!this._codeEditorPendingLayout && activeOpenType.type === EditorOpenType.code) ||
|
|
1843
|
-
(!this._diffEditorPendingLayout && activeOpenType.type === EditorOpenType.diff) ||
|
|
1844
|
-
(!this._mergeEditorPendingLayout && activeOpenType.type === EditorOpenType.mergeEditor)
|
|
1845
|
-
) {
|
|
1846
|
-
this.doLayoutEditors();
|
|
1847
|
-
}
|
|
1818
|
+
this.layoutEditors();
|
|
1848
1819
|
|
|
1849
1820
|
this.cachedResourcesActiveOpenTypes.set(resource.uri.toString(), activeOpenType);
|
|
1850
1821
|
}
|
|
@@ -2242,7 +2213,6 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
2242
2213
|
super.dispose();
|
|
2243
2214
|
this.codeEditor && this.codeEditor.dispose();
|
|
2244
2215
|
this.diffEditor && this.diffEditor.dispose();
|
|
2245
|
-
this.toDispose.forEach((disposable) => disposable.dispose());
|
|
2246
2216
|
this.eventBus.fire(
|
|
2247
2217
|
new EditorGroupDisposeEvent({
|
|
2248
2218
|
group: this,
|