@opensumi/ide-editor 3.2.5-next-1725277870.0 → 3.2.5-next-1725353631.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 +1 -2
- package/lib/browser/doc-model/editor-document-model-service.d.ts.map +1 -1
- package/lib/browser/doc-model/editor-document-model-service.js +0 -22
- package/lib/browser/doc-model/editor-document-model-service.js.map +1 -1
- package/lib/browser/doc-model/editor-document-model.d.ts +0 -1
- package/lib/browser/doc-model/editor-document-model.d.ts.map +1 -1
- package/lib/browser/doc-model/editor-document-model.js +0 -14
- 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 +0 -1
- package/lib/browser/doc-model/saveParticipants.js.map +1 -1
- package/lib/browser/doc-model/types.d.ts +1 -3
- 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.module.less +1 -1
- package/lib/browser/editor.contribution.d.ts.map +1 -1
- package/lib/browser/editor.contribution.js +4 -7
- package/lib/browser/editor.contribution.js.map +1 -1
- package/lib/browser/editor.module.less +11 -3
- package/lib/browser/format/formatter-selector.d.ts.map +1 -1
- package/lib/browser/format/formatter-selector.js +8 -6
- 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 +7 -5
- package/lib/browser/fs-resource/fs-resource.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 +11 -10
- package/lib/browser/hooks/useEditor.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +0 -5
- package/lib/browser/index.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 +4 -3
- 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/tab.view.d.ts.map +1 -1
- package/lib/browser/tab.view.js +0 -5
- 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 +7 -5
- 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 +20 -12
- package/lib/browser/workbench-editor.service.js.map +1 -1
- package/lib/common/editor.d.ts +0 -47
- package/lib/common/editor.d.ts.map +1 -1
- package/lib/common/editor.js.map +1 -1
- package/lib/common/index.d.ts +3 -4
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +3 -4
- package/lib/common/index.js.map +1 -1
- package/lib/common/language.d.ts +0 -1
- package/lib/common/language.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/browser/doc-model/editor-document-model-service.ts +1 -25
- package/src/browser/doc-model/editor-document-model.ts +0 -18
- package/src/browser/doc-model/saveParticipants.ts +0 -1
- package/src/browser/doc-model/types.ts +1 -3
- package/src/browser/editor-scrollbar/index.module.less +1 -1
- package/src/browser/editor.contribution.ts +3 -8
- package/src/browser/editor.module.less +11 -3
- package/src/browser/format/formatter-selector.ts +8 -6
- package/src/browser/fs-resource/fs-resource.ts +7 -5
- package/src/browser/hooks/useEditor.ts +12 -13
- package/src/browser/index.ts +0 -6
- package/src/browser/merge-conflict/merge-conflict.model.ts +5 -4
- package/src/browser/monaco-contrib/callHierarchy/callHierarchy.service.ts +2 -4
- package/src/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.ts +2 -5
- package/src/browser/tab.view.tsx +0 -5
- package/src/browser/untitled-resource.ts +7 -5
- package/src/browser/workbench-editor.service.ts +21 -13
- package/src/common/editor.ts +1 -59
- package/src/common/index.ts +3 -4
- package/src/common/language.ts +0 -1
- package/lib/browser/notebook.service.d.ts +0 -20
- package/lib/browser/notebook.service.d.ts.map +0 -1
- package/lib/browser/notebook.service.js +0 -24
- package/lib/browser/notebook.service.js.map +0 -1
- package/lib/common/notebook.d.ts +0 -169
- package/lib/common/notebook.d.ts.map +0 -1
- package/lib/common/notebook.js +0 -26
- package/lib/common/notebook.js.map +0 -1
- package/src/browser/notebook.service.ts +0 -19
- package/src/common/notebook.ts +0 -196
|
@@ -360,25 +360,7 @@ export class EditorDocumentModel extends Disposable implements IEditorDocumentMo
|
|
|
360
360
|
return this.monacoModel;
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
-
async syncDocumentModelToExtThread() {
|
|
364
|
-
await this.eventBus.fireAndAwait(
|
|
365
|
-
new EditorDocumentModelOptionChangedEvent({
|
|
366
|
-
uri: this.uri,
|
|
367
|
-
languageId: this.languageId,
|
|
368
|
-
encoding: this.encoding,
|
|
369
|
-
eol: this.eol,
|
|
370
|
-
dirty: this.dirty,
|
|
371
|
-
}),
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
363
|
async save(force = false, reason: SaveReason = SaveReason.Manual): Promise<boolean> {
|
|
376
|
-
if (!this.dirty) {
|
|
377
|
-
// 如果文档内容没有变化,则只同步新状态到插件进程
|
|
378
|
-
await this.syncDocumentModelToExtThread();
|
|
379
|
-
return false;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
364
|
const provider = await this.contentRegistry.getProvider(this.uri);
|
|
383
365
|
const isReadonly = await provider?.isReadonly(this.uri);
|
|
384
366
|
|
|
@@ -12,7 +12,7 @@ import * as monaco from '@opensumi/ide-monaco';
|
|
|
12
12
|
import { EOL, EndOfLineSequence } from '@opensumi/ide-monaco/lib/browser/monaco-api/types';
|
|
13
13
|
|
|
14
14
|
import { IEditorDocumentModelContentChange, SaveReason } from '../../common';
|
|
15
|
-
import {
|
|
15
|
+
import { IEditorDocumentModel, IEditorDocumentModelRef } from '../../common/editor';
|
|
16
16
|
|
|
17
17
|
export interface IDocModelUpdateOptions extends monaco.editor.ITextModelUpdateOptions {
|
|
18
18
|
detectIndentation?: boolean;
|
|
@@ -130,7 +130,6 @@ export interface IEditorDocumentModelService {
|
|
|
130
130
|
* 当文档从来没有被打开过时,返回null
|
|
131
131
|
*/
|
|
132
132
|
getModelReference(uri: URI, reason?: string): IEditorDocumentModelRef | null;
|
|
133
|
-
getModelDescription(uri: URI, reason?: string): IEditorDocumentDescription | null;
|
|
134
133
|
|
|
135
134
|
/**
|
|
136
135
|
* 获得全部model
|
|
@@ -194,7 +193,6 @@ export interface IEditorDocumentModelOptionChangedEventPayload {
|
|
|
194
193
|
encoding?: string;
|
|
195
194
|
languageId?: string;
|
|
196
195
|
eol?: EOL;
|
|
197
|
-
dirty?: boolean;
|
|
198
196
|
}
|
|
199
197
|
|
|
200
198
|
export class EditorDocumentModelCreationEvent extends BasicEvent<IEditorDocumentModelCreationEventPayload> {}
|
|
@@ -808,12 +808,7 @@ export class EditorContribution
|
|
|
808
808
|
return;
|
|
809
809
|
}
|
|
810
810
|
|
|
811
|
-
|
|
812
|
-
if (!ref) {
|
|
813
|
-
return;
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
return ref.encoding;
|
|
811
|
+
return this.editorDocumentModelService.getModelReference(uri)?.instance.encoding;
|
|
817
812
|
},
|
|
818
813
|
});
|
|
819
814
|
|
|
@@ -837,8 +832,8 @@ export class EditorContribution
|
|
|
837
832
|
|
|
838
833
|
const provider = await this.contentRegistry.getProvider(uri);
|
|
839
834
|
const guessedEncoding = await provider?.guessEncoding?.(uri);
|
|
840
|
-
const ref = this.editorDocumentModelService.
|
|
841
|
-
const currentEncoding = documentModel?.encoding ?? ref?.encoding;
|
|
835
|
+
const ref = this.editorDocumentModelService.getModelReference(uri);
|
|
836
|
+
const currentEncoding = documentModel?.encoding ?? ref?.instance.encoding;
|
|
842
837
|
|
|
843
838
|
let matchIndex: number | undefined;
|
|
844
839
|
const encodingItems: QuickPickItem<string>[] = Object.keys(SUPPORTED_ENCODINGS)
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
position: absolute;
|
|
49
49
|
width: 100%;
|
|
50
50
|
height: 100%;
|
|
51
|
-
pointer-events: none;
|
|
52
51
|
}
|
|
53
52
|
.kt_editor_tabs {
|
|
54
53
|
display: flex;
|
|
@@ -133,6 +132,12 @@
|
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
134
|
|
|
135
|
+
.kt_editor_tabs_scroll_wrapper {
|
|
136
|
+
flex-grow: 1;
|
|
137
|
+
width: 100%;
|
|
138
|
+
position: relative;
|
|
139
|
+
}
|
|
140
|
+
|
|
136
141
|
.kt_editor_tabs_scroll {
|
|
137
142
|
overflow-y: hidden;
|
|
138
143
|
:global(.loading_indicator) {
|
|
@@ -179,7 +184,7 @@
|
|
|
179
184
|
}
|
|
180
185
|
.kt_editor_tabs_content {
|
|
181
186
|
overflow-y: hidden;
|
|
182
|
-
display: flex;
|
|
187
|
+
display: inline-flex;
|
|
183
188
|
position: relative;
|
|
184
189
|
height: 100%;
|
|
185
190
|
&.kt_on_drag_over {
|
|
@@ -192,6 +197,8 @@
|
|
|
192
197
|
display: flex;
|
|
193
198
|
position: relative;
|
|
194
199
|
align-items: center;
|
|
200
|
+
flex-shrink: 1;
|
|
201
|
+
flex-grow: 1;
|
|
195
202
|
padding: 0 12px;
|
|
196
203
|
border-right: 1px solid var(--tab-border);
|
|
197
204
|
height: 100%;
|
|
@@ -202,6 +209,7 @@
|
|
|
202
209
|
color: var(--tab-inactiveForeground);
|
|
203
210
|
background: var(--tab-inactiveBackground);
|
|
204
211
|
border-top: 1px solid transparent;
|
|
212
|
+
box-sizing: border-box;
|
|
205
213
|
z-index: 1;
|
|
206
214
|
word-break: keep-all;
|
|
207
215
|
white-space: nowrap;
|
|
@@ -340,7 +348,7 @@
|
|
|
340
348
|
}
|
|
341
349
|
|
|
342
350
|
.editorGroupHeader {
|
|
343
|
-
z-index: var(--stacking-level-
|
|
351
|
+
z-index: var(--stacking-level-background, 0);
|
|
344
352
|
position: relative;
|
|
345
353
|
}
|
|
346
354
|
|
|
@@ -47,11 +47,12 @@ export class FormattingSelector implements IFormattingSelector {
|
|
|
47
47
|
mode: FormattingMode,
|
|
48
48
|
_kind: FormattingKind,
|
|
49
49
|
): Promise<T | undefined> {
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
50
|
+
const docRef = this.modelService.getModelReference(URI.from(document.uri.toJSON()));
|
|
51
|
+
if (!docRef) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
const languageId =
|
|
54
|
+
const languageId = docRef.instance.languageId;
|
|
55
|
+
docRef.dispose();
|
|
55
56
|
const preferred = this.getPreferedFormatter(languageId);
|
|
56
57
|
|
|
57
58
|
const elements: { [key: string]: T } = {};
|
|
@@ -119,11 +120,12 @@ export class FormattingSelector implements IFormattingSelector {
|
|
|
119
120
|
formatters: T[],
|
|
120
121
|
document: ITextModel,
|
|
121
122
|
): Promise<T | undefined> {
|
|
122
|
-
const
|
|
123
|
-
if (!
|
|
123
|
+
const docRef = this.modelService.getModelReference(URI.from(document.uri.toJSON()));
|
|
124
|
+
if (!docRef) {
|
|
124
125
|
return;
|
|
125
126
|
}
|
|
126
|
-
const languageId =
|
|
127
|
+
const languageId = docRef.instance.languageId;
|
|
128
|
+
docRef.dispose();
|
|
127
129
|
|
|
128
130
|
const elements: { [key: string]: T } = {};
|
|
129
131
|
formatters.forEach((provider: T) => {
|
|
@@ -181,8 +181,8 @@ export class FileSystemResourceProvider extends WithEventBus implements IResourc
|
|
|
181
181
|
this.cachedFileStat.delete(resource.uri.toString());
|
|
182
182
|
}
|
|
183
183
|
async shouldCloseResourceWithoutConfirm(resource: IResource) {
|
|
184
|
-
const documentModelRef = this.documentModelService.
|
|
185
|
-
if (documentModelRef && documentModelRef.dirty) {
|
|
184
|
+
const documentModelRef = this.documentModelService.getModelReference(resource.uri, 'close-resource-check');
|
|
185
|
+
if (documentModelRef && documentModelRef.instance.dirty) {
|
|
186
186
|
return true;
|
|
187
187
|
}
|
|
188
188
|
return false;
|
|
@@ -204,7 +204,6 @@ export class FileSystemResourceProvider extends WithEventBus implements IResourc
|
|
|
204
204
|
documentModelRef.dispose();
|
|
205
205
|
return false;
|
|
206
206
|
} else {
|
|
207
|
-
documentModelRef.dispose();
|
|
208
207
|
return true;
|
|
209
208
|
}
|
|
210
209
|
}
|
|
@@ -223,8 +222,11 @@ export class FileSystemResourceProvider extends WithEventBus implements IResourc
|
|
|
223
222
|
}
|
|
224
223
|
}
|
|
225
224
|
}
|
|
226
|
-
const documentModelRef = this.documentModelService.
|
|
227
|
-
if (!documentModelRef || !documentModelRef.dirty) {
|
|
225
|
+
const documentModelRef = this.documentModelService.getModelReference(resource.uri, 'close-resource-check');
|
|
226
|
+
if (!documentModelRef || !documentModelRef.instance.dirty) {
|
|
227
|
+
if (documentModelRef) {
|
|
228
|
+
documentModelRef.dispose();
|
|
229
|
+
}
|
|
228
230
|
return true;
|
|
229
231
|
}
|
|
230
232
|
|
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { URI, useInjectable } from '@opensumi/ide-core-browser';
|
|
4
4
|
|
|
5
5
|
import { IEditorDocumentModelService } from '../doc-model/types';
|
|
6
|
-
import {
|
|
6
|
+
import { IEditorDocumentModelRef } from '../types';
|
|
7
7
|
|
|
8
|
-
export function
|
|
8
|
+
export function useEditorDocumentModelRef(uri: URI) {
|
|
9
9
|
const documentService: IEditorDocumentModelService = useInjectable(IEditorDocumentModelService);
|
|
10
|
-
const [
|
|
10
|
+
const [ref, setRef] = useState<IEditorDocumentModelRef | null>(null);
|
|
11
11
|
|
|
12
12
|
useEffect(() => {
|
|
13
|
-
const toDispose = new DisposableStore();
|
|
14
13
|
const run = () => {
|
|
15
14
|
const ref = documentService.getModelReference(uri);
|
|
16
15
|
if (ref) {
|
|
17
|
-
|
|
18
|
-
ref.dispose();
|
|
16
|
+
setRef(ref);
|
|
19
17
|
}
|
|
20
18
|
};
|
|
21
19
|
|
|
22
|
-
toDispose.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}),
|
|
26
|
-
);
|
|
20
|
+
const toDispose = documentService.onDocumentModelCreated(uri.toString(), () => {
|
|
21
|
+
run();
|
|
22
|
+
});
|
|
27
23
|
|
|
28
24
|
run();
|
|
29
25
|
return () => {
|
|
30
26
|
toDispose.dispose();
|
|
27
|
+
if (ref) {
|
|
28
|
+
ref.dispose();
|
|
29
|
+
}
|
|
31
30
|
};
|
|
32
31
|
}, [uri]);
|
|
33
32
|
|
|
34
|
-
return
|
|
33
|
+
return ref;
|
|
35
34
|
}
|
package/src/browser/index.ts
CHANGED
|
@@ -52,7 +52,6 @@ import {
|
|
|
52
52
|
MonacoCommandService,
|
|
53
53
|
} from './monaco-contrib/command/command.service';
|
|
54
54
|
import { TextmateService } from './monaco-contrib/tokenizer/textmate.service';
|
|
55
|
-
import { NotebookService } from './notebook.service';
|
|
56
55
|
import { EditorPreferenceContribution } from './preference/contribution';
|
|
57
56
|
import { EditorPreferences, editorPreferenceSchema } from './preference/schema';
|
|
58
57
|
import { ResourceServiceImpl } from './resource.service';
|
|
@@ -66,7 +65,6 @@ import {
|
|
|
66
65
|
IEditorFeatureRegistry,
|
|
67
66
|
IEditorTabService,
|
|
68
67
|
ILanguageStatusService,
|
|
69
|
-
INotebookService,
|
|
70
68
|
} from './types';
|
|
71
69
|
import { WorkbenchEditorServiceImpl } from './workbench-editor.service';
|
|
72
70
|
export * from './doc-cache';
|
|
@@ -171,10 +169,6 @@ export class EditorModule extends BrowserModule {
|
|
|
171
169
|
token: IEditorTabService,
|
|
172
170
|
useClass: EditorTabService,
|
|
173
171
|
},
|
|
174
|
-
{
|
|
175
|
-
token: INotebookService,
|
|
176
|
-
useClass: NotebookService,
|
|
177
|
-
},
|
|
178
172
|
EditorPreferenceContribution,
|
|
179
173
|
DefaultDiffEditorContribution,
|
|
180
174
|
MergeEditorContribution,
|
|
@@ -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 { useEditorDocumentModelRef } 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 = useEditorDocumentModelRef(uri);
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* 如果是原来就有冲突的文件,当冲突没了之后,仍然显示冲突
|
|
@@ -28,8 +28,9 @@ export function useMergeConflictModel(uri: URI) {
|
|
|
28
28
|
const disposables = new DisposableStore();
|
|
29
29
|
|
|
30
30
|
if (editorModel) {
|
|
31
|
+
const { instance } = editorModel;
|
|
31
32
|
const run = () => {
|
|
32
|
-
const n = mergeConflictService.scanDocument(
|
|
33
|
+
const n = mergeConflictService.scanDocument(instance.getMonacoModel());
|
|
33
34
|
setConflictsCount(n);
|
|
34
35
|
if (n > 0) {
|
|
35
36
|
setIsInitialVisiable(true);
|
|
@@ -39,7 +40,7 @@ export function useMergeConflictModel(uri: URI) {
|
|
|
39
40
|
const debounceRun = debounce(run, 150);
|
|
40
41
|
|
|
41
42
|
disposables.add(
|
|
42
|
-
|
|
43
|
+
instance.getMonacoModel().onDidChangeContent(() => {
|
|
43
44
|
debounceRun();
|
|
44
45
|
}),
|
|
45
46
|
);
|
|
@@ -112,10 +112,8 @@ export class CallHierarchyService implements ICallHierarchyService {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
async prepareCallHierarchyProvider(resource: Uri, position: Position) {
|
|
115
|
-
let
|
|
116
|
-
let
|
|
117
|
-
textModelReference?.dispose();
|
|
118
|
-
|
|
115
|
+
let textModel = this.modelService.getModelReference(URI.parse(resource.toString()))?.instance.getMonacoModel();
|
|
116
|
+
let textModelReference: IDisposable | undefined;
|
|
119
117
|
if (!textModel) {
|
|
120
118
|
const result = await this.modelService.createModelReference(URI.parse(resource.toString()));
|
|
121
119
|
textModel = result.instance.getMonacoModel();
|
|
@@ -104,11 +104,8 @@ export class TypeHierarchyService implements ITypeHierarchyService {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
async prepareTypeHierarchyProvider(resource: Uri, position: Position) {
|
|
107
|
-
let
|
|
108
|
-
|
|
109
|
-
let textModel: ITextModel | undefined = textModelReference?.instance.getMonacoModel();
|
|
110
|
-
textModelReference?.dispose();
|
|
111
|
-
|
|
107
|
+
let textModel = this.modelService.getModelReference(URI.parse(resource.toString()))?.instance.getMonacoModel();
|
|
108
|
+
let textModelReference: IDisposable | undefined;
|
|
112
109
|
if (!textModel) {
|
|
113
110
|
const result = await this.modelService.createModelReference(URI.parse(resource.toString()));
|
|
114
111
|
textModel = result.instance.getMonacoModel();
|
package/src/browser/tab.view.tsx
CHANGED
|
@@ -567,11 +567,6 @@ export const EditorActions = forwardRef<HTMLDivElement, IEditorActionsProps>(
|
|
|
567
567
|
const [hasFocus, setHasFocus] = useState<boolean>(editorService.currentEditorGroup === group);
|
|
568
568
|
const [args, setArgs] = useState<[URI, IEditorGroup, MaybeNull<URI>] | undefined>(acquireArgs());
|
|
569
569
|
|
|
570
|
-
/**
|
|
571
|
-
* 集成场景下可以不展示任何菜单,可以用以下代码取消菜单注册
|
|
572
|
-
* registry.unregisterMenuId(MenuId.EditorTitle);
|
|
573
|
-
* registry.unregisterMenuId(MenuId.EditorTitleRun);
|
|
574
|
-
*/
|
|
575
570
|
const noActions = menu.getMergedMenuNodes().length === 0;
|
|
576
571
|
|
|
577
572
|
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.dirty) {
|
|
174
|
+
const documentModelRef = this.documentModelService.getModelReference(resource.uri, 'close-resource-check');
|
|
175
|
+
if (documentModelRef && documentModelRef.instance.dirty) {
|
|
176
176
|
return true;
|
|
177
177
|
}
|
|
178
178
|
return false;
|
|
@@ -195,14 +195,16 @@ export class UntitledSchemeResourceProvider extends WithEventBus implements IRes
|
|
|
195
195
|
documentModelRef.dispose();
|
|
196
196
|
return false;
|
|
197
197
|
} else {
|
|
198
|
-
documentModelRef.dispose();
|
|
199
198
|
return true;
|
|
200
199
|
}
|
|
201
200
|
}
|
|
202
201
|
|
|
203
202
|
async shouldCloseResource(resource: IResource) {
|
|
204
|
-
const documentModelRef = this.documentModelService.
|
|
205
|
-
if (!documentModelRef || !documentModelRef.dirty) {
|
|
203
|
+
const documentModelRef = this.documentModelService.getModelReference(resource.uri, 'close-resource-check');
|
|
204
|
+
if (!documentModelRef || !documentModelRef.instance.dirty) {
|
|
205
|
+
if (documentModelRef) {
|
|
206
|
+
documentModelRef.dispose();
|
|
207
|
+
}
|
|
206
208
|
return true;
|
|
207
209
|
}
|
|
208
210
|
// 询问用户是否保存
|
|
@@ -44,7 +44,6 @@ import {
|
|
|
44
44
|
debounce,
|
|
45
45
|
formatLocalize,
|
|
46
46
|
getDebugLogger,
|
|
47
|
-
isDefined,
|
|
48
47
|
isUndefinedOrNull,
|
|
49
48
|
localize,
|
|
50
49
|
makeRandomHexString,
|
|
@@ -436,9 +435,10 @@ export class WorkbenchEditorServiceImpl extends WithEventBus implements Workbenc
|
|
|
436
435
|
// contextKeys
|
|
437
436
|
const getLanguageFromModel = (uri: URI) => {
|
|
438
437
|
let result: string | null = null;
|
|
439
|
-
const modelRef = this.documentModelManager.
|
|
438
|
+
const modelRef = this.documentModelManager.getModelReference(uri, 'resourceContextKey');
|
|
440
439
|
if (modelRef) {
|
|
441
|
-
result = modelRef.languageId;
|
|
440
|
+
result = modelRef.instance.languageId;
|
|
441
|
+
modelRef.dispose();
|
|
442
442
|
}
|
|
443
443
|
return result;
|
|
444
444
|
};
|
|
@@ -717,10 +717,12 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
717
717
|
/**
|
|
718
718
|
* 当前打开的所有resource
|
|
719
719
|
*/
|
|
720
|
+
// @observable.shallow
|
|
720
721
|
resources: IResource[] = [];
|
|
721
722
|
|
|
722
723
|
resourceStatus: Map<IResource, Promise<void>> = new Map();
|
|
723
724
|
|
|
725
|
+
// @observable.ref
|
|
724
726
|
_currentResource: IResource | null;
|
|
725
727
|
|
|
726
728
|
_currentOpenType: IEditorOpenType | null;
|
|
@@ -892,9 +894,12 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
892
894
|
if (!this._resourceContext) {
|
|
893
895
|
const getLanguageFromModel = (uri: URI) => {
|
|
894
896
|
let result: string | null = null;
|
|
895
|
-
const modelRef = this.documentModelManager.
|
|
897
|
+
const modelRef = this.documentModelManager.getModelReference(uri, 'resourceContextKey');
|
|
896
898
|
if (modelRef) {
|
|
897
|
-
|
|
899
|
+
if (modelRef) {
|
|
900
|
+
result = modelRef.instance.languageId;
|
|
901
|
+
}
|
|
902
|
+
modelRef.dispose();
|
|
898
903
|
}
|
|
899
904
|
return result;
|
|
900
905
|
};
|
|
@@ -1409,9 +1414,6 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1409
1414
|
if (options && options.label) {
|
|
1410
1415
|
resource.name = options.label;
|
|
1411
1416
|
}
|
|
1412
|
-
if (options && isDefined(options.supportsRevive)) {
|
|
1413
|
-
resource.supportsRevive = options.supportsRevive;
|
|
1414
|
-
}
|
|
1415
1417
|
let replaceResource: IResource | null = null;
|
|
1416
1418
|
if (options && options.index !== undefined && options.index < this.resources.length) {
|
|
1417
1419
|
replaceResource = this.resources[options.index];
|
|
@@ -2303,7 +2305,9 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
2303
2305
|
// 否则使用 document 进行保存 (如果有)
|
|
2304
2306
|
const docRef = this.documentModelManager.getModelReference(resource.uri);
|
|
2305
2307
|
if (docRef) {
|
|
2306
|
-
|
|
2308
|
+
if (docRef.instance.dirty) {
|
|
2309
|
+
await docRef.instance.save(undefined, reason);
|
|
2310
|
+
}
|
|
2307
2311
|
docRef.dispose();
|
|
2308
2312
|
}
|
|
2309
2313
|
}
|
|
@@ -2336,9 +2340,11 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
2336
2340
|
|
|
2337
2341
|
hasDirty(): boolean {
|
|
2338
2342
|
for (const r of this.resources) {
|
|
2339
|
-
const docRef = this.documentModelManager.
|
|
2343
|
+
const docRef = this.documentModelManager.getModelReference(r.uri);
|
|
2340
2344
|
if (docRef) {
|
|
2341
|
-
|
|
2345
|
+
const isDirty = docRef.instance.dirty;
|
|
2346
|
+
docRef.dispose();
|
|
2347
|
+
if (isDirty) {
|
|
2342
2348
|
return true;
|
|
2343
2349
|
}
|
|
2344
2350
|
}
|
|
@@ -2352,13 +2358,15 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
2352
2358
|
calcDirtyCount(countedUris: Set<string> = new Set<string>()): number {
|
|
2353
2359
|
let count = 0;
|
|
2354
2360
|
for (const r of this.resources) {
|
|
2355
|
-
const docRef = this.documentModelManager.
|
|
2361
|
+
const docRef = this.documentModelManager.getModelReference(r.uri, 'calc-dirty-count');
|
|
2356
2362
|
if (countedUris.has(r.uri.toString())) {
|
|
2357
2363
|
continue;
|
|
2358
2364
|
}
|
|
2359
2365
|
countedUris.add(r.uri.toString());
|
|
2360
2366
|
if (docRef) {
|
|
2361
|
-
|
|
2367
|
+
const isDirty = docRef.instance.dirty;
|
|
2368
|
+
docRef.dispose();
|
|
2369
|
+
if (isDirty) {
|
|
2362
2370
|
count += 1;
|
|
2363
2371
|
}
|
|
2364
2372
|
}
|
package/src/common/editor.ts
CHANGED
|
@@ -29,66 +29,10 @@ 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
|
-
|
|
89
32
|
/**
|
|
90
33
|
* editorDocumentModel is a wrapped concept for monaco's textModel
|
|
91
34
|
*/
|
|
35
|
+
|
|
92
36
|
export interface IEditorDocumentModel extends IDisposable {
|
|
93
37
|
/**
|
|
94
38
|
* 文档URI
|
|
@@ -692,8 +636,6 @@ export interface IResourceOpenOptions {
|
|
|
692
636
|
* 当关闭时指定 force 参数,用来跳过 shouldClose 等逻辑
|
|
693
637
|
*/
|
|
694
638
|
forceClose?: boolean;
|
|
695
|
-
|
|
696
|
-
supportsRevive?: boolean;
|
|
697
639
|
}
|
|
698
640
|
|
|
699
641
|
export interface IResourceOpenResult {
|
package/src/common/index.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export * from './components';
|
|
2
1
|
export * from './doc-cache';
|
|
3
2
|
export * from './editor';
|
|
4
|
-
export * from './language';
|
|
5
|
-
export * from './language-status';
|
|
6
|
-
export * from './notebook';
|
|
7
3
|
export * from './resource';
|
|
4
|
+
export * from './language';
|
|
8
5
|
export * from './utils';
|
|
6
|
+
export * from './language-status';
|
|
7
|
+
export * from './components';
|
package/src/common/language.ts
CHANGED
|
@@ -201,7 +201,6 @@ export interface LanguageFilter {
|
|
|
201
201
|
scheme?: string;
|
|
202
202
|
pattern?: string | IRelativePattern;
|
|
203
203
|
hasAccessToAllModels?: boolean;
|
|
204
|
-
notebookType?: string;
|
|
205
204
|
}
|
|
206
205
|
|
|
207
206
|
export type LanguageSelector = string | LanguageFilter | (string | LanguageFilter)[];
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Emitter, Event, UriComponents, WithEventBus } from '@opensumi/ide-core-browser';
|
|
2
|
-
import type { INotebookModelAddedData, INotebookService, NotebookDataDto, NotebookDocumentChangeDto } from './types';
|
|
3
|
-
export declare class NotebookService extends WithEventBus implements INotebookService {
|
|
4
|
-
createNotebook: (data?: NotebookDataDto) => Promise<{
|
|
5
|
-
uri: UriComponents;
|
|
6
|
-
}>;
|
|
7
|
-
openNotebook: (uriComponents: UriComponents) => Promise<{
|
|
8
|
-
uri: UriComponents;
|
|
9
|
-
}>;
|
|
10
|
-
saveNotebook: (uriComponents: UriComponents) => Promise<boolean>;
|
|
11
|
-
protected _onDidOpenNotebookDocument: Emitter<INotebookModelAddedData>;
|
|
12
|
-
onDidOpenNotebookDocument: Event<INotebookModelAddedData>;
|
|
13
|
-
protected _onDidCloseNotebookDocument: Emitter<UriComponents>;
|
|
14
|
-
onDidCloseNotebookDocument: Event<UriComponents>;
|
|
15
|
-
protected _onDidSaveNotebookDocument: Emitter<UriComponents>;
|
|
16
|
-
onDidSaveNotebookDocument: Event<UriComponents>;
|
|
17
|
-
protected _onDidChangeNotebookDocument: Emitter<NotebookDocumentChangeDto>;
|
|
18
|
-
onDidChangeNotebookDocument: Event<NotebookDocumentChangeDto>;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=notebook.service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notebook.service.d.ts","sourceRoot":"","sources":["../../src/browser/notebook.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAEzF,OAAO,KAAK,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAErH,qBACa,eAAgB,SAAQ,YAAa,YAAW,gBAAgB;IAC3E,cAAc,EAAE,CAAC,IAAI,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC;QAAE,GAAG,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC;IAC5E,YAAY,EAAE,CAAC,aAAa,EAAE,aAAa,KAAK,OAAO,CAAC;QAAE,GAAG,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC;IAChF,YAAY,EAAE,CAAC,aAAa,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjE,SAAS,CAAC,0BAA0B,mCAA0C;IAC9E,yBAAyB,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAyC;IAClG,SAAS,CAAC,2BAA2B,yBAAgC;IACrE,0BAA0B,EAAE,KAAK,CAAC,aAAa,CAAC,CAA0C;IAC1F,SAAS,CAAC,0BAA0B,yBAAgC;IACpE,yBAAyB,EAAE,KAAK,CAAC,aAAa,CAAC,CAAyC;IACxF,SAAS,CAAC,4BAA4B,qCAA4C;IAClF,2BAA2B,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAA2C;CACzG"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotebookService = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const di_1 = require("@opensumi/di");
|
|
6
|
-
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
|
|
7
|
-
let NotebookService = class NotebookService extends ide_core_browser_1.WithEventBus {
|
|
8
|
-
constructor() {
|
|
9
|
-
super(...arguments);
|
|
10
|
-
this._onDidOpenNotebookDocument = new ide_core_browser_1.Emitter();
|
|
11
|
-
this.onDidOpenNotebookDocument = this._onDidOpenNotebookDocument.event;
|
|
12
|
-
this._onDidCloseNotebookDocument = new ide_core_browser_1.Emitter();
|
|
13
|
-
this.onDidCloseNotebookDocument = this._onDidCloseNotebookDocument.event;
|
|
14
|
-
this._onDidSaveNotebookDocument = new ide_core_browser_1.Emitter();
|
|
15
|
-
this.onDidSaveNotebookDocument = this._onDidSaveNotebookDocument.event;
|
|
16
|
-
this._onDidChangeNotebookDocument = new ide_core_browser_1.Emitter();
|
|
17
|
-
this.onDidChangeNotebookDocument = this._onDidChangeNotebookDocument.event;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
NotebookService = tslib_1.__decorate([
|
|
21
|
-
(0, di_1.Injectable)()
|
|
22
|
-
], NotebookService);
|
|
23
|
-
exports.NotebookService = NotebookService;
|
|
24
|
-
//# sourceMappingURL=notebook.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notebook.service.js","sourceRoot":"","sources":["../../src/browser/notebook.service.ts"],"names":[],"mappings":";;;;AAAA,qCAA0C;AAC1C,iEAAyF;AAKlF,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,+BAAY;IAA1C;;QAIK,+BAA0B,GAAG,IAAI,0BAAO,EAA2B,CAAC;QAC9E,8BAAyB,GAAmC,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC;QACxF,gCAA2B,GAAG,IAAI,0BAAO,EAAiB,CAAC;QACrE,+BAA0B,GAAyB,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC;QAChF,+BAA0B,GAAG,IAAI,0BAAO,EAAiB,CAAC;QACpE,8BAAyB,GAAyB,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC;QAC9E,iCAA4B,GAAG,IAAI,0BAAO,EAA6B,CAAC;QAClF,gCAA2B,GAAqC,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC;IAC1G,CAAC;CAAA,CAAA;AAZY,eAAe;IAD3B,IAAA,eAAU,GAAE;GACA,eAAe,CAY3B;AAZY,0CAAe"}
|