@opensumi/ide-editor 2.21.13 → 2.22.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/breadcrumb/default.js.map +1 -1
- package/lib/browser/breadcrumb/document-symbol.js.map +1 -1
- package/lib/browser/breadcrumb/index.js.map +1 -1
- package/lib/browser/component.js.map +1 -1
- package/lib/browser/decoration-applier.js.map +1 -1
- package/lib/browser/diff/compare.js.map +1 -1
- package/lib/browser/diff/index.d.ts.map +1 -1
- package/lib/browser/diff/index.js +1 -1
- package/lib/browser/diff/index.js.map +1 -1
- package/lib/browser/doc-cache/empty-doc-cache.js.map +1 -1
- package/lib/browser/doc-cache/local-storage-cache.js.map +1 -1
- package/lib/browser/doc-model/editor-document-model-service.js +3 -3
- package/lib/browser/doc-model/editor-document-model-service.js.map +1 -1
- package/lib/browser/doc-model/editor-document-model.d.ts +8 -0
- package/lib/browser/doc-model/editor-document-model.d.ts.map +1 -1
- package/lib/browser/doc-model/editor-document-model.js +61 -11
- package/lib/browser/doc-model/editor-document-model.js.map +1 -1
- package/lib/browser/doc-model/editor-document-registry.js.map +1 -1
- package/lib/browser/doc-model/override.js.map +1 -1
- package/lib/browser/doc-model/save-task.js +1 -1
- package/lib/browser/doc-model/save-task.js.map +1 -1
- package/lib/browser/doc-model/saveParticipants.d.ts +7 -7
- package/lib/browser/doc-model/saveParticipants.d.ts.map +1 -1
- package/lib/browser/doc-model/saveParticipants.js +69 -38
- package/lib/browser/doc-model/saveParticipants.js.map +1 -1
- package/lib/browser/doc-model/types.d.ts +1 -1
- package/lib/browser/doc-model/types.d.ts.map +1 -1
- package/lib/browser/editor-collection.service.d.ts +8 -3
- package/lib/browser/editor-collection.service.d.ts.map +1 -1
- package/lib/browser/editor-collection.service.js +75 -66
- package/lib/browser/editor-collection.service.js.map +1 -1
- package/lib/browser/editor-opener.js.map +1 -1
- package/lib/browser/editor.contribution.d.ts.map +1 -1
- package/lib/browser/editor.contribution.js +31 -3
- package/lib/browser/editor.contribution.js.map +1 -1
- package/lib/browser/editor.decoration.service.d.ts +5 -6
- package/lib/browser/editor.decoration.service.d.ts.map +1 -1
- package/lib/browser/editor.decoration.service.js +9 -1
- package/lib/browser/editor.decoration.service.js.map +1 -1
- package/lib/browser/editor.override.js +2 -2
- package/lib/browser/editor.override.js.map +1 -1
- package/lib/browser/editor.status-bar.service.js.map +1 -1
- package/lib/browser/editor.view.d.ts.map +1 -1
- package/lib/browser/editor.view.js +20 -23
- package/lib/browser/editor.view.js.map +1 -1
- package/lib/browser/error.d.ts +1 -1
- package/lib/browser/error.d.ts.map +1 -1
- package/lib/browser/feature.js.map +1 -1
- package/lib/browser/format/format.service.js.map +1 -1
- package/lib/browser/format/formatterSelect.js.map +1 -1
- package/lib/browser/fs-resource/file-tree-set.js +6 -6
- package/lib/browser/fs-resource/file-tree-set.js.map +1 -1
- package/lib/browser/fs-resource/fs-editor-doc.js +1 -1
- package/lib/browser/fs-resource/fs-editor-doc.js.map +1 -1
- package/lib/browser/fs-resource/fs-resource.js.map +1 -1
- package/lib/browser/fs-resource/index.js.map +1 -1
- package/lib/browser/history/index.d.ts.map +1 -1
- package/lib/browser/history/index.js +2 -1
- package/lib/browser/history/index.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +2 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/language/diagnostic-collection.d.ts +5 -5
- package/lib/browser/language/diagnostic-collection.d.ts.map +1 -1
- package/lib/browser/language/diagnostic-collection.js +1 -1
- package/lib/browser/language/diagnostic-collection.js.map +1 -1
- package/lib/browser/language/language-status.contribution.js.map +1 -1
- package/lib/browser/language/language-status.service.js.map +1 -1
- package/lib/browser/language/language.service.d.ts +4 -3
- package/lib/browser/language/language.service.d.ts.map +1 -1
- package/lib/browser/language/language.service.js +8 -2
- package/lib/browser/language/language.service.js.map +1 -1
- package/lib/browser/menu/editor.context.js +3 -3
- package/lib/browser/menu/editor.context.js.map +1 -1
- package/lib/browser/menu/editor.menu.d.ts +2 -2
- package/lib/browser/menu/editor.menu.d.ts.map +1 -1
- package/lib/browser/menu/editor.menu.js +6 -8
- package/lib/browser/menu/editor.menu.js.map +1 -1
- package/lib/browser/menu/open-type-menu.contribution.js +9 -9
- package/lib/browser/menu/open-type-menu.contribution.js.map +1 -1
- package/lib/browser/menu/title-context.menu.js.map +1 -1
- package/lib/browser/merge-editor/merge-editor.contribution.d.ts +8 -0
- package/lib/browser/merge-editor/merge-editor.contribution.d.ts.map +1 -0
- package/lib/browser/merge-editor/merge-editor.contribution.js +29 -0
- package/lib/browser/merge-editor/merge-editor.contribution.js.map +1 -0
- package/lib/browser/merge-editor/merge-editor.provider.d.ts +8 -0
- package/lib/browser/merge-editor/merge-editor.provider.d.ts.map +1 -0
- package/lib/browser/merge-editor/merge-editor.provider.js +44 -0
- package/lib/browser/merge-editor/merge-editor.provider.js.map +1 -0
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.contribution.js.map +1 -1
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.js +7 -7
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.js.map +1 -1
- package/lib/browser/monaco-contrib/command/command.service.d.ts +1 -1
- package/lib/browser/monaco-contrib/command/command.service.d.ts.map +1 -1
- package/lib/browser/monaco-contrib/command/command.service.js.map +1 -1
- package/lib/browser/monaco-contrib/tokenizer/textmate-registry.js.map +1 -1
- package/lib/browser/monaco-contrib/tokenizer/textmate.service.d.ts +2 -1
- package/lib/browser/monaco-contrib/tokenizer/textmate.service.d.ts.map +1 -1
- package/lib/browser/monaco-contrib/tokenizer/textmate.service.js +5 -2
- package/lib/browser/monaco-contrib/tokenizer/textmate.service.js.map +1 -1
- package/lib/browser/monaco-contrib/typeHierarchy/typeHierarchy.contribution.js.map +1 -1
- package/lib/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.js +7 -7
- package/lib/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.js.map +1 -1
- package/lib/browser/navigation.module.less +1 -1
- package/lib/browser/navigation.view.d.ts.map +1 -1
- package/lib/browser/navigation.view.js +26 -15
- package/lib/browser/navigation.view.js.map +1 -1
- package/lib/browser/preference/contribution.js.map +1 -1
- package/lib/browser/preference/converter.d.ts +3 -3
- package/lib/browser/preference/converter.d.ts.map +1 -1
- package/lib/browser/preference/schema.d.ts +1 -1
- package/lib/browser/preference/schema.d.ts.map +1 -1
- package/lib/browser/preference/schema.js +8 -8
- package/lib/browser/preference/schema.js.map +1 -1
- package/lib/browser/quick-open/go-to-line.js.map +1 -1
- package/lib/browser/quick-open/workspace-symbol-quickopen.d.ts.map +1 -1
- package/lib/browser/quick-open/workspace-symbol-quickopen.js +2 -2
- package/lib/browser/quick-open/workspace-symbol-quickopen.js.map +1 -1
- package/lib/browser/resource.service.js.map +1 -1
- package/lib/browser/tab.view.d.ts +1 -1
- package/lib/browser/tab.view.d.ts.map +1 -1
- package/lib/browser/tab.view.js +2 -2
- package/lib/browser/tab.view.js.map +1 -1
- package/lib/browser/types.d.ts +5 -5
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/untitled-resource.js +1 -1
- package/lib/browser/untitled-resource.js.map +1 -1
- package/lib/browser/view/suggest-widget.js.map +1 -1
- package/lib/browser/workbench-editor.service.d.ts +17 -0
- package/lib/browser/workbench-editor.service.d.ts.map +1 -1
- package/lib/browser/workbench-editor.service.js +259 -176
- package/lib/browser/workbench-editor.service.js.map +1 -1
- package/lib/common/doc-cache.d.ts +2 -2
- package/lib/common/doc-cache.d.ts.map +1 -1
- package/lib/common/editor.d.ts +20 -6
- package/lib/common/editor.d.ts.map +1 -1
- package/lib/common/editor.js +12 -1
- package/lib/common/editor.js.map +1 -1
- package/lib/common/language.d.ts +18 -7
- package/lib/common/language.d.ts.map +1 -1
- package/lib/common/language.js +15 -7
- package/lib/common/language.js.map +1 -1
- package/lib/common/mocks/workbench-editor.service.js.map +1 -1
- package/lib/common/resource.d.ts +8 -2
- package/lib/common/resource.d.ts.map +1 -1
- package/lib/common/resource.js +1 -0
- package/lib/common/resource.js.map +1 -1
- package/package.json +17 -16
- package/src/browser/breadcrumb/default.ts +299 -0
- package/src/browser/breadcrumb/document-symbol.ts +187 -0
- package/src/browser/breadcrumb/index.ts +96 -0
- package/src/browser/component.ts +204 -0
- package/src/browser/decoration-applier.ts +256 -0
- package/src/browser/diff/compare.ts +99 -0
- package/src/browser/diff/index.ts +81 -0
- package/src/browser/doc-cache/empty-doc-cache.ts +26 -0
- package/src/browser/doc-cache/index.ts +2 -0
- package/src/browser/doc-cache/local-storage-cache.ts +67 -0
- package/src/browser/doc-model/editor-document-error.ts +10 -0
- package/src/browser/doc-model/editor-document-model-service.ts +346 -0
- package/src/browser/doc-model/editor-document-model.ts +690 -0
- package/src/browser/doc-model/editor-document-registry.ts +119 -0
- package/src/browser/doc-model/editor-is-fn.ts +9 -0
- package/src/browser/doc-model/main.ts +4 -0
- package/src/browser/doc-model/override.ts +49 -0
- package/src/browser/doc-model/save-task.ts +88 -0
- package/src/browser/doc-model/saveParticipants.ts +227 -0
- package/src/browser/doc-model/types.ts +350 -0
- package/src/browser/editor-collection.service.ts +790 -0
- package/src/browser/editor-opener.ts +44 -0
- package/src/browser/editor.contribution.ts +1438 -0
- package/src/browser/editor.decoration.service.ts +247 -0
- package/src/browser/editor.less +4 -0
- package/src/browser/editor.module.less +548 -0
- package/src/browser/editor.override.ts +133 -0
- package/src/browser/editor.status-bar.service.ts +116 -0
- package/src/browser/editor.view.tsx +623 -0
- package/src/browser/error.ts +21 -0
- package/src/browser/feature.ts +63 -0
- package/src/browser/format/format.service.ts +95 -0
- package/src/browser/format/formatterSelect.ts +82 -0
- package/src/browser/fs-resource/file-tree-set.ts +126 -0
- package/src/browser/fs-resource/fs-editor-doc.ts +213 -0
- package/src/browser/fs-resource/fs-resource.ts +247 -0
- package/src/browser/fs-resource/index.ts +27 -0
- package/src/browser/grid/grid.service.ts +288 -0
- package/src/browser/history/index.ts +228 -0
- package/src/browser/index.ts +236 -0
- package/src/browser/language/diagnostic-collection.ts +83 -0
- package/src/browser/language/language-status.contribution.ts +81 -0
- package/src/browser/language/language-status.service.ts +32 -0
- package/src/browser/language/language.service.ts +185 -0
- package/src/browser/menu/editor.context.ts +186 -0
- package/src/browser/menu/editor.menu.ts +45 -0
- package/src/browser/menu/open-type-menu.contribution.ts +90 -0
- package/src/browser/menu/title-context.menu.ts +54 -0
- package/src/browser/merge-editor/merge-editor.contribution.ts +25 -0
- package/src/browser/merge-editor/merge-editor.provider.ts +36 -0
- package/src/browser/monaco-contrib/callHierarchy/callHierarchy.contribution.ts +78 -0
- package/src/browser/monaco-contrib/callHierarchy/callHierarchy.service.ts +160 -0
- package/src/browser/monaco-contrib/command/command.service.ts +438 -0
- package/src/browser/monaco-contrib/index.ts +4 -0
- package/src/browser/monaco-contrib/tokenizer/textmate-registry.ts +107 -0
- package/src/browser/monaco-contrib/tokenizer/textmate-tokenizer.ts +104 -0
- package/src/browser/monaco-contrib/tokenizer/textmate.service.ts +925 -0
- package/src/browser/monaco-contrib/typeHierarchy/typeHierarchy.contribution.ts +78 -0
- package/src/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.ts +154 -0
- package/src/browser/navigation.module.less +96 -0
- package/src/browser/navigation.view.tsx +254 -0
- package/src/browser/preference/contribution.ts +8 -0
- package/src/browser/preference/converter.ts +793 -0
- package/src/browser/preference/schema.ts +1896 -0
- package/src/browser/preference/util.ts +14 -0
- package/src/browser/quick-open/go-to-line.ts +164 -0
- package/src/browser/quick-open/workspace-symbol-quickopen.ts +276 -0
- package/src/browser/resource.service.ts +263 -0
- package/src/browser/tab.view.tsx +514 -0
- package/src/browser/types.ts +467 -0
- package/src/browser/untitled-resource.ts +223 -0
- package/src/browser/view/editor.react.tsx +82 -0
- package/src/browser/view/react-hook.tsx +7 -0
- package/src/browser/view/suggest-widget.ts +77 -0
- package/src/browser/view/topPadding.ts +18 -0
- package/src/browser/workbench-editor.service.ts +2291 -0
- package/src/common/doc-cache.ts +117 -0
- package/src/common/editor.ts +799 -0
- package/src/common/index.ts +6 -0
- package/src/common/language-status.ts +33 -0
- package/src/common/language.ts +206 -0
- package/src/common/mocks/workbench-editor.service.ts +52 -0
- package/src/common/resource.ts +147 -0
- package/src/common/utils.ts +10 -0
- package/src/index.ts +1 -0
- package/lib/browser/component/scroll/scroll.d.ts +0 -2
- package/lib/browser/component/scroll/scroll.d.ts.map +0 -1
- package/lib/browser/component/scroll/scroll.js +0 -5
- package/lib/browser/component/scroll/scroll.js.map +0 -1
- package/lib/browser/component/scroll/scroll.module.less +0 -86
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { Injectable, Autowired } from '@opensumi/di';
|
|
2
|
+
import {
|
|
3
|
+
IPosition,
|
|
4
|
+
URI,
|
|
5
|
+
WithEventBus,
|
|
6
|
+
OnEvent,
|
|
7
|
+
PreferenceService,
|
|
8
|
+
addDisposableListener,
|
|
9
|
+
EventType,
|
|
10
|
+
DisposableCollection,
|
|
11
|
+
} from '@opensumi/ide-core-browser';
|
|
12
|
+
|
|
13
|
+
import { WorkbenchEditorService } from '../../common';
|
|
14
|
+
import { EditorSelectionChangeEvent, EditorGroupChangeEvent, EditorGroupCloseEvent, EditorOpenType } from '../types';
|
|
15
|
+
|
|
16
|
+
const HistoryPositionLineThreshold = 7;
|
|
17
|
+
const HardMaxStateLength = 200; // 超过200个过后,会缩减至100个, 防止反复缩减
|
|
18
|
+
const SoftMaxStateLength = 100;
|
|
19
|
+
|
|
20
|
+
@Injectable()
|
|
21
|
+
export class EditorHistoryService extends WithEventBus {
|
|
22
|
+
private static readonly MOUSE_NAVIGATION_SETTING = 'editor.mouseBackForwardToNavigate';
|
|
23
|
+
|
|
24
|
+
@Autowired(PreferenceService)
|
|
25
|
+
private preferenceService: PreferenceService;
|
|
26
|
+
|
|
27
|
+
@Autowired(WorkbenchEditorService)
|
|
28
|
+
private editorService: WorkbenchEditorService;
|
|
29
|
+
|
|
30
|
+
private currentIndex = -1;
|
|
31
|
+
|
|
32
|
+
private stack: EditorHistoryState[] = [];
|
|
33
|
+
|
|
34
|
+
private closedStack: URI[] = [];
|
|
35
|
+
|
|
36
|
+
init() {
|
|
37
|
+
this.registerMouseNavigationListener();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private registerMouseNavigationListener() {
|
|
41
|
+
const disposables = new DisposableCollection();
|
|
42
|
+
const handleMouseBackForwardSupport = () => {
|
|
43
|
+
disposables.dispose();
|
|
44
|
+
if (this.preferenceService.get(EditorHistoryService.MOUSE_NAVIGATION_SETTING)) {
|
|
45
|
+
disposables.push(addDisposableListener(window.document, EventType.MOUSE_DOWN, (e) => this.onMouseDown(e)));
|
|
46
|
+
}
|
|
47
|
+
this.disposables.push(disposables);
|
|
48
|
+
};
|
|
49
|
+
this.disposables.push(
|
|
50
|
+
this.preferenceService.onSpecificPreferenceChange(EditorHistoryService.MOUSE_NAVIGATION_SETTING, () => {
|
|
51
|
+
if (this.preferenceService.get(EditorHistoryService.MOUSE_NAVIGATION_SETTING)) {
|
|
52
|
+
handleMouseBackForwardSupport();
|
|
53
|
+
}
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
handleMouseBackForwardSupport();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private onMouseDown(event: MouseEvent) {
|
|
60
|
+
// Support to navigate in history when mouse buttons 4/5 are pressed
|
|
61
|
+
switch (event.button) {
|
|
62
|
+
case 3:
|
|
63
|
+
event.stopPropagation();
|
|
64
|
+
this.back();
|
|
65
|
+
break;
|
|
66
|
+
case 4:
|
|
67
|
+
event.stopPropagation();
|
|
68
|
+
this.forward();
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@OnEvent(EditorSelectionChangeEvent)
|
|
74
|
+
onEditorSelectionChangeEvent(e: EditorSelectionChangeEvent) {
|
|
75
|
+
if (e.payload.selections[0]) {
|
|
76
|
+
this.onNewState(
|
|
77
|
+
new EditorHistoryState(
|
|
78
|
+
e.payload.editorUri,
|
|
79
|
+
{
|
|
80
|
+
lineNumber: e.payload.selections[0]!.selectionStartLineNumber,
|
|
81
|
+
column: e.payload.selections[0]!.selectionStartColumn,
|
|
82
|
+
},
|
|
83
|
+
e.payload.group.index,
|
|
84
|
+
false,
|
|
85
|
+
),
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@OnEvent(EditorGroupChangeEvent)
|
|
91
|
+
onEditorGroupChangeEvent(e: EditorGroupChangeEvent) {
|
|
92
|
+
if (
|
|
93
|
+
e.payload.newOpenType &&
|
|
94
|
+
(e.payload.newOpenType.type === EditorOpenType.code || e.payload.newOpenType.type === EditorOpenType.diff)
|
|
95
|
+
) {
|
|
96
|
+
const selections = e.payload.group.currentEditor!.getSelections();
|
|
97
|
+
if (selections && selections.length > 0) {
|
|
98
|
+
this.onNewState(
|
|
99
|
+
new EditorHistoryState(
|
|
100
|
+
e.payload.newResource!.uri,
|
|
101
|
+
{
|
|
102
|
+
lineNumber: selections[0].selectionStartLineNumber,
|
|
103
|
+
column: selections[0]!.selectionStartColumn,
|
|
104
|
+
},
|
|
105
|
+
e.payload.group.index,
|
|
106
|
+
true,
|
|
107
|
+
),
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@OnEvent(EditorGroupCloseEvent)
|
|
114
|
+
onEditorGroupCloseEvent(e: EditorGroupCloseEvent) {
|
|
115
|
+
this.pushClosed(e.payload.resource.uri);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
onNewState(state: EditorHistoryState) {
|
|
119
|
+
if (this.currentIndex !== this.stack.length - 1) {
|
|
120
|
+
if (state.isTabChange && this.currentState.isRelevant(state)) {
|
|
121
|
+
//
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (this.currentState && this.currentState.isEqual(state)) {
|
|
125
|
+
// 这个状态可能来自 back/forward 被调用产生的行为
|
|
126
|
+
// 如果相同,不做任何行为
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const isRelevant = this.currentState && this.currentState.isRelevant(state);
|
|
131
|
+
this.doPushState(state, isRelevant);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
get currentState() {
|
|
135
|
+
return this.stack[this.currentIndex];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
doPushState(state: EditorHistoryState, isRelevant: boolean) {
|
|
139
|
+
// 如果和最新的状态关联, 则替换最新的状态
|
|
140
|
+
this.stack.splice(this.currentIndex + (isRelevant ? 0 : 1));
|
|
141
|
+
this.stack.push(state);
|
|
142
|
+
if (this.stack.length > HardMaxStateLength) {
|
|
143
|
+
this.stack.splice(0, this.stack.length - SoftMaxStateLength);
|
|
144
|
+
}
|
|
145
|
+
this.currentIndex = this.stack.length - 1;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
forward() {
|
|
149
|
+
if (this.currentIndex < this.stack.length - 1) {
|
|
150
|
+
this.currentIndex++;
|
|
151
|
+
this.restoreState(this.currentState);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
back() {
|
|
156
|
+
if (this.currentIndex > 0) {
|
|
157
|
+
this.currentIndex--;
|
|
158
|
+
this.restoreState(this.currentState);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
restoreState(state: EditorHistoryState) {
|
|
163
|
+
if (!state) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const editorGroup = this.editorService.editorGroups[state.groupIndex] || this.editorService.currentEditorGroup;
|
|
167
|
+
editorGroup.open(state.uri, {
|
|
168
|
+
range: {
|
|
169
|
+
startColumn: state.position.column,
|
|
170
|
+
startLineNumber: state.position.lineNumber,
|
|
171
|
+
endColumn: state.position.column,
|
|
172
|
+
endLineNumber: state.position.lineNumber,
|
|
173
|
+
},
|
|
174
|
+
focus: true,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
pushClosed(uri: URI) {
|
|
179
|
+
this.closedStack.push(uri);
|
|
180
|
+
if (this.closedStack.length > HardMaxStateLength) {
|
|
181
|
+
this.closedStack.splice(0, this.closedStack.length - SoftMaxStateLength);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
popClosed() {
|
|
186
|
+
const uri = this.closedStack.pop();
|
|
187
|
+
if (uri) {
|
|
188
|
+
this.editorService.open(uri, {
|
|
189
|
+
focus: true,
|
|
190
|
+
});
|
|
191
|
+
this.closedStack = this.closedStack.filter((u) => !uri.isEqual(u));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export class EditorHistoryState {
|
|
197
|
+
constructor(
|
|
198
|
+
public readonly uri: URI,
|
|
199
|
+
public readonly position: IPosition,
|
|
200
|
+
public groupIndex: number,
|
|
201
|
+
public isTabChange: boolean,
|
|
202
|
+
) {}
|
|
203
|
+
|
|
204
|
+
isRelevant(anotherState: EditorHistoryState): boolean {
|
|
205
|
+
if (this.uri.isEqual(anotherState.uri)) {
|
|
206
|
+
if (
|
|
207
|
+
anotherState.position.lineNumber < this.position.lineNumber + HistoryPositionLineThreshold &&
|
|
208
|
+
anotherState.position.lineNumber > this.position.lineNumber - HistoryPositionLineThreshold
|
|
209
|
+
) {
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
if (this.isTabChange || anotherState.isTabChange) {
|
|
213
|
+
// 如果是 tabChange 类型,我们认为是相关的,这样防止无意义的 0 line 0 column 状态出现
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
isEqual(anotherState: EditorHistoryState) {
|
|
222
|
+
return (
|
|
223
|
+
this.uri.isEqual(anotherState.uri) &&
|
|
224
|
+
this.position.lineNumber === anotherState.position.lineNumber &&
|
|
225
|
+
this.position.column === anotherState.position.column
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { Injectable, Provider, Autowired, Injector, INJECTOR_TOKEN } from '@opensumi/di';
|
|
2
|
+
import {
|
|
3
|
+
BrowserModule,
|
|
4
|
+
Domain,
|
|
5
|
+
ClientAppContribution,
|
|
6
|
+
ContributionProvider,
|
|
7
|
+
PreferenceService,
|
|
8
|
+
createPreferenceProxy,
|
|
9
|
+
} from '@opensumi/ide-core-browser';
|
|
10
|
+
import { ICallHierarchyService } from '@opensumi/ide-monaco/lib/browser/contrib/callHierarchy';
|
|
11
|
+
import {
|
|
12
|
+
ICommandServiceToken,
|
|
13
|
+
IMonacoActionRegistry,
|
|
14
|
+
IMonacoCommandsRegistry,
|
|
15
|
+
} from '@opensumi/ide-monaco/lib/browser/contrib/command';
|
|
16
|
+
import { ITextmateTokenizer } from '@opensumi/ide-monaco/lib/browser/contrib/tokenizer';
|
|
17
|
+
import { ITypeHierarchyService } from '@opensumi/ide-monaco/lib/browser/contrib/typeHierarchy';
|
|
18
|
+
|
|
19
|
+
import { EditorCollectionService, WorkbenchEditorService, ResourceService, ILanguageService } from '../common';
|
|
20
|
+
import { IDocPersistentCacheProvider } from '../common/doc-cache';
|
|
21
|
+
|
|
22
|
+
import { BreadCrumbServiceImpl } from './breadcrumb';
|
|
23
|
+
import { EditorComponentRegistryImpl } from './component';
|
|
24
|
+
import { DefaultDiffEditorContribution } from './diff';
|
|
25
|
+
import { CompareService, CompareEditorContribution } from './diff/compare';
|
|
26
|
+
import { EmptyDocCacheImpl } from './doc-cache';
|
|
27
|
+
import { EditorDocumentModelContentRegistryImpl, EditorDocumentModelServiceImpl } from './doc-model/main';
|
|
28
|
+
import { SaveParticipantsContribution } from './doc-model/saveParticipants';
|
|
29
|
+
import { IEditorDocumentModelContentRegistry, IEditorDocumentModelService } from './doc-model/types';
|
|
30
|
+
import { EditorCollectionServiceImpl } from './editor-collection.service';
|
|
31
|
+
import { EditorContribution, EditorAutoSaveEditorContribution } from './editor.contribution';
|
|
32
|
+
import { EditorDecorationCollectionService } from './editor.decoration.service';
|
|
33
|
+
import { EditorFeatureRegistryImpl } from './feature';
|
|
34
|
+
import { FileSystemResourceContribution } from './fs-resource';
|
|
35
|
+
import { LanguageStatusContribution } from './language/language-status.contribution';
|
|
36
|
+
import { LanguageStatusService } from './language/language-status.service';
|
|
37
|
+
import { LanguageService } from './language/language.service';
|
|
38
|
+
import { EditorActionRegistryImpl } from './menu/editor.menu';
|
|
39
|
+
import { OpenTypeMenuContribution } from './menu/open-type-menu.contribution';
|
|
40
|
+
import { MergeEditorContribution } from './merge-editor/merge-editor.contribution';
|
|
41
|
+
import {
|
|
42
|
+
CallHierarchyContribution,
|
|
43
|
+
CallHierarchyService,
|
|
44
|
+
TypeHierarchyService,
|
|
45
|
+
TypeHierarchyContribution,
|
|
46
|
+
} from './monaco-contrib';
|
|
47
|
+
import {
|
|
48
|
+
MonacoActionRegistry,
|
|
49
|
+
MonacoCommandRegistry,
|
|
50
|
+
MonacoCommandService,
|
|
51
|
+
} from './monaco-contrib/command/command.service';
|
|
52
|
+
import { TextmateService } from './monaco-contrib/tokenizer/textmate.service';
|
|
53
|
+
import { EditorPreferenceContribution } from './preference/contribution';
|
|
54
|
+
import { EditorPreferences, editorPreferenceSchema } from './preference/schema';
|
|
55
|
+
import { ResourceServiceImpl } from './resource.service';
|
|
56
|
+
import {
|
|
57
|
+
EditorComponentRegistry,
|
|
58
|
+
BrowserEditorContribution,
|
|
59
|
+
IEditorDecorationCollectionService,
|
|
60
|
+
IEditorActionRegistry,
|
|
61
|
+
ICompareService,
|
|
62
|
+
IBreadCrumbService,
|
|
63
|
+
IEditorFeatureRegistry,
|
|
64
|
+
ILanguageStatusService,
|
|
65
|
+
} from './types';
|
|
66
|
+
import { WorkbenchEditorServiceImpl } from './workbench-editor.service';
|
|
67
|
+
export * from './preference/schema';
|
|
68
|
+
export * from './types';
|
|
69
|
+
export * from './doc-model/types';
|
|
70
|
+
export * from './doc-cache';
|
|
71
|
+
export * from './editor.less';
|
|
72
|
+
export * from './view/editor.react';
|
|
73
|
+
|
|
74
|
+
@Injectable()
|
|
75
|
+
export class EditorModule extends BrowserModule {
|
|
76
|
+
providers: Provider[] = [
|
|
77
|
+
{
|
|
78
|
+
token: EditorCollectionService,
|
|
79
|
+
useClass: EditorCollectionServiceImpl,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
token: WorkbenchEditorService,
|
|
83
|
+
useClass: WorkbenchEditorServiceImpl,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
token: ResourceService,
|
|
87
|
+
useClass: ResourceServiceImpl,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
token: EditorComponentRegistry,
|
|
91
|
+
useClass: EditorComponentRegistryImpl,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
token: IEditorDecorationCollectionService,
|
|
95
|
+
useClass: EditorDecorationCollectionService,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
token: IEditorDocumentModelContentRegistry,
|
|
99
|
+
useClass: EditorDocumentModelContentRegistryImpl,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
token: IEditorDocumentModelService,
|
|
103
|
+
useClass: EditorDocumentModelServiceImpl,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
token: ILanguageService,
|
|
107
|
+
useClass: LanguageService,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
token: IEditorActionRegistry,
|
|
111
|
+
useClass: EditorActionRegistryImpl,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
token: IDocPersistentCacheProvider,
|
|
115
|
+
useClass: EmptyDocCacheImpl,
|
|
116
|
+
// useClass: LocalStorageDocCacheImpl,
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
token: ICompareService,
|
|
120
|
+
useClass: CompareService,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
token: IBreadCrumbService,
|
|
124
|
+
useClass: BreadCrumbServiceImpl,
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
token: IEditorFeatureRegistry,
|
|
128
|
+
useClass: EditorFeatureRegistryImpl,
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
token: EditorPreferences,
|
|
132
|
+
useFactory: (inject: Injector) => {
|
|
133
|
+
const preferences: PreferenceService = inject.get(PreferenceService);
|
|
134
|
+
return createPreferenceProxy(preferences, editorPreferenceSchema);
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
token: ICallHierarchyService,
|
|
139
|
+
useClass: CallHierarchyService,
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
token: ITypeHierarchyService,
|
|
143
|
+
useClass: TypeHierarchyService,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
token: ICommandServiceToken,
|
|
147
|
+
useClass: MonacoCommandService,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
token: IMonacoCommandsRegistry,
|
|
151
|
+
useClass: MonacoCommandRegistry,
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
token: IMonacoActionRegistry,
|
|
155
|
+
useClass: MonacoActionRegistry,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
token: ITextmateTokenizer,
|
|
159
|
+
useClass: TextmateService,
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
token: ILanguageStatusService,
|
|
163
|
+
useClass: LanguageStatusService,
|
|
164
|
+
},
|
|
165
|
+
EditorPreferenceContribution,
|
|
166
|
+
DefaultDiffEditorContribution,
|
|
167
|
+
MergeEditorContribution,
|
|
168
|
+
EditorClientAppContribution,
|
|
169
|
+
EditorContribution,
|
|
170
|
+
CompareEditorContribution,
|
|
171
|
+
EditorAutoSaveEditorContribution,
|
|
172
|
+
SaveParticipantsContribution,
|
|
173
|
+
FileSystemResourceContribution,
|
|
174
|
+
CallHierarchyContribution,
|
|
175
|
+
TypeHierarchyContribution,
|
|
176
|
+
LanguageStatusContribution,
|
|
177
|
+
OpenTypeMenuContribution,
|
|
178
|
+
];
|
|
179
|
+
contributionProvider = BrowserEditorContribution;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@Domain(ClientAppContribution)
|
|
183
|
+
export class EditorClientAppContribution implements ClientAppContribution {
|
|
184
|
+
@Autowired()
|
|
185
|
+
resourceService!: ResourceService;
|
|
186
|
+
|
|
187
|
+
@Autowired()
|
|
188
|
+
editorComponentRegistry!: EditorComponentRegistry;
|
|
189
|
+
|
|
190
|
+
@Autowired(WorkbenchEditorService)
|
|
191
|
+
workbenchEditorService!: WorkbenchEditorServiceImpl;
|
|
192
|
+
|
|
193
|
+
@Autowired(IEditorDocumentModelContentRegistry)
|
|
194
|
+
modelContentRegistry: IEditorDocumentModelContentRegistry;
|
|
195
|
+
|
|
196
|
+
@Autowired(IEditorActionRegistry)
|
|
197
|
+
editorActionRegistry: IEditorActionRegistry;
|
|
198
|
+
|
|
199
|
+
@Autowired(IEditorFeatureRegistry)
|
|
200
|
+
editorFeatureRegistry: IEditorFeatureRegistry;
|
|
201
|
+
|
|
202
|
+
@Autowired(INJECTOR_TOKEN)
|
|
203
|
+
injector: Injector;
|
|
204
|
+
|
|
205
|
+
@Autowired(IEditorDocumentModelService)
|
|
206
|
+
modelService: EditorDocumentModelServiceImpl;
|
|
207
|
+
|
|
208
|
+
@Autowired(BrowserEditorContribution)
|
|
209
|
+
private readonly contributions: ContributionProvider<BrowserEditorContribution>;
|
|
210
|
+
|
|
211
|
+
async initialize() {
|
|
212
|
+
for (const contribution of this.contributions.getContributions()) {
|
|
213
|
+
if (contribution.registerResource) {
|
|
214
|
+
contribution.registerResource(this.resourceService);
|
|
215
|
+
}
|
|
216
|
+
if (contribution.registerEditorComponent) {
|
|
217
|
+
contribution.registerEditorComponent(this.editorComponentRegistry);
|
|
218
|
+
}
|
|
219
|
+
if (contribution.registerEditorDocumentModelContentProvider) {
|
|
220
|
+
contribution.registerEditorDocumentModelContentProvider(this.modelContentRegistry);
|
|
221
|
+
}
|
|
222
|
+
if (contribution.registerEditorActions) {
|
|
223
|
+
contribution.registerEditorActions(this.editorActionRegistry);
|
|
224
|
+
}
|
|
225
|
+
if (contribution.registerEditorFeature) {
|
|
226
|
+
contribution.registerEditorFeature(this.editorFeatureRegistry);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
this.workbenchEditorService.contributionsReady.resolve();
|
|
230
|
+
await Promise.all([this.workbenchEditorService.initialize(), this.modelService.initialize()]);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
async onDidStart() {
|
|
234
|
+
this.workbenchEditorService.prepareContextKeyService();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';
|
|
2
|
+
|
|
3
|
+
import IMonacoModel = monaco.editor.IModel;
|
|
4
|
+
import IMonacoMarkerData = monaco.editor.IMarkerData;
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line import/order
|
|
7
|
+
import { DisposableCollection, Disposable, IDisposable } from '@opensumi/ide-core-common';
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line import/order
|
|
10
|
+
import { DiagnosticCollection, Diagnostic, asMonacoDiagnostics } from '../../common';
|
|
11
|
+
|
|
12
|
+
export class MonacoDiagnosticCollection implements DiagnosticCollection {
|
|
13
|
+
protected readonly diagnostics = new Map<string, MonacoModelDiagnostics | undefined>();
|
|
14
|
+
protected readonly toDispose = new DisposableCollection();
|
|
15
|
+
|
|
16
|
+
constructor(protected readonly name: string) {}
|
|
17
|
+
|
|
18
|
+
dispose() {
|
|
19
|
+
this.toDispose.dispose();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get(uri: string): Diagnostic[] {
|
|
23
|
+
const diagnostics = this.diagnostics.get(uri);
|
|
24
|
+
return diagnostics ? diagnostics.diagnostics : [];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
set(uri: string, diagnostics: Diagnostic[]): void {
|
|
28
|
+
const existing = this.diagnostics.get(uri);
|
|
29
|
+
if (existing) {
|
|
30
|
+
existing.diagnostics = diagnostics;
|
|
31
|
+
} else {
|
|
32
|
+
const modelDiagnostics = new MonacoModelDiagnostics(uri, diagnostics, this.name);
|
|
33
|
+
this.diagnostics.set(uri, modelDiagnostics);
|
|
34
|
+
this.toDispose.push(
|
|
35
|
+
Disposable.create(() => {
|
|
36
|
+
this.diagnostics.delete(uri);
|
|
37
|
+
modelDiagnostics.dispose();
|
|
38
|
+
}),
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class MonacoModelDiagnostics implements IDisposable {
|
|
45
|
+
readonly uri: monaco.Uri;
|
|
46
|
+
protected _markers: IMonacoMarkerData[] = [];
|
|
47
|
+
protected _diagnostics: Diagnostic[] = [];
|
|
48
|
+
constructor(uri: string, diagnostics: Diagnostic[], readonly owner: string) {
|
|
49
|
+
this.uri = monaco.Uri.parse(uri);
|
|
50
|
+
this.diagnostics = diagnostics;
|
|
51
|
+
monaco.editor.onDidCreateModel((model) => this.doUpdateModelMarkers(model));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
set diagnostics(diagnostics: Diagnostic[]) {
|
|
55
|
+
this._diagnostics = diagnostics;
|
|
56
|
+
this._markers = asMonacoDiagnostics(diagnostics) || [];
|
|
57
|
+
this.updateModelMarkers();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get diagnostics(): Diagnostic[] {
|
|
61
|
+
return this._diagnostics;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
get markers(): ReadonlyArray<IMonacoMarkerData> {
|
|
65
|
+
return this._markers;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
dispose(): void {
|
|
69
|
+
this._markers = [];
|
|
70
|
+
this.updateModelMarkers();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
updateModelMarkers(): void {
|
|
74
|
+
const model = monaco.editor.getModel(this.uri);
|
|
75
|
+
this.doUpdateModelMarkers(model);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
protected doUpdateModelMarkers(model: IMonacoModel | null): void {
|
|
79
|
+
if (model && this.uri.toString() === model.uri.toString()) {
|
|
80
|
+
monaco.editor.setModelMarkers(model, this.owner, this._markers);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Autowired } from '@opensumi/di';
|
|
2
|
+
import {
|
|
3
|
+
ClientAppContribution,
|
|
4
|
+
Domain,
|
|
5
|
+
IStatusBarService,
|
|
6
|
+
localize,
|
|
7
|
+
Severity,
|
|
8
|
+
StatusBarAlignment,
|
|
9
|
+
WithEventBus,
|
|
10
|
+
} from '@opensumi/ide-core-browser';
|
|
11
|
+
|
|
12
|
+
import { WorkbenchEditorService, IEditor, ILanguageStatusService, ILanguageStatus } from '../../common';
|
|
13
|
+
import { EditorDocumentModelOptionChangedEvent } from '../doc-model/types';
|
|
14
|
+
|
|
15
|
+
@Domain(ClientAppContribution)
|
|
16
|
+
export class LanguageStatusContribution extends WithEventBus implements ClientAppContribution {
|
|
17
|
+
@Autowired(IStatusBarService)
|
|
18
|
+
private readonly statusBar: IStatusBarService;
|
|
19
|
+
|
|
20
|
+
@Autowired()
|
|
21
|
+
private readonly workbenchEditorService: WorkbenchEditorService;
|
|
22
|
+
|
|
23
|
+
@Autowired(ILanguageStatusService)
|
|
24
|
+
private readonly languageStatusService: ILanguageStatusService;
|
|
25
|
+
|
|
26
|
+
initialize() {
|
|
27
|
+
this.workbenchEditorService.onActiveResourceChange(() => {
|
|
28
|
+
this.updateLanguageStatus(this.workbenchEditorService.currentEditor);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
this.eventBus.on(EditorDocumentModelOptionChangedEvent, (e) => {
|
|
32
|
+
const currentEditor = this.workbenchEditorService.currentEditor;
|
|
33
|
+
if (currentEditor && currentEditor.currentUri && currentEditor.currentUri.isEqual(e.payload.uri)) {
|
|
34
|
+
this.updateLanguageStatus(this.workbenchEditorService.currentEditor);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
protected updateLanguageStatus(editor: IEditor | null): void {
|
|
40
|
+
if (!editor) {
|
|
41
|
+
this.statusBar.removeElement('editor-status-language-status');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const documentModel = editor.currentDocumentModel;
|
|
46
|
+
|
|
47
|
+
if (documentModel) {
|
|
48
|
+
const all = this.languageStatusService.getLanguageStatus(documentModel.getMonacoModel());
|
|
49
|
+
if (all.length) {
|
|
50
|
+
this.statusBar.addElement('editor-status-language-status', {
|
|
51
|
+
name: localize('status-bar.editor-langStatus'),
|
|
52
|
+
alignment: StatusBarAlignment.RIGHT,
|
|
53
|
+
text: this.getLanguageStatusText(all),
|
|
54
|
+
// 默认在选择语言模式左边
|
|
55
|
+
priority: 1.1,
|
|
56
|
+
hoverContents: all.map((status) => ({
|
|
57
|
+
title: status.label,
|
|
58
|
+
name: status.name,
|
|
59
|
+
command: status.command,
|
|
60
|
+
})),
|
|
61
|
+
// 添加个空的执行函数以便点击状态栏有相应态
|
|
62
|
+
onClick: () => {},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
private getLanguageStatusText(status: ILanguageStatus[]) {
|
|
68
|
+
if (status.length === 0) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const [first] = status;
|
|
72
|
+
switch (first.severity) {
|
|
73
|
+
case Severity.Error:
|
|
74
|
+
return '$(bracket-error)';
|
|
75
|
+
case Severity.Warning:
|
|
76
|
+
return '$(bracket-dot)';
|
|
77
|
+
default:
|
|
78
|
+
return '$(bracket)';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Injectable } from '@opensumi/di';
|
|
2
|
+
import { strings, Event, IDisposable } from '@opensumi/ide-core-common';
|
|
3
|
+
import { LanguageFeatureRegistry } from '@opensumi/monaco-editor-core/esm/vs/editor/common/languageFeatureRegistry';
|
|
4
|
+
import { ITextModel } from '@opensumi/monaco-editor-core/esm/vs/editor/common/model';
|
|
5
|
+
|
|
6
|
+
import { ILanguageStatusService, ILanguageStatus } from '../../common';
|
|
7
|
+
|
|
8
|
+
const { compare } = strings;
|
|
9
|
+
|
|
10
|
+
@Injectable()
|
|
11
|
+
export class LanguageStatusService implements ILanguageStatusService {
|
|
12
|
+
private readonly _provider = new LanguageFeatureRegistry<ILanguageStatus>();
|
|
13
|
+
|
|
14
|
+
readonly onDidChange: Event<any> = this._provider.onDidChange;
|
|
15
|
+
|
|
16
|
+
addStatus(status: ILanguageStatus): IDisposable {
|
|
17
|
+
return this._provider.register(status.selector, status);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getLanguageStatus(model: ITextModel): ILanguageStatus[] {
|
|
21
|
+
return this._provider.ordered(model).sort((a, b) => {
|
|
22
|
+
let res = b.severity - a.severity;
|
|
23
|
+
if (res === 0) {
|
|
24
|
+
res = compare(a.source, b.source);
|
|
25
|
+
}
|
|
26
|
+
if (res === 0) {
|
|
27
|
+
res = compare(a.id, b.id);
|
|
28
|
+
}
|
|
29
|
+
return res;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|