@opensumi/ide-editor 3.9.1-next-1748403761.0 → 3.9.1-next-1748425167.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/decoration-applier.d.ts.map +1 -1
- package/lib/browser/decoration-applier.js.map +1 -1
- package/lib/browser/editor-collection.service.d.ts +57 -21
- package/lib/browser/editor-collection.service.d.ts.map +1 -1
- package/lib/browser/editor-collection.service.js +206 -42
- package/lib/browser/editor-collection.service.js.map +1 -1
- package/lib/browser/editor.contribution.d.ts.map +1 -1
- package/lib/browser/editor.contribution.js +0 -1
- package/lib/browser/editor.contribution.js.map +1 -1
- package/lib/browser/editor.less +0 -25
- package/lib/browser/multi-diff/multi-diff-editor.d.ts +7 -10
- package/lib/browser/multi-diff/multi-diff-editor.d.ts.map +1 -1
- package/lib/browser/multi-diff/multi-diff-editor.js +7 -60
- package/lib/browser/multi-diff/multi-diff-editor.js.map +1 -1
- package/lib/browser/multi-diff/multi-diff-resource.d.ts.map +1 -1
- package/lib/browser/multi-diff/multi-diff-resource.js.map +1 -1
- package/lib/browser/workbench-editor.service.js +1 -1
- package/lib/browser/workbench-editor.service.js.map +1 -1
- package/lib/common/multi-diff.d.ts +1 -6
- package/lib/common/multi-diff.d.ts.map +1 -1
- package/lib/common/multi-diff.js.map +1 -1
- package/package.json +14 -14
- package/src/browser/decoration-applier.ts +0 -1
- package/src/browser/editor-collection.service.ts +263 -48
- package/src/browser/editor.contribution.ts +0 -2
- package/src/browser/editor.less +0 -25
- package/src/browser/multi-diff/multi-diff-editor.ts +10 -91
- package/src/browser/multi-diff/multi-diff-resource.ts +1 -0
- package/src/browser/workbench-editor.service.ts +1 -1
- package/src/common/multi-diff.ts +1 -8
- package/lib/browser/base-editor-wrapper.d.ts +0 -58
- package/lib/browser/base-editor-wrapper.d.ts.map +0 -1
- package/lib/browser/base-editor-wrapper.js +0 -203
- package/lib/browser/base-editor-wrapper.js.map +0 -1
- package/src/browser/base-editor-wrapper.ts +0 -254
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { IRange } from '@opensumi/ide-core-browser';
|
|
2
|
-
import { Disposable, URI, WithEventBus } from '@opensumi/ide-core-common';
|
|
3
|
-
import * as monaco from '@opensumi/ide-monaco';
|
|
4
|
-
import { IConfigurationService } from '@opensumi/monaco-editor-core/esm/vs/platform/configuration/common/configuration';
|
|
5
|
-
import { EditorType, IDecorationApplyOptions, IEditor, IUndoStopOptions } from '../common';
|
|
6
|
-
import { IEditorDocumentModel } from '../common/editor';
|
|
7
|
-
import { MonacoEditorDecorationApplier } from './decoration-applier';
|
|
8
|
-
import { IEditorFeatureRegistry } from './types';
|
|
9
|
-
import type { ICodeEditor as IMonacoCodeEditor } from '@opensumi/ide-monaco/lib/browser/monaco-api/types';
|
|
10
|
-
export type ISumiEditor = IEditor;
|
|
11
|
-
export declare function insertSnippetWithMonacoEditor(editor: IMonacoCodeEditor, template: string, ranges: IRange[], opts: IUndoStopOptions): void;
|
|
12
|
-
export declare abstract class BaseMonacoEditorWrapper extends WithEventBus implements IEditor {
|
|
13
|
-
readonly monacoEditor: IMonacoCodeEditor;
|
|
14
|
-
private type;
|
|
15
|
-
abstract readonly currentDocumentModel: IEditorDocumentModel | null;
|
|
16
|
-
get currentUri(): URI | null;
|
|
17
|
-
getId(): string;
|
|
18
|
-
getSelections(): monaco.Selection[];
|
|
19
|
-
onFocus: monaco.Event<void>;
|
|
20
|
-
onBlur: monaco.Event<void>;
|
|
21
|
-
protected _specialEditorOptions: any;
|
|
22
|
-
protected _specialModelOptions: monaco.editor.ITextModelUpdateOptions;
|
|
23
|
-
protected _editorOptionsFromContribution: any;
|
|
24
|
-
protected readonly editorFeatureRegistry: IEditorFeatureRegistry;
|
|
25
|
-
protected readonly configurationService: IConfigurationService;
|
|
26
|
-
protected readonly decorationApplier: MonacoEditorDecorationApplier;
|
|
27
|
-
private _disableSelectionEmitter;
|
|
28
|
-
protected disableSelectionEmitter(): void;
|
|
29
|
-
protected enableSelectionEmitter(): void;
|
|
30
|
-
private injector;
|
|
31
|
-
constructor(monacoEditor: IMonacoCodeEditor, type: EditorType);
|
|
32
|
-
private onDidChangeModel;
|
|
33
|
-
getType(): EditorType;
|
|
34
|
-
updateOptions(editorOptions?: monaco.editor.IEditorOptions, modelOptions?: monaco.editor.ITextModelUpdateOptions): void;
|
|
35
|
-
private _doUpdateOptions;
|
|
36
|
-
/**
|
|
37
|
-
* 合并所有的选项
|
|
38
|
-
* 优先关系: (从高到底)
|
|
39
|
-
* 1. 当前编辑器的特殊选项(通过调用 updateOptions或者启动时传入)
|
|
40
|
-
* 2. 来自 featureRegistry 的根据 当前uri 提供的选项
|
|
41
|
-
* 3. 来自偏好设置的选项
|
|
42
|
-
*/
|
|
43
|
-
private _calculateFinalOptions;
|
|
44
|
-
insertSnippet(template: string, ranges: IRange[], opts: IUndoStopOptions): void;
|
|
45
|
-
applyDecoration(key: string, options: IDecorationApplyOptions[]): void;
|
|
46
|
-
onSelectionsChanged(listener: any): import("@opensumi/monaco-editor-core/esm/vs/base/common/lifecycle").IDisposable;
|
|
47
|
-
onVisibleRangesChanged(listener: any): Disposable;
|
|
48
|
-
setSelections(selections: any): void;
|
|
49
|
-
setSelection(selection: any): void;
|
|
50
|
-
save(): Promise<void>;
|
|
51
|
-
onConfigurationChanged(listener: any): import("@opensumi/monaco-editor-core/esm/vs/base/common/lifecycle").IDisposable;
|
|
52
|
-
}
|
|
53
|
-
export declare class DiffEditorPart extends BaseMonacoEditorWrapper implements IEditor {
|
|
54
|
-
private getDocumentModel;
|
|
55
|
-
get currentDocumentModel(): IEditorDocumentModel | null;
|
|
56
|
-
constructor(monacoEditor: IMonacoCodeEditor, getDocumentModel: () => IEditorDocumentModel | null, type: EditorType);
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=base-editor-wrapper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-editor-wrapper.d.ts","sourceRoot":"","s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|
-
exports.DiffEditorPart = exports.BaseMonacoEditorWrapper = void 0;
|
|
4
|
-
exports.insertSnippetWithMonacoEditor = insertSnippetWithMonacoEditor;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const di_1 = require("@opensumi/di");
|
|
7
|
-
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
8
|
-
const monaco = tslib_1.__importStar(require("@opensumi/ide-monaco"));
|
|
9
|
-
const configuration_1 = require("@opensumi/monaco-editor-core/esm/vs/platform/configuration/common/configuration");
|
|
10
|
-
const common_1 = require("../common");
|
|
11
|
-
const decoration_applier_1 = require("./decoration-applier");
|
|
12
|
-
const converter_1 = require("./preference/converter");
|
|
13
|
-
const types_1 = require("./types");
|
|
14
|
-
function insertSnippetWithMonacoEditor(editor, template, ranges, opts) {
|
|
15
|
-
const snippetController = editor.getContribution('snippetController2');
|
|
16
|
-
const selections = ranges.map((r) => new monaco.Selection(r.startLineNumber, r.startColumn, r.endLineNumber, r.endColumn));
|
|
17
|
-
editor.setSelections(selections);
|
|
18
|
-
editor.focus();
|
|
19
|
-
snippetController.insert(template, 0, 0, opts.undoStopBefore, opts.undoStopAfter);
|
|
20
|
-
}
|
|
21
|
-
const { removeUndefined } = ide_core_common_1.objects;
|
|
22
|
-
function updateOptionsWithMonacoEditor(monacoEditor, editorOptions, modelOptions) {
|
|
23
|
-
monacoEditor.updateOptions(editorOptions);
|
|
24
|
-
if (monacoEditor.getModel()) {
|
|
25
|
-
monacoEditor.getModel().updateOptions(modelOptions);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
let BaseMonacoEditorWrapper = class BaseMonacoEditorWrapper extends ide_core_common_1.WithEventBus {
|
|
29
|
-
get currentUri() {
|
|
30
|
-
return this.currentDocumentModel ? this.currentDocumentModel.uri : null;
|
|
31
|
-
}
|
|
32
|
-
getId() {
|
|
33
|
-
return this.monacoEditor.getId();
|
|
34
|
-
}
|
|
35
|
-
getSelections() {
|
|
36
|
-
return this.monacoEditor.getSelections() || [];
|
|
37
|
-
}
|
|
38
|
-
disableSelectionEmitter() {
|
|
39
|
-
this._disableSelectionEmitter = true;
|
|
40
|
-
}
|
|
41
|
-
enableSelectionEmitter() {
|
|
42
|
-
this._disableSelectionEmitter = false;
|
|
43
|
-
}
|
|
44
|
-
constructor(monacoEditor, type) {
|
|
45
|
-
super();
|
|
46
|
-
this.monacoEditor = monacoEditor;
|
|
47
|
-
this.type = type;
|
|
48
|
-
this.onFocus = this.monacoEditor.onDidFocusEditorWidget;
|
|
49
|
-
this.onBlur = this.monacoEditor.onDidBlurEditorWidget;
|
|
50
|
-
this._specialEditorOptions = {};
|
|
51
|
-
this._specialModelOptions = {};
|
|
52
|
-
this._editorOptionsFromContribution = {};
|
|
53
|
-
this._disableSelectionEmitter = false;
|
|
54
|
-
this.decorationApplier = this.injector.get(decoration_applier_1.MonacoEditorDecorationApplier, [this.monacoEditor]);
|
|
55
|
-
this.addDispose(this.monacoEditor.onDidChangeModel(this.onDidChangeModel.bind(this)));
|
|
56
|
-
this.addDispose(this.monacoEditor.onDidChangeModelLanguage(() => {
|
|
57
|
-
this._doUpdateOptions();
|
|
58
|
-
}));
|
|
59
|
-
this.addDispose(this.configurationService.onDidChangeConfiguration((e) => {
|
|
60
|
-
const changedEditorKeys = Array.from(e.affectedKeys.values()).filter((key) => (0, converter_1.isEditorOption)(key));
|
|
61
|
-
if (changedEditorKeys.length > 0) {
|
|
62
|
-
this._doUpdateOptions();
|
|
63
|
-
}
|
|
64
|
-
}));
|
|
65
|
-
}
|
|
66
|
-
async onDidChangeModel() {
|
|
67
|
-
this._editorOptionsFromContribution = {};
|
|
68
|
-
const uri = this.currentUri;
|
|
69
|
-
if (uri) {
|
|
70
|
-
Promise.resolve(this.editorFeatureRegistry.runProvideEditorOptionsForUri(uri)).then((options) => {
|
|
71
|
-
if (!this.currentUri || !uri.isEqual(this.currentUri)) {
|
|
72
|
-
return; // uri可能已经变了
|
|
73
|
-
}
|
|
74
|
-
if (options && Object.keys(options).length > 0) {
|
|
75
|
-
this._editorOptionsFromContribution = options;
|
|
76
|
-
if (!(0, ide_core_common_1.isEmptyObject)(this._editorOptionsFromContribution)) {
|
|
77
|
-
this._doUpdateOptions();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
getType() {
|
|
84
|
-
return this.type;
|
|
85
|
-
}
|
|
86
|
-
updateOptions(editorOptions = {}, modelOptions = {}) {
|
|
87
|
-
this._specialEditorOptions = removeUndefined({ ...this._specialEditorOptions, ...editorOptions });
|
|
88
|
-
this._specialModelOptions = removeUndefined({ ...this._specialModelOptions, ...modelOptions });
|
|
89
|
-
this._doUpdateOptions();
|
|
90
|
-
}
|
|
91
|
-
_doUpdateOptions() {
|
|
92
|
-
const { editorOptions, modelOptions } = this._calculateFinalOptions();
|
|
93
|
-
updateOptionsWithMonacoEditor(this.monacoEditor, editorOptions, modelOptions);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* 合并所有的选项
|
|
97
|
-
* 优先关系: (从高到底)
|
|
98
|
-
* 1. 当前编辑器的特殊选项(通过调用 updateOptions或者启动时传入)
|
|
99
|
-
* 2. 来自 featureRegistry 的根据 当前uri 提供的选项
|
|
100
|
-
* 3. 来自偏好设置的选项
|
|
101
|
-
*/
|
|
102
|
-
_calculateFinalOptions() {
|
|
103
|
-
var _a;
|
|
104
|
-
const uriStr = this.currentUri ? this.currentUri.toString() : undefined;
|
|
105
|
-
const languageId = this.currentDocumentModel ? this.currentDocumentModel.languageId : undefined;
|
|
106
|
-
const options = (0, converter_1.getConvertedMonacoOptions)(this.configurationService, uriStr, languageId, undefined);
|
|
107
|
-
const basicEditorOptions = {
|
|
108
|
-
readOnly: ((_a = this.currentDocumentModel) === null || _a === void 0 ? void 0 : _a.readonly) || false,
|
|
109
|
-
};
|
|
110
|
-
let editorOptions = {
|
|
111
|
-
...basicEditorOptions,
|
|
112
|
-
...options.editorOptions,
|
|
113
|
-
...this._editorOptionsFromContribution,
|
|
114
|
-
...this._specialEditorOptions,
|
|
115
|
-
};
|
|
116
|
-
if (this.type !== common_1.EditorType.CODE) {
|
|
117
|
-
editorOptions = {
|
|
118
|
-
...editorOptions,
|
|
119
|
-
...options.diffOptions,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
editorOptions,
|
|
124
|
-
modelOptions: { ...options.modelOptions, ...this._specialModelOptions },
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
insertSnippet(template, ranges, opts) {
|
|
128
|
-
insertSnippetWithMonacoEditor(this.monacoEditor, template, ranges, opts);
|
|
129
|
-
}
|
|
130
|
-
applyDecoration(key, options) {
|
|
131
|
-
this.decorationApplier.applyDecoration(key, options);
|
|
132
|
-
}
|
|
133
|
-
onSelectionsChanged(listener) {
|
|
134
|
-
return this.monacoEditor.onDidChangeCursorSelection((e) => {
|
|
135
|
-
if (!this._disableSelectionEmitter) {
|
|
136
|
-
listener({
|
|
137
|
-
selections: this.getSelections(),
|
|
138
|
-
source: e.source,
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
onVisibleRangesChanged(listener) {
|
|
144
|
-
const disposer = new ide_core_common_1.Disposable();
|
|
145
|
-
const monacoEditor = this.monacoEditor;
|
|
146
|
-
disposer.addDispose(monacoEditor.onDidScrollChange((e) => {
|
|
147
|
-
listener(this.monacoEditor.getVisibleRanges());
|
|
148
|
-
}));
|
|
149
|
-
disposer.addDispose(monacoEditor.onDidLayoutChange((e) => {
|
|
150
|
-
listener(this.monacoEditor.getVisibleRanges());
|
|
151
|
-
}));
|
|
152
|
-
return disposer;
|
|
153
|
-
}
|
|
154
|
-
setSelections(selections) {
|
|
155
|
-
return this.monacoEditor.setSelections(selections);
|
|
156
|
-
}
|
|
157
|
-
setSelection(selection) {
|
|
158
|
-
return this.monacoEditor.setSelection(selection);
|
|
159
|
-
}
|
|
160
|
-
async save() {
|
|
161
|
-
if (this.currentDocumentModel) {
|
|
162
|
-
await this.currentDocumentModel.save();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
onConfigurationChanged(listener) {
|
|
166
|
-
const monacoEditor = this.monacoEditor;
|
|
167
|
-
return monacoEditor.onDidChangeConfiguration((e) => {
|
|
168
|
-
listener();
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
exports.BaseMonacoEditorWrapper = BaseMonacoEditorWrapper;
|
|
173
|
-
tslib_1.__decorate([
|
|
174
|
-
(0, di_1.Autowired)(types_1.IEditorFeatureRegistry),
|
|
175
|
-
tslib_1.__metadata("design:type", Object)
|
|
176
|
-
], BaseMonacoEditorWrapper.prototype, "editorFeatureRegistry", void 0);
|
|
177
|
-
tslib_1.__decorate([
|
|
178
|
-
(0, di_1.Autowired)(configuration_1.IConfigurationService),
|
|
179
|
-
tslib_1.__metadata("design:type", Object)
|
|
180
|
-
], BaseMonacoEditorWrapper.prototype, "configurationService", void 0);
|
|
181
|
-
tslib_1.__decorate([
|
|
182
|
-
(0, di_1.Autowired)(di_1.INJECTOR_TOKEN),
|
|
183
|
-
tslib_1.__metadata("design:type", di_1.Injector)
|
|
184
|
-
], BaseMonacoEditorWrapper.prototype, "injector", void 0);
|
|
185
|
-
exports.BaseMonacoEditorWrapper = BaseMonacoEditorWrapper = tslib_1.__decorate([
|
|
186
|
-
(0, di_1.Injectable)({ multiple: true }),
|
|
187
|
-
tslib_1.__metadata("design:paramtypes", [Object, Object])
|
|
188
|
-
], BaseMonacoEditorWrapper);
|
|
189
|
-
let DiffEditorPart = class DiffEditorPart extends BaseMonacoEditorWrapper {
|
|
190
|
-
get currentDocumentModel() {
|
|
191
|
-
return this.getDocumentModel();
|
|
192
|
-
}
|
|
193
|
-
constructor(monacoEditor, getDocumentModel, type) {
|
|
194
|
-
super(monacoEditor, type);
|
|
195
|
-
this.getDocumentModel = getDocumentModel;
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
exports.DiffEditorPart = DiffEditorPart;
|
|
199
|
-
exports.DiffEditorPart = DiffEditorPart = tslib_1.__decorate([
|
|
200
|
-
(0, di_1.Injectable)({ multiple: true }),
|
|
201
|
-
tslib_1.__metadata("design:paramtypes", [Object, Function, Object])
|
|
202
|
-
], DiffEditorPart);
|
|
203
|
-
//# sourceMappingURL=base-editor-wrapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-editor-wrapper.js","sourceRoot":"","sources":["../../src/browser/base-editor-wrapper.ts"],"names":[],"mappings":";;;AAiBA,sEAcC;;AA/BD,qCAA+E;AAE/E,+DAA8G;AAC9G,qEAA+C;AAC/C,mHAAwH;AAExH,sCAA2F;AAG3F,6DAAqE;AACrE,sDAAmF;AACnF,mCAAiD;AAMjD,SAAgB,6BAA6B,CAC3C,MAAyB,EACzB,QAAgB,EAChB,MAAgB,EAChB,IAAsB;IAEtB,MAAM,iBAAiB,GAAG,MAAM,CAAC,eAAe,CAAC,oBAAoB,CAAQ,CAAC;IAC9E,MAAM,UAAU,GAAiB,MAAM,CAAC,GAAG,CACzC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,SAAS,CAAC,CAC5F,CAAC;IACF,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACjC,MAAM,CAAC,KAAK,EAAE,CAAC;IAEf,iBAAiB,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,EAAE,eAAe,EAAE,GAAG,yBAAO,CAAC;AAEpC,SAAS,6BAA6B,CACpC,YAA+B,EAC/B,aAA2C,EAC3C,YAAmD;IAEnD,YAAY,CAAC,aAAa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AEM,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,uBAAuB;IACzD,IAAI,oBAAoB;QACtB,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAC;IACjC,CAAC;IAED,YACE,YAA+B,EACvB,gBAAmD,EAC3D,IAAgB;QAEhB,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAHlB,qBAAgB,GAAhB,gBAAgB,CAAmC;IAI7D,CAAC;CACF,CAAA;AAZY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,eAAU,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;GAClB,cAAc,CAY1B"}
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { Autowired, INJECTOR_TOKEN, Injectable, Injector } from '@opensumi/di';
|
|
2
|
-
import { IRange } from '@opensumi/ide-core-browser';
|
|
3
|
-
import { Disposable, ISelection, URI, WithEventBus, isEmptyObject, objects } from '@opensumi/ide-core-common';
|
|
4
|
-
import * as monaco from '@opensumi/ide-monaco';
|
|
5
|
-
import { IConfigurationService } from '@opensumi/monaco-editor-core/esm/vs/platform/configuration/common/configuration';
|
|
6
|
-
|
|
7
|
-
import { EditorType, IDecorationApplyOptions, IEditor, IUndoStopOptions } from '../common';
|
|
8
|
-
import { IEditorDocumentModel } from '../common/editor';
|
|
9
|
-
|
|
10
|
-
import { MonacoEditorDecorationApplier } from './decoration-applier';
|
|
11
|
-
import { getConvertedMonacoOptions, isEditorOption } from './preference/converter';
|
|
12
|
-
import { IEditorFeatureRegistry } from './types';
|
|
13
|
-
|
|
14
|
-
import type { ICodeEditor as IMonacoCodeEditor } from '@opensumi/ide-monaco/lib/browser/monaco-api/types';
|
|
15
|
-
|
|
16
|
-
export type ISumiEditor = IEditor;
|
|
17
|
-
|
|
18
|
-
export function insertSnippetWithMonacoEditor(
|
|
19
|
-
editor: IMonacoCodeEditor,
|
|
20
|
-
template: string,
|
|
21
|
-
ranges: IRange[],
|
|
22
|
-
opts: IUndoStopOptions,
|
|
23
|
-
) {
|
|
24
|
-
const snippetController = editor.getContribution('snippetController2') as any;
|
|
25
|
-
const selections: ISelection[] = ranges.map(
|
|
26
|
-
(r) => new monaco.Selection(r.startLineNumber, r.startColumn, r.endLineNumber, r.endColumn),
|
|
27
|
-
);
|
|
28
|
-
editor.setSelections(selections);
|
|
29
|
-
editor.focus();
|
|
30
|
-
|
|
31
|
-
snippetController.insert(template, 0, 0, opts.undoStopBefore, opts.undoStopAfter);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const { removeUndefined } = objects;
|
|
35
|
-
|
|
36
|
-
function updateOptionsWithMonacoEditor(
|
|
37
|
-
monacoEditor: IMonacoCodeEditor,
|
|
38
|
-
editorOptions: monaco.editor.IEditorOptions,
|
|
39
|
-
modelOptions: monaco.editor.ITextModelUpdateOptions,
|
|
40
|
-
) {
|
|
41
|
-
monacoEditor.updateOptions(editorOptions);
|
|
42
|
-
if (monacoEditor.getModel()) {
|
|
43
|
-
monacoEditor.getModel()!.updateOptions(modelOptions);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@Injectable({ multiple: true })
|
|
48
|
-
export abstract class BaseMonacoEditorWrapper extends WithEventBus implements IEditor {
|
|
49
|
-
public abstract readonly currentDocumentModel: IEditorDocumentModel | null;
|
|
50
|
-
|
|
51
|
-
public get currentUri(): URI | null {
|
|
52
|
-
return this.currentDocumentModel ? this.currentDocumentModel.uri : null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
public getId() {
|
|
56
|
-
return this.monacoEditor.getId();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
getSelections() {
|
|
60
|
-
return this.monacoEditor.getSelections() || [];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public onFocus = this.monacoEditor.onDidFocusEditorWidget;
|
|
64
|
-
|
|
65
|
-
public onBlur = this.monacoEditor.onDidBlurEditorWidget;
|
|
66
|
-
|
|
67
|
-
protected _specialEditorOptions: any = {};
|
|
68
|
-
|
|
69
|
-
protected _specialModelOptions: monaco.editor.ITextModelUpdateOptions = {};
|
|
70
|
-
|
|
71
|
-
protected _editorOptionsFromContribution: any = {};
|
|
72
|
-
|
|
73
|
-
@Autowired(IEditorFeatureRegistry)
|
|
74
|
-
protected readonly editorFeatureRegistry: IEditorFeatureRegistry;
|
|
75
|
-
|
|
76
|
-
@Autowired(IConfigurationService)
|
|
77
|
-
protected readonly configurationService: IConfigurationService;
|
|
78
|
-
|
|
79
|
-
protected readonly decorationApplier: MonacoEditorDecorationApplier;
|
|
80
|
-
|
|
81
|
-
private _disableSelectionEmitter = false;
|
|
82
|
-
|
|
83
|
-
protected disableSelectionEmitter() {
|
|
84
|
-
this._disableSelectionEmitter = true;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
protected enableSelectionEmitter() {
|
|
88
|
-
this._disableSelectionEmitter = false;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
@Autowired(INJECTOR_TOKEN)
|
|
92
|
-
private injector: Injector;
|
|
93
|
-
|
|
94
|
-
constructor(public readonly monacoEditor: IMonacoCodeEditor, private type: EditorType) {
|
|
95
|
-
super();
|
|
96
|
-
this.decorationApplier = this.injector.get(MonacoEditorDecorationApplier, [this.monacoEditor]);
|
|
97
|
-
this.addDispose(this.monacoEditor.onDidChangeModel(this.onDidChangeModel.bind(this)));
|
|
98
|
-
this.addDispose(
|
|
99
|
-
this.monacoEditor.onDidChangeModelLanguage(() => {
|
|
100
|
-
this._doUpdateOptions();
|
|
101
|
-
}),
|
|
102
|
-
);
|
|
103
|
-
this.addDispose(
|
|
104
|
-
this.configurationService.onDidChangeConfiguration((e) => {
|
|
105
|
-
const changedEditorKeys = Array.from(e.affectedKeys.values()).filter((key) => isEditorOption(key));
|
|
106
|
-
if (changedEditorKeys.length > 0) {
|
|
107
|
-
this._doUpdateOptions();
|
|
108
|
-
}
|
|
109
|
-
}),
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
private async onDidChangeModel() {
|
|
114
|
-
this._editorOptionsFromContribution = {};
|
|
115
|
-
const uri = this.currentUri;
|
|
116
|
-
if (uri) {
|
|
117
|
-
Promise.resolve(this.editorFeatureRegistry.runProvideEditorOptionsForUri(uri)).then((options) => {
|
|
118
|
-
if (!this.currentUri || !uri.isEqual(this.currentUri)) {
|
|
119
|
-
return; // uri可能已经变了
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (options && Object.keys(options).length > 0) {
|
|
123
|
-
this._editorOptionsFromContribution = options;
|
|
124
|
-
if (!isEmptyObject(this._editorOptionsFromContribution)) {
|
|
125
|
-
this._doUpdateOptions();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
public getType() {
|
|
133
|
-
return this.type;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
updateOptions(
|
|
137
|
-
editorOptions: monaco.editor.IEditorOptions = {},
|
|
138
|
-
modelOptions: monaco.editor.ITextModelUpdateOptions = {},
|
|
139
|
-
) {
|
|
140
|
-
this._specialEditorOptions = removeUndefined({ ...this._specialEditorOptions, ...editorOptions });
|
|
141
|
-
this._specialModelOptions = removeUndefined({ ...this._specialModelOptions, ...modelOptions });
|
|
142
|
-
this._doUpdateOptions();
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
private _doUpdateOptions() {
|
|
146
|
-
const { editorOptions, modelOptions } = this._calculateFinalOptions();
|
|
147
|
-
updateOptionsWithMonacoEditor(this.monacoEditor, editorOptions, modelOptions);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* 合并所有的选项
|
|
152
|
-
* 优先关系: (从高到底)
|
|
153
|
-
* 1. 当前编辑器的特殊选项(通过调用 updateOptions或者启动时传入)
|
|
154
|
-
* 2. 来自 featureRegistry 的根据 当前uri 提供的选项
|
|
155
|
-
* 3. 来自偏好设置的选项
|
|
156
|
-
*/
|
|
157
|
-
private _calculateFinalOptions() {
|
|
158
|
-
const uriStr = this.currentUri ? this.currentUri.toString() : undefined;
|
|
159
|
-
const languageId = this.currentDocumentModel ? this.currentDocumentModel.languageId : undefined;
|
|
160
|
-
const options = getConvertedMonacoOptions(this.configurationService, uriStr, languageId, undefined);
|
|
161
|
-
const basicEditorOptions: Partial<monaco.editor.IEditorOptions> = {
|
|
162
|
-
readOnly: this.currentDocumentModel?.readonly || false,
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
let editorOptions = {
|
|
166
|
-
...basicEditorOptions,
|
|
167
|
-
...options.editorOptions,
|
|
168
|
-
...this._editorOptionsFromContribution,
|
|
169
|
-
...this._specialEditorOptions,
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
if (this.type !== EditorType.CODE) {
|
|
173
|
-
editorOptions = {
|
|
174
|
-
...editorOptions,
|
|
175
|
-
...options.diffOptions,
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return {
|
|
180
|
-
editorOptions,
|
|
181
|
-
modelOptions: { ...options.modelOptions, ...this._specialModelOptions },
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
insertSnippet(template: string, ranges: IRange[], opts: IUndoStopOptions) {
|
|
186
|
-
insertSnippetWithMonacoEditor(this.monacoEditor, template, ranges, opts);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
applyDecoration(key: string, options: IDecorationApplyOptions[]) {
|
|
190
|
-
this.decorationApplier.applyDecoration(key, options);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
onSelectionsChanged(listener) {
|
|
194
|
-
return this.monacoEditor.onDidChangeCursorSelection((e) => {
|
|
195
|
-
if (!this._disableSelectionEmitter) {
|
|
196
|
-
listener({
|
|
197
|
-
selections: this.getSelections(),
|
|
198
|
-
source: e.source,
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
onVisibleRangesChanged(listener) {
|
|
205
|
-
const disposer = new Disposable();
|
|
206
|
-
const monacoEditor = this.monacoEditor;
|
|
207
|
-
disposer.addDispose(
|
|
208
|
-
monacoEditor.onDidScrollChange((e) => {
|
|
209
|
-
listener(this.monacoEditor.getVisibleRanges());
|
|
210
|
-
}),
|
|
211
|
-
);
|
|
212
|
-
disposer.addDispose(
|
|
213
|
-
monacoEditor.onDidLayoutChange((e) => {
|
|
214
|
-
listener(this.monacoEditor.getVisibleRanges());
|
|
215
|
-
}),
|
|
216
|
-
);
|
|
217
|
-
return disposer;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
setSelections(selections) {
|
|
221
|
-
return this.monacoEditor.setSelections(selections as any);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
setSelection(selection) {
|
|
225
|
-
return this.monacoEditor.setSelection(selection as any);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
public async save(): Promise<void> {
|
|
229
|
-
if (this.currentDocumentModel) {
|
|
230
|
-
await this.currentDocumentModel.save();
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
onConfigurationChanged(listener) {
|
|
235
|
-
const monacoEditor = this.monacoEditor;
|
|
236
|
-
return monacoEditor.onDidChangeConfiguration((e) => {
|
|
237
|
-
listener();
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
@Injectable({ multiple: true })
|
|
242
|
-
export class DiffEditorPart extends BaseMonacoEditorWrapper implements IEditor {
|
|
243
|
-
get currentDocumentModel() {
|
|
244
|
-
return this.getDocumentModel();
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
constructor(
|
|
248
|
-
monacoEditor: IMonacoCodeEditor,
|
|
249
|
-
private getDocumentModel: () => IEditorDocumentModel | null,
|
|
250
|
-
type: EditorType,
|
|
251
|
-
) {
|
|
252
|
-
super(monacoEditor, type);
|
|
253
|
-
}
|
|
254
|
-
}
|