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