@opensumi/ide-editor 3.3.1-next-1725350427.0 → 3.3.1-next-1725416966.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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { observable } from 'mobx';
|
|
2
|
+
|
|
1
3
|
import { Autowired, INJECTOR_TOKEN, Injectable, Injector } from '@opensumi/di';
|
|
2
4
|
import {
|
|
3
5
|
AppConfig,
|
|
@@ -16,7 +18,6 @@ import {
|
|
|
16
18
|
toMarkdown,
|
|
17
19
|
} from '@opensumi/ide-core-browser';
|
|
18
20
|
import { ResourceContextKey } from '@opensumi/ide-core-browser/lib/contextkey/resource';
|
|
19
|
-
import { IDimension } from '@opensumi/ide-core-browser/lib/dom/resize-observer';
|
|
20
21
|
import { IMergeEditorEditor, MergeEditorInputData } from '@opensumi/ide-core-browser/lib/monaco/merge-editor-widget';
|
|
21
22
|
import {
|
|
22
23
|
CUSTOM_EDITOR_SCHEME,
|
|
@@ -41,6 +42,7 @@ import {
|
|
|
41
42
|
StorageProvider,
|
|
42
43
|
URI,
|
|
43
44
|
WithEventBus,
|
|
45
|
+
debounce,
|
|
44
46
|
formatLocalize,
|
|
45
47
|
getDebugLogger,
|
|
46
48
|
isDefined,
|
|
@@ -278,7 +280,7 @@ export class WorkbenchEditorServiceImpl extends WithEventBus implements Workbenc
|
|
|
278
280
|
createEditorGroup(): EditorGroup {
|
|
279
281
|
const editorGroup = this.injector.get(EditorGroup, [this.generateRandomEditorGroupName(), this.editorGroupIdGen++]);
|
|
280
282
|
this.editorGroups.push(editorGroup);
|
|
281
|
-
|
|
283
|
+
const currentWatchDisposer = new Disposable(
|
|
282
284
|
editorGroup.onDidEditorGroupBodyChanged(() => {
|
|
283
285
|
if (editorGroup === this.currentEditorGroup) {
|
|
284
286
|
if (!editorGroup.currentOpenType && editorGroup.currentResource) {
|
|
@@ -297,15 +299,25 @@ export class WorkbenchEditorServiceImpl extends WithEventBus implements Workbenc
|
|
|
297
299
|
}
|
|
298
300
|
}
|
|
299
301
|
}),
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
302
|
+
);
|
|
303
|
+
editorGroup.addDispose({
|
|
304
|
+
dispose: () => {
|
|
305
|
+
currentWatchDisposer.dispose();
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
const groupChangeDisposer = editorGroup.onDidEditorGroupTabChanged(() => {
|
|
309
|
+
this.saveOpenedResourceState();
|
|
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
|
+
});
|
|
309
321
|
|
|
310
322
|
return editorGroup;
|
|
311
323
|
}
|
|
@@ -677,25 +689,25 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
677
689
|
/**
|
|
678
690
|
* 当编辑器的tab部分发生变更
|
|
679
691
|
*/
|
|
680
|
-
_onDidEditorGroupTabChanged =
|
|
692
|
+
_onDidEditorGroupTabChanged = new EventEmitter<void>();
|
|
681
693
|
onDidEditorGroupTabChanged: Event<void> = this._onDidEditorGroupTabChanged.event;
|
|
682
694
|
|
|
683
695
|
/**
|
|
684
696
|
* 当编辑器的tab部分发生变更
|
|
685
697
|
*/
|
|
686
|
-
_onDidEditorGroupTabOperation =
|
|
698
|
+
_onDidEditorGroupTabOperation = new EventEmitter<IResourceTabOperation>();
|
|
687
699
|
onDidEditorGroupTabOperation: Event<IResourceTabOperation> = this._onDidEditorGroupTabOperation.event;
|
|
688
700
|
|
|
689
701
|
/**
|
|
690
702
|
* 当编辑器的主体部分发生变更
|
|
691
703
|
*/
|
|
692
|
-
_onDidEditorGroupBodyChanged =
|
|
704
|
+
_onDidEditorGroupBodyChanged = new EventEmitter<void>();
|
|
693
705
|
onDidEditorGroupBodyChanged: Event<void> = this._onDidEditorGroupBodyChanged.event;
|
|
694
706
|
|
|
695
707
|
/**
|
|
696
708
|
* 当编辑器有内容处于加载状态
|
|
697
709
|
*/
|
|
698
|
-
_onDidEditorGroupContentLoading =
|
|
710
|
+
_onDidEditorGroupContentLoading = new EventEmitter<IResource>();
|
|
699
711
|
onDidEditorGroupContentLoading: Event<IResource> = this._onDidEditorGroupContentLoading.event;
|
|
700
712
|
|
|
701
713
|
/**
|
|
@@ -721,6 +733,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
721
733
|
|
|
722
734
|
private cachedResourcesOpenTypes = new Map<string, IEditorOpenType[]>();
|
|
723
735
|
|
|
736
|
+
@observable.shallow
|
|
724
737
|
availableOpenTypes: IEditorOpenType[] = [];
|
|
725
738
|
|
|
726
739
|
activeComponents = new Map<IEditorComponent, IResource[]>();
|
|
@@ -731,6 +744,8 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
731
744
|
|
|
732
745
|
private holdDocumentModelRefs: Map<string, IEditorDocumentModelRef> = new Map();
|
|
733
746
|
|
|
747
|
+
private readonly toDispose: monaco.IDisposable[] = [];
|
|
748
|
+
|
|
734
749
|
private _contextKeyService: IContextKeyService;
|
|
735
750
|
|
|
736
751
|
private _resourceContext: ResourceContextKey;
|
|
@@ -748,8 +763,12 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
748
763
|
private _prevDomHeight = 0;
|
|
749
764
|
private _prevDomWidth = 0;
|
|
750
765
|
|
|
766
|
+
private _codeEditorPendingLayout = false;
|
|
767
|
+
private _diffEditorPendingLayout = false;
|
|
768
|
+
private _mergeEditorPendingLayout = false;
|
|
769
|
+
|
|
751
770
|
// 当前为EditorComponent,且monaco光标变化时触发
|
|
752
|
-
private _onCurrentEditorCursorChange =
|
|
771
|
+
private _onCurrentEditorCursorChange = new EventEmitter<CursorStatus>();
|
|
753
772
|
public onCurrentEditorCursorChange = this._onCurrentEditorCursorChange.event;
|
|
754
773
|
|
|
755
774
|
private resourceOpenHistory: URI[] = [];
|
|
@@ -776,28 +795,28 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
776
795
|
|
|
777
796
|
constructor(public readonly name: string, public readonly groupId: number) {
|
|
778
797
|
super();
|
|
779
|
-
|
|
780
|
-
this.
|
|
781
|
-
this.
|
|
782
|
-
|
|
783
|
-
()
|
|
784
|
-
|
|
785
|
-
},
|
|
786
|
-
),
|
|
787
|
-
);
|
|
788
|
-
this.addDispose(
|
|
789
|
-
this.eventBus.on(GridResizeEvent, (e: GridResizeEvent) => {
|
|
790
|
-
if (e.payload.gridId === this.grid.uid) {
|
|
791
|
-
this.layoutEditors();
|
|
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();
|
|
792
804
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
this.activateComponentsProps.delete(e.payload);
|
|
799
|
-
}),
|
|
805
|
+
|
|
806
|
+
toDispose = fastdom.mutate(() => {
|
|
807
|
+
this._layoutEditorWorker();
|
|
808
|
+
});
|
|
809
|
+
},
|
|
800
810
|
);
|
|
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
|
+
});
|
|
801
820
|
|
|
802
821
|
this.listenToExplorerAutoRevealConfig();
|
|
803
822
|
}
|
|
@@ -806,8 +825,10 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
806
825
|
private listenToExplorerAutoRevealConfig() {
|
|
807
826
|
this.explorerAutoRevealConfig = !!this.preferenceService.get<boolean>('explorer.autoReveal');
|
|
808
827
|
this.disposables.push(
|
|
809
|
-
this.preferenceService.
|
|
810
|
-
|
|
828
|
+
this.preferenceService.onPreferenceChanged((change) => {
|
|
829
|
+
if (change.preferenceName === 'explorer.autoReveal') {
|
|
830
|
+
this.explorerAutoRevealConfig = change.newValue;
|
|
831
|
+
}
|
|
811
832
|
}),
|
|
812
833
|
);
|
|
813
834
|
}
|
|
@@ -839,32 +860,49 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
839
860
|
layoutEditors() {
|
|
840
861
|
fastdom.measure(() => {
|
|
841
862
|
if (this._domNode) {
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
this.
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
true,
|
|
850
|
-
);
|
|
863
|
+
const currentWidth = this._domNode.offsetWidth;
|
|
864
|
+
const currentHeight = this._domNode.offsetHeight;
|
|
865
|
+
if (currentWidth !== this._prevDomWidth || currentHeight !== this._prevDomHeight) {
|
|
866
|
+
this.doLayoutEditors();
|
|
867
|
+
}
|
|
868
|
+
this._prevDomWidth = currentWidth;
|
|
869
|
+
this._prevDomHeight = currentHeight;
|
|
851
870
|
}
|
|
852
871
|
});
|
|
853
872
|
}
|
|
854
873
|
|
|
855
|
-
private
|
|
874
|
+
private _layoutEditorWorker() {
|
|
856
875
|
if (this.codeEditor) {
|
|
857
876
|
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.code) {
|
|
858
|
-
this.codeEditor.layout(
|
|
877
|
+
this.codeEditor.layout();
|
|
878
|
+
this._codeEditorPendingLayout = false;
|
|
879
|
+
} else {
|
|
880
|
+
this._codeEditorPendingLayout = true;
|
|
859
881
|
}
|
|
860
882
|
}
|
|
861
883
|
if (this.diffEditor) {
|
|
862
884
|
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.diff) {
|
|
863
|
-
this.diffEditor.layout(
|
|
885
|
+
this.diffEditor.layout();
|
|
886
|
+
this._diffEditorPendingLayout = false;
|
|
887
|
+
} else {
|
|
888
|
+
this._diffEditorPendingLayout = true;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
if (this.mergeEditor) {
|
|
892
|
+
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.mergeEditor) {
|
|
893
|
+
// this.mergeEditor.layout();
|
|
894
|
+
this._mergeEditorPendingLayout = false;
|
|
895
|
+
} else {
|
|
896
|
+
this._mergeEditorPendingLayout = true;
|
|
864
897
|
}
|
|
865
898
|
}
|
|
866
899
|
}
|
|
867
900
|
|
|
901
|
+
@debounce(16 * 5)
|
|
902
|
+
doLayoutEditors() {
|
|
903
|
+
this._layoutEditorWorker();
|
|
904
|
+
}
|
|
905
|
+
|
|
868
906
|
setContextKeys() {
|
|
869
907
|
if (!this._resourceContext) {
|
|
870
908
|
const getLanguageFromModel = (uri: URI) => {
|
|
@@ -1103,21 +1141,19 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1103
1141
|
);
|
|
1104
1142
|
|
|
1105
1143
|
setTimeout(() => {
|
|
1106
|
-
|
|
1107
|
-
this.codeEditor.layout();
|
|
1108
|
-
});
|
|
1144
|
+
this.codeEditor.layout();
|
|
1109
1145
|
});
|
|
1110
1146
|
this.addDispose(
|
|
1111
1147
|
this.codeEditor.onRefOpen(() => {
|
|
1112
1148
|
this.codeEditor.layout();
|
|
1113
1149
|
}),
|
|
1114
1150
|
);
|
|
1115
|
-
this.
|
|
1151
|
+
this.toDispose.push(
|
|
1116
1152
|
this.codeEditor.onCursorPositionChanged((e) => {
|
|
1117
1153
|
this._onCurrentEditorCursorChange.fire(e);
|
|
1118
1154
|
}),
|
|
1119
1155
|
);
|
|
1120
|
-
this.
|
|
1156
|
+
this.toDispose.push(
|
|
1121
1157
|
this.codeEditor.onSelectionsChanged((e) => {
|
|
1122
1158
|
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.code) {
|
|
1123
1159
|
this.eventBus.fire(
|
|
@@ -1132,7 +1168,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1132
1168
|
}
|
|
1133
1169
|
}),
|
|
1134
1170
|
);
|
|
1135
|
-
this.
|
|
1171
|
+
this.toDispose.push(
|
|
1136
1172
|
this.codeEditor.onVisibleRangesChanged((e) => {
|
|
1137
1173
|
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.code) {
|
|
1138
1174
|
this.eventBus.fire(
|
|
@@ -1146,7 +1182,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1146
1182
|
}
|
|
1147
1183
|
}),
|
|
1148
1184
|
);
|
|
1149
|
-
this.
|
|
1185
|
+
this.toDispose.push(
|
|
1150
1186
|
this.codeEditor.onConfigurationChanged(() => {
|
|
1151
1187
|
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.code) {
|
|
1152
1188
|
this.eventBus.fire(
|
|
@@ -1189,15 +1225,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1189
1225
|
},
|
|
1190
1226
|
);
|
|
1191
1227
|
setTimeout(() => {
|
|
1192
|
-
|
|
1193
|
-
this.diffEditor.layout();
|
|
1194
|
-
});
|
|
1195
|
-
});
|
|
1196
|
-
|
|
1197
|
-
this.diffEditor.onRefOpen(() => {
|
|
1198
|
-
fastdom.mutate(() => {
|
|
1199
|
-
this.diffEditor.layout();
|
|
1200
|
-
});
|
|
1228
|
+
this.diffEditor.layout();
|
|
1201
1229
|
});
|
|
1202
1230
|
|
|
1203
1231
|
this.addDiffEditorEventListeners(this.diffEditor.originalEditor, 'original');
|
|
@@ -1222,7 +1250,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1222
1250
|
}
|
|
1223
1251
|
|
|
1224
1252
|
private addDiffEditorEventListeners(editor: IEditor, side?: 'modified' | 'original') {
|
|
1225
|
-
this.
|
|
1253
|
+
this.toDispose.push(
|
|
1226
1254
|
editor.onSelectionsChanged((e) => {
|
|
1227
1255
|
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.diff) {
|
|
1228
1256
|
this.eventBus.fire(
|
|
@@ -1239,7 +1267,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1239
1267
|
}),
|
|
1240
1268
|
);
|
|
1241
1269
|
|
|
1242
|
-
this.
|
|
1270
|
+
this.toDispose.push(
|
|
1243
1271
|
editor.onVisibleRangesChanged((e) => {
|
|
1244
1272
|
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.diff) {
|
|
1245
1273
|
this.eventBus.fire(
|
|
@@ -1254,7 +1282,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1254
1282
|
}),
|
|
1255
1283
|
);
|
|
1256
1284
|
|
|
1257
|
-
this.
|
|
1285
|
+
this.toDispose.push(
|
|
1258
1286
|
editor.onConfigurationChanged(() => {
|
|
1259
1287
|
if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.diff) {
|
|
1260
1288
|
this.eventBus.fire(
|
|
@@ -1810,7 +1838,13 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1810
1838
|
this._currentOpenType = activeOpenType;
|
|
1811
1839
|
this.notifyBodyChanged();
|
|
1812
1840
|
|
|
1813
|
-
|
|
1841
|
+
if (
|
|
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
|
+
}
|
|
1814
1848
|
|
|
1815
1849
|
this.cachedResourcesActiveOpenTypes.set(resource.uri.toString(), activeOpenType);
|
|
1816
1850
|
}
|
|
@@ -2208,6 +2242,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
2208
2242
|
super.dispose();
|
|
2209
2243
|
this.codeEditor && this.codeEditor.dispose();
|
|
2210
2244
|
this.diffEditor && this.diffEditor.dispose();
|
|
2245
|
+
this.toDispose.forEach((disposable) => disposable.dispose());
|
|
2211
2246
|
this.eventBus.fire(
|
|
2212
2247
|
new EditorGroupDisposeEvent({
|
|
2213
2248
|
group: this,
|