@opensumi/ide-editor 3.2.5 → 3.2.6-next-1724824955.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/doc-model/editor-document-model-service.d.ts +2 -1
- package/lib/browser/doc-model/editor-document-model-service.d.ts.map +1 -1
- package/lib/browser/doc-model/editor-document-model-service.js +22 -0
- package/lib/browser/doc-model/editor-document-model-service.js.map +1 -1
- package/lib/browser/doc-model/editor-document-model.d.ts +1 -0
- package/lib/browser/doc-model/editor-document-model.d.ts.map +1 -1
- package/lib/browser/doc-model/editor-document-model.js +14 -0
- package/lib/browser/doc-model/editor-document-model.js.map +1 -1
- package/lib/browser/doc-model/saveParticipants.d.ts.map +1 -1
- package/lib/browser/doc-model/saveParticipants.js +1 -0
- package/lib/browser/doc-model/saveParticipants.js.map +1 -1
- package/lib/browser/doc-model/types.d.ts +3 -1
- package/lib/browser/doc-model/types.d.ts.map +1 -1
- package/lib/browser/doc-model/types.js.map +1 -1
- package/lib/browser/editor-scrollbar/index.d.ts +69 -0
- package/lib/browser/editor-scrollbar/index.d.ts.map +1 -0
- package/lib/browser/editor-scrollbar/index.js +289 -0
- package/lib/browser/editor-scrollbar/index.js.map +1 -0
- package/lib/browser/editor-scrollbar/index.module.less +106 -0
- package/lib/browser/editor.contribution.d.ts.map +1 -1
- package/lib/browser/editor.contribution.js +7 -4
- package/lib/browser/editor.contribution.js.map +1 -1
- package/lib/browser/editor.module.less +9 -17
- package/lib/browser/editor.view.d.ts.map +1 -1
- package/lib/browser/editor.view.js +2 -12
- package/lib/browser/editor.view.js.map +1 -1
- package/lib/browser/format/formatter-selector.d.ts.map +1 -1
- package/lib/browser/format/formatter-selector.js +6 -8
- package/lib/browser/format/formatter-selector.js.map +1 -1
- package/lib/browser/fs-resource/fs-resource.d.ts.map +1 -1
- package/lib/browser/fs-resource/fs-resource.js +5 -7
- package/lib/browser/fs-resource/fs-resource.js.map +1 -1
- package/lib/browser/grid/grid.service.d.ts +1 -0
- package/lib/browser/grid/grid.service.d.ts.map +1 -1
- package/lib/browser/grid/grid.service.js +6 -4
- package/lib/browser/grid/grid.service.js.map +1 -1
- package/lib/browser/hooks/useEditor.d.ts +2 -2
- package/lib/browser/hooks/useEditor.d.ts.map +1 -1
- package/lib/browser/hooks/useEditor.js +10 -11
- package/lib/browser/hooks/useEditor.js.map +1 -1
- package/lib/browser/merge-conflict/merge-conflict.model.d.ts.map +1 -1
- package/lib/browser/merge-conflict/merge-conflict.model.js +3 -4
- package/lib/browser/merge-conflict/merge-conflict.model.js.map +1 -1
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.d.ts.map +1 -1
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.js +3 -3
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.js.map +1 -1
- package/lib/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.d.ts.map +1 -1
- package/lib/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.js +3 -3
- package/lib/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.js.map +1 -1
- package/lib/browser/navigation.module.less +3 -2
- package/lib/browser/navigation.view.js +1 -1
- package/lib/browser/navigation.view.js.map +1 -1
- package/lib/browser/tab.view.d.ts.map +1 -1
- package/lib/browser/tab.view.js +21 -6
- package/lib/browser/tab.view.js.map +1 -1
- package/lib/browser/untitled-resource.d.ts.map +1 -1
- package/lib/browser/untitled-resource.js +5 -7
- package/lib/browser/untitled-resource.js.map +1 -1
- package/lib/browser/workbench-editor.service.d.ts.map +1 -1
- package/lib/browser/workbench-editor.service.js +15 -22
- package/lib/browser/workbench-editor.service.js.map +1 -1
- package/lib/common/components.d.ts +3 -0
- package/lib/common/components.d.ts.map +1 -0
- package/lib/common/components.js +6 -0
- package/lib/common/components.js.map +1 -0
- package/lib/common/editor.d.ts +47 -0
- package/lib/common/editor.d.ts.map +1 -1
- package/lib/common/editor.js.map +1 -1
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +1 -0
- package/lib/common/index.js.map +1 -1
- package/package.json +14 -14
- package/src/browser/doc-model/editor-document-model-service.ts +25 -1
- package/src/browser/doc-model/editor-document-model.ts +18 -0
- package/src/browser/doc-model/saveParticipants.ts +1 -0
- package/src/browser/doc-model/types.ts +3 -1
- package/src/browser/editor-scrollbar/index.module.less +106 -0
- package/src/browser/editor-scrollbar/index.tsx +399 -0
- package/src/browser/editor.contribution.ts +8 -3
- package/src/browser/editor.module.less +9 -17
- package/src/browser/editor.view.tsx +4 -21
- package/src/browser/format/formatter-selector.ts +6 -8
- package/src/browser/fs-resource/fs-resource.ts +5 -7
- package/src/browser/grid/grid.service.ts +13 -7
- package/src/browser/hooks/useEditor.ts +13 -12
- package/src/browser/merge-conflict/merge-conflict.model.ts +4 -5
- package/src/browser/monaco-contrib/callHierarchy/callHierarchy.service.ts +4 -2
- package/src/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.ts +5 -2
- package/src/browser/navigation.module.less +3 -2
- package/src/browser/navigation.view.tsx +1 -1
- package/src/browser/tab.view.tsx +40 -8
- package/src/browser/untitled-resource.ts +5 -7
- package/src/browser/workbench-editor.service.ts +20 -25
- package/src/common/components.ts +2 -0
- package/src/common/editor.ts +59 -1
- package/src/common/index.ts +1 -0
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import { URI, useInjectable } from '@opensumi/ide-core-browser';
|
|
3
|
+
import { DisposableStore, URI, useInjectable } from '@opensumi/ide-core-browser';
|
|
4
4
|
|
|
5
5
|
import { IEditorDocumentModelService } from '../doc-model/types';
|
|
6
|
-
import {
|
|
6
|
+
import { IEditorDocumentModel } from '../types';
|
|
7
7
|
|
|
8
|
-
export function
|
|
8
|
+
export function useEditorDocumentModel(uri: URI) {
|
|
9
9
|
const documentService: IEditorDocumentModelService = useInjectable(IEditorDocumentModelService);
|
|
10
|
-
const [
|
|
10
|
+
const [instance, setInstance] = useState<IEditorDocumentModel | null>(null);
|
|
11
11
|
|
|
12
12
|
useEffect(() => {
|
|
13
|
+
const toDispose = new DisposableStore();
|
|
13
14
|
const run = () => {
|
|
14
15
|
const ref = documentService.getModelReference(uri);
|
|
15
16
|
if (ref) {
|
|
16
|
-
|
|
17
|
+
setInstance(ref.instance);
|
|
18
|
+
ref.dispose();
|
|
17
19
|
}
|
|
18
20
|
};
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
toDispose.add(
|
|
23
|
+
documentService.onDocumentModelCreated(uri.toString(), () => {
|
|
24
|
+
run();
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
23
27
|
|
|
24
28
|
run();
|
|
25
29
|
return () => {
|
|
26
30
|
toDispose.dispose();
|
|
27
|
-
if (ref) {
|
|
28
|
-
ref.dispose();
|
|
29
|
-
}
|
|
30
31
|
};
|
|
31
32
|
}, [uri]);
|
|
32
33
|
|
|
33
|
-
return
|
|
34
|
+
return instance;
|
|
34
35
|
}
|
|
@@ -4,12 +4,12 @@ import { useEffect, useMemo, useState } from 'react';
|
|
|
4
4
|
import { formatLocalize, useInjectable } from '@opensumi/ide-core-browser';
|
|
5
5
|
import { DisposableStore, URI } from '@opensumi/ide-utils';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { useEditorDocumentModel } from '../hooks/useEditor';
|
|
8
8
|
|
|
9
9
|
import { MergeConflictService } from './merge-conflict.service';
|
|
10
10
|
|
|
11
11
|
export function useMergeConflictModel(uri: URI) {
|
|
12
|
-
const editorModel =
|
|
12
|
+
const editorModel = useEditorDocumentModel(uri);
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* 如果是原来就有冲突的文件,当冲突没了之后,仍然显示冲突
|
|
@@ -28,9 +28,8 @@ export function useMergeConflictModel(uri: URI) {
|
|
|
28
28
|
const disposables = new DisposableStore();
|
|
29
29
|
|
|
30
30
|
if (editorModel) {
|
|
31
|
-
const { instance } = editorModel;
|
|
32
31
|
const run = () => {
|
|
33
|
-
const n = mergeConflictService.scanDocument(
|
|
32
|
+
const n = mergeConflictService.scanDocument(editorModel.getMonacoModel());
|
|
34
33
|
setConflictsCount(n);
|
|
35
34
|
if (n > 0) {
|
|
36
35
|
setIsInitialVisiable(true);
|
|
@@ -40,7 +39,7 @@ export function useMergeConflictModel(uri: URI) {
|
|
|
40
39
|
const debounceRun = debounce(run, 150);
|
|
41
40
|
|
|
42
41
|
disposables.add(
|
|
43
|
-
|
|
42
|
+
editorModel.getMonacoModel().onDidChangeContent(() => {
|
|
44
43
|
debounceRun();
|
|
45
44
|
}),
|
|
46
45
|
);
|
|
@@ -112,8 +112,10 @@ export class CallHierarchyService implements ICallHierarchyService {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
async prepareCallHierarchyProvider(resource: Uri, position: Position) {
|
|
115
|
-
let
|
|
116
|
-
let
|
|
115
|
+
let textModelReference = this.modelService.getModelReference(URI.parse(resource.toString()));
|
|
116
|
+
let textModel: ITextModel | undefined = textModelReference?.instance.getMonacoModel();
|
|
117
|
+
textModelReference?.dispose();
|
|
118
|
+
|
|
117
119
|
if (!textModel) {
|
|
118
120
|
const result = await this.modelService.createModelReference(URI.parse(resource.toString()));
|
|
119
121
|
textModel = result.instance.getMonacoModel();
|
|
@@ -104,8 +104,11 @@ export class TypeHierarchyService implements ITypeHierarchyService {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
async prepareTypeHierarchyProvider(resource: Uri, position: Position) {
|
|
107
|
-
let
|
|
108
|
-
|
|
107
|
+
let textModelReference = this.modelService.getModelReference(URI.parse(resource.toString()));
|
|
108
|
+
|
|
109
|
+
let textModel: ITextModel | undefined = textModelReference?.instance.getMonacoModel();
|
|
110
|
+
textModelReference?.dispose();
|
|
111
|
+
|
|
109
112
|
if (!textModel) {
|
|
110
113
|
const result = await this.modelService.createModelReference(URI.parse(resource.toString()));
|
|
111
114
|
textModel = result.instance.getMonacoModel();
|
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
.navigation_icon {
|
|
18
|
-
font-size: 12px;
|
|
18
|
+
font-size: 12px !important;
|
|
19
19
|
color: var(--breadcrumb-foreground);
|
|
20
20
|
}
|
|
21
|
+
|
|
21
22
|
.navigation-part {
|
|
22
23
|
color: var(--breadcrumb-foreground);
|
|
23
|
-
font-size: 12px;
|
|
24
|
+
font-size: 12px !important;
|
|
24
25
|
padding: 0 4px;
|
|
25
26
|
position: relative;
|
|
26
27
|
line-height: 22px;
|
|
@@ -56,7 +56,7 @@ export const NavigationBar = ({ editorGroup }: { editorGroup: EditorGroup }) =>
|
|
|
56
56
|
}
|
|
57
57
|
return parts.length === 0 ? null : (
|
|
58
58
|
<div
|
|
59
|
-
className={styles_navigation_container}
|
|
59
|
+
className={cls('kt-navigation-container', styles_navigation_container)}
|
|
60
60
|
onContextMenu={(event) => {
|
|
61
61
|
event.preventDefault();
|
|
62
62
|
}}
|
package/src/browser/tab.view.tsx
CHANGED
|
@@ -13,8 +13,8 @@ import React, {
|
|
|
13
13
|
useState,
|
|
14
14
|
} from 'react';
|
|
15
15
|
|
|
16
|
-
import { Scrollbars } from '@opensumi/ide-components';
|
|
17
16
|
import {
|
|
17
|
+
ComponentRegistry,
|
|
18
18
|
ConfigContext,
|
|
19
19
|
Disposable,
|
|
20
20
|
DisposableCollection,
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
getExternalIcon,
|
|
30
30
|
getIcon,
|
|
31
31
|
getSlotLocation,
|
|
32
|
+
renderView,
|
|
32
33
|
useDesignStyles,
|
|
33
34
|
} from '@opensumi/ide-core-browser';
|
|
34
35
|
import { InlineMenuBar } from '@opensumi/ide-core-browser/lib/components/actions';
|
|
@@ -36,9 +37,18 @@ import { LayoutViewSizeConfig } from '@opensumi/ide-core-browser/lib/layout/cons
|
|
|
36
37
|
import { VIEW_CONTAINERS } from '@opensumi/ide-core-browser/lib/layout/view-id';
|
|
37
38
|
import { IMenuRegistry, MenuId } from '@opensumi/ide-core-browser/lib/menu/next';
|
|
38
39
|
import { useInjectable, useUpdateOnEventBusEvent } from '@opensumi/ide-core-browser/lib/react-hooks';
|
|
40
|
+
import { formatLocalize } from '@opensumi/ide-core-common';
|
|
39
41
|
|
|
40
|
-
import {
|
|
41
|
-
|
|
42
|
+
import {
|
|
43
|
+
IEditorGroup,
|
|
44
|
+
IResource,
|
|
45
|
+
ResourceDidUpdateEvent,
|
|
46
|
+
ResourceService,
|
|
47
|
+
TabbarRightExtraContentId,
|
|
48
|
+
WorkbenchEditorService,
|
|
49
|
+
} from '../common';
|
|
50
|
+
|
|
51
|
+
import { Scroll } from './editor-scrollbar';
|
|
42
52
|
import styles from './editor.module.less';
|
|
43
53
|
import { TabTitleMenuService } from './menu/title-context.menu';
|
|
44
54
|
import {
|
|
@@ -72,6 +82,7 @@ export const Tabs = ({ group }: ITabsProps) => {
|
|
|
72
82
|
const menuRegistry = useInjectable<IMenuRegistry>(IMenuRegistry);
|
|
73
83
|
const editorTabService = useInjectable<IEditorTabService>(IEditorTabService);
|
|
74
84
|
const layoutViewSize = useInjectable<LayoutViewSizeConfig>(LayoutViewSizeConfig);
|
|
85
|
+
const componentRegistry = useInjectable<ComponentRegistry>(ComponentRegistry);
|
|
75
86
|
|
|
76
87
|
const styles_tab_right = useDesignStyles(styles.tab_right, 'tab_right');
|
|
77
88
|
const styles_close_tab = useDesignStyles(styles.close_tab, 'close_tab');
|
|
@@ -105,6 +116,13 @@ export const Tabs = ({ group }: ITabsProps) => {
|
|
|
105
116
|
|
|
106
117
|
const slotLocation = useMemo(() => getSlotLocation(pkgName, configContext.layoutConfig), []);
|
|
107
118
|
|
|
119
|
+
const RightExtraContentViewConfig = React.useMemo(() => {
|
|
120
|
+
const firstView = componentRegistry.getComponentRegistryInfo(TabbarRightExtraContentId)?.views?.[0];
|
|
121
|
+
if (firstView) {
|
|
122
|
+
return firstView;
|
|
123
|
+
}
|
|
124
|
+
}, []);
|
|
125
|
+
|
|
108
126
|
useUpdateOnGroupTabChange(group);
|
|
109
127
|
useUpdateOnEventBusEvent(
|
|
110
128
|
ResourceDidUpdateEvent,
|
|
@@ -360,7 +378,9 @@ export const Tabs = ({ group }: ITabsProps) => {
|
|
|
360
378
|
return editorTabService.renderEditorTab(
|
|
361
379
|
<>
|
|
362
380
|
<div className={tabsLoadingMap[resource.uri.toString()] ? 'loading_indicator' : cls(resource.icon)}> </div>
|
|
363
|
-
<div
|
|
381
|
+
<div tabIndex={0} role='tab' aria-selected={isCurrent ? 'true' : 'false'}>
|
|
382
|
+
{resource.name}
|
|
383
|
+
</div>
|
|
364
384
|
{subname ? <div className={styles.subname}>{subname}</div> : null}
|
|
365
385
|
{decoration.readOnly ? (
|
|
366
386
|
<span className={cls(getExternalIcon('lock'), styles.editor_readonly_icon)}></span>
|
|
@@ -380,7 +400,12 @@ export const Tabs = ({ group }: ITabsProps) => {
|
|
|
380
400
|
}}
|
|
381
401
|
>
|
|
382
402
|
{editorTabService.renderTabCloseComponent(
|
|
383
|
-
<div
|
|
403
|
+
<div
|
|
404
|
+
className={cls(getIcon('close'), styles_kt_editor_close_icon)}
|
|
405
|
+
tabIndex={0}
|
|
406
|
+
role='button'
|
|
407
|
+
aria-label={formatLocalize('editor.closeTab.title', resource.name)}
|
|
408
|
+
/>,
|
|
384
409
|
)}
|
|
385
410
|
</div>
|
|
386
411
|
</div>
|
|
@@ -401,6 +426,7 @@ export const Tabs = ({ group }: ITabsProps) => {
|
|
|
401
426
|
[styles_kt_editor_tabs_current_last]: curTabIndex === group.resources.length - 1,
|
|
402
427
|
})}
|
|
403
428
|
ref={contentRef as any}
|
|
429
|
+
role='tablist'
|
|
404
430
|
>
|
|
405
431
|
{group.resources.map((resource, i) => {
|
|
406
432
|
let ref: HTMLDivElement | null;
|
|
@@ -492,18 +518,19 @@ export const Tabs = ({ group }: ITabsProps) => {
|
|
|
492
518
|
onDoubleClick={handleEmptyDBClick}
|
|
493
519
|
>
|
|
494
520
|
{!wrapMode ? (
|
|
495
|
-
<
|
|
496
|
-
tabBarMode
|
|
521
|
+
<Scroll
|
|
497
522
|
forwardedRef={(el) => (el ? (tabContainer.current = el) : null)}
|
|
498
523
|
className={styles.kt_editor_tabs_scroll}
|
|
499
524
|
>
|
|
500
525
|
{renderTabContent()}
|
|
501
|
-
</
|
|
526
|
+
</Scroll>
|
|
502
527
|
) : (
|
|
503
528
|
<div className={styles.kt_editor_wrap_container}>{renderTabContent()}</div>
|
|
504
529
|
)}
|
|
505
530
|
</div>
|
|
506
531
|
{!wrapMode && <EditorActions ref={editorActionRef} group={group} />}
|
|
532
|
+
|
|
533
|
+
{renderView(RightExtraContentViewConfig)}
|
|
507
534
|
</div>
|
|
508
535
|
);
|
|
509
536
|
};
|
|
@@ -540,6 +567,11 @@ export const EditorActions = forwardRef<HTMLDivElement, IEditorActionsProps>(
|
|
|
540
567
|
const [hasFocus, setHasFocus] = useState<boolean>(editorService.currentEditorGroup === group);
|
|
541
568
|
const [args, setArgs] = useState<[URI, IEditorGroup, MaybeNull<URI>] | undefined>(acquireArgs());
|
|
542
569
|
|
|
570
|
+
/**
|
|
571
|
+
* 集成场景下可以不展示任何菜单,可以用以下代码取消菜单注册
|
|
572
|
+
* registry.unregisterMenuId(MenuId.EditorTitle);
|
|
573
|
+
* registry.unregisterMenuId(MenuId.EditorTitleRun);
|
|
574
|
+
*/
|
|
543
575
|
const noActions = menu.getMergedMenuNodes().length === 0;
|
|
544
576
|
|
|
545
577
|
useEffect(() => {
|
|
@@ -171,8 +171,8 @@ export class UntitledSchemeResourceProvider extends WithEventBus implements IRes
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
async shouldCloseResourceWithoutConfirm(resource: IResource) {
|
|
174
|
-
const documentModelRef = this.documentModelService.
|
|
175
|
-
if (documentModelRef && documentModelRef.
|
|
174
|
+
const documentModelRef = this.documentModelService.getModelDescription(resource.uri, 'close-resource-check');
|
|
175
|
+
if (documentModelRef && documentModelRef.dirty) {
|
|
176
176
|
return true;
|
|
177
177
|
}
|
|
178
178
|
return false;
|
|
@@ -195,16 +195,14 @@ export class UntitledSchemeResourceProvider extends WithEventBus implements IRes
|
|
|
195
195
|
documentModelRef.dispose();
|
|
196
196
|
return false;
|
|
197
197
|
} else {
|
|
198
|
+
documentModelRef.dispose();
|
|
198
199
|
return true;
|
|
199
200
|
}
|
|
200
201
|
}
|
|
201
202
|
|
|
202
203
|
async shouldCloseResource(resource: IResource) {
|
|
203
|
-
const documentModelRef = this.documentModelService.
|
|
204
|
-
if (!documentModelRef || !documentModelRef.
|
|
205
|
-
if (documentModelRef) {
|
|
206
|
-
documentModelRef.dispose();
|
|
207
|
-
}
|
|
204
|
+
const documentModelRef = this.documentModelService.getModelDescription(resource.uri, 'close-resource-check');
|
|
205
|
+
if (!documentModelRef || !documentModelRef.dirty) {
|
|
208
206
|
return true;
|
|
209
207
|
}
|
|
210
208
|
// 询问用户是否保存
|
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
debounce,
|
|
45
45
|
formatLocalize,
|
|
46
46
|
getDebugLogger,
|
|
47
|
+
isDefined,
|
|
47
48
|
isUndefinedOrNull,
|
|
48
49
|
localize,
|
|
49
50
|
makeRandomHexString,
|
|
@@ -435,10 +436,9 @@ export class WorkbenchEditorServiceImpl extends WithEventBus implements Workbenc
|
|
|
435
436
|
// contextKeys
|
|
436
437
|
const getLanguageFromModel = (uri: URI) => {
|
|
437
438
|
let result: string | null = null;
|
|
438
|
-
const modelRef = this.documentModelManager.
|
|
439
|
+
const modelRef = this.documentModelManager.getModelDescription(uri, 'resourceContextKey');
|
|
439
440
|
if (modelRef) {
|
|
440
|
-
result = modelRef.
|
|
441
|
-
modelRef.dispose();
|
|
441
|
+
result = modelRef.languageId;
|
|
442
442
|
}
|
|
443
443
|
return result;
|
|
444
444
|
};
|
|
@@ -491,10 +491,13 @@ export class WorkbenchEditorServiceImpl extends WithEventBus implements Workbenc
|
|
|
491
491
|
state = this.openedResourceState.get<IEditorGridState>('grid', state);
|
|
492
492
|
}
|
|
493
493
|
this.topGrid = new EditorGrid();
|
|
494
|
-
this.topGrid
|
|
495
|
-
|
|
496
|
-
this.
|
|
497
|
-
|
|
494
|
+
this.addDispose(this.topGrid);
|
|
495
|
+
this.addDispose(
|
|
496
|
+
this.topGrid.onDidGridAndDesendantStateChange(() => {
|
|
497
|
+
this._sortedEditorGroups = undefined;
|
|
498
|
+
this._onDidEditorGroupsChanged.fire();
|
|
499
|
+
}),
|
|
500
|
+
);
|
|
498
501
|
const editorRestorePromises = [];
|
|
499
502
|
const promise = this.topGrid
|
|
500
503
|
.deserialize(state, () => this.createEditorGroup(), editorRestorePromises)
|
|
@@ -714,12 +717,10 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
714
717
|
/**
|
|
715
718
|
* 当前打开的所有resource
|
|
716
719
|
*/
|
|
717
|
-
// @observable.shallow
|
|
718
720
|
resources: IResource[] = [];
|
|
719
721
|
|
|
720
722
|
resourceStatus: Map<IResource, Promise<void>> = new Map();
|
|
721
723
|
|
|
722
|
-
// @observable.ref
|
|
723
724
|
_currentResource: IResource | null;
|
|
724
725
|
|
|
725
726
|
_currentOpenType: IEditorOpenType | null;
|
|
@@ -891,12 +892,9 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
891
892
|
if (!this._resourceContext) {
|
|
892
893
|
const getLanguageFromModel = (uri: URI) => {
|
|
893
894
|
let result: string | null = null;
|
|
894
|
-
const modelRef = this.documentModelManager.
|
|
895
|
+
const modelRef = this.documentModelManager.getModelDescription(uri, 'resourceContextKey');
|
|
895
896
|
if (modelRef) {
|
|
896
|
-
|
|
897
|
-
result = modelRef.instance.languageId;
|
|
898
|
-
}
|
|
899
|
-
modelRef.dispose();
|
|
897
|
+
result = modelRef.languageId;
|
|
900
898
|
}
|
|
901
899
|
return result;
|
|
902
900
|
};
|
|
@@ -1411,6 +1409,9 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1411
1409
|
if (options && options.label) {
|
|
1412
1410
|
resource.name = options.label;
|
|
1413
1411
|
}
|
|
1412
|
+
if (options && isDefined(options.supportsRevive)) {
|
|
1413
|
+
resource.supportsRevive = options.supportsRevive;
|
|
1414
|
+
}
|
|
1414
1415
|
let replaceResource: IResource | null = null;
|
|
1415
1416
|
if (options && options.index !== undefined && options.index < this.resources.length) {
|
|
1416
1417
|
replaceResource = this.resources[options.index];
|
|
@@ -2302,9 +2303,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
2302
2303
|
// 否则使用 document 进行保存 (如果有)
|
|
2303
2304
|
const docRef = this.documentModelManager.getModelReference(resource.uri);
|
|
2304
2305
|
if (docRef) {
|
|
2305
|
-
|
|
2306
|
-
await docRef.instance.save(undefined, reason);
|
|
2307
|
-
}
|
|
2306
|
+
await docRef.instance.save(undefined, reason);
|
|
2308
2307
|
docRef.dispose();
|
|
2309
2308
|
}
|
|
2310
2309
|
}
|
|
@@ -2337,11 +2336,9 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
2337
2336
|
|
|
2338
2337
|
hasDirty(): boolean {
|
|
2339
2338
|
for (const r of this.resources) {
|
|
2340
|
-
const docRef = this.documentModelManager.
|
|
2339
|
+
const docRef = this.documentModelManager.getModelDescription(r.uri);
|
|
2341
2340
|
if (docRef) {
|
|
2342
|
-
|
|
2343
|
-
docRef.dispose();
|
|
2344
|
-
if (isDirty) {
|
|
2341
|
+
if (docRef.dirty) {
|
|
2345
2342
|
return true;
|
|
2346
2343
|
}
|
|
2347
2344
|
}
|
|
@@ -2355,15 +2352,13 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
2355
2352
|
calcDirtyCount(countedUris: Set<string> = new Set<string>()): number {
|
|
2356
2353
|
let count = 0;
|
|
2357
2354
|
for (const r of this.resources) {
|
|
2358
|
-
const docRef = this.documentModelManager.
|
|
2355
|
+
const docRef = this.documentModelManager.getModelDescription(r.uri, 'calc-dirty-count');
|
|
2359
2356
|
if (countedUris.has(r.uri.toString())) {
|
|
2360
2357
|
continue;
|
|
2361
2358
|
}
|
|
2362
2359
|
countedUris.add(r.uri.toString());
|
|
2363
2360
|
if (docRef) {
|
|
2364
|
-
|
|
2365
|
-
docRef.dispose();
|
|
2366
|
-
if (isDirty) {
|
|
2361
|
+
if (docRef.dirty) {
|
|
2367
2362
|
count += 1;
|
|
2368
2363
|
}
|
|
2369
2364
|
}
|
package/src/common/editor.ts
CHANGED
|
@@ -29,10 +29,66 @@ import type { ITextModel, ITextModelUpdateOptions } from '@opensumi/monaco-edito
|
|
|
29
29
|
|
|
30
30
|
export { ShowLightbulbIconMode } from '@opensumi/ide-monaco';
|
|
31
31
|
|
|
32
|
+
export interface IEditorDocumentDescription {
|
|
33
|
+
/**
|
|
34
|
+
* 文档URI
|
|
35
|
+
*/
|
|
36
|
+
readonly uri: URI;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A unique identifier associated with this model.
|
|
40
|
+
*/
|
|
41
|
+
readonly id: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 编码
|
|
45
|
+
*/
|
|
46
|
+
readonly encoding: string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 行末结束
|
|
50
|
+
*/
|
|
51
|
+
readonly eol: EOL;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 语言Id
|
|
55
|
+
*/
|
|
56
|
+
readonly languageId: string;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 是否被修改过
|
|
60
|
+
*/
|
|
61
|
+
readonly dirty: boolean;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 能否修改
|
|
65
|
+
*/
|
|
66
|
+
readonly readonly: boolean;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 能否保存
|
|
70
|
+
*/
|
|
71
|
+
readonly savable: boolean;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 是否永远都显示 dirty
|
|
75
|
+
*/
|
|
76
|
+
readonly alwaysDirty: boolean;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 即便是 dirty 也要被 dispose
|
|
80
|
+
*/
|
|
81
|
+
readonly disposeEvenDirty: boolean;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 是否关闭自动保存功能
|
|
85
|
+
*/
|
|
86
|
+
readonly closeAutoSave: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
32
89
|
/**
|
|
33
90
|
* editorDocumentModel is a wrapped concept for monaco's textModel
|
|
34
91
|
*/
|
|
35
|
-
|
|
36
92
|
export interface IEditorDocumentModel extends IDisposable {
|
|
37
93
|
/**
|
|
38
94
|
* 文档URI
|
|
@@ -636,6 +692,8 @@ export interface IResourceOpenOptions {
|
|
|
636
692
|
* 当关闭时指定 force 参数,用来跳过 shouldClose 等逻辑
|
|
637
693
|
*/
|
|
638
694
|
forceClose?: boolean;
|
|
695
|
+
|
|
696
|
+
supportsRevive?: boolean;
|
|
639
697
|
}
|
|
640
698
|
|
|
641
699
|
export interface IResourceOpenResult {
|
package/src/common/index.ts
CHANGED