@theia/monaco 1.45.0 → 1.46.0-next.72
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/README.md +100 -100
- package/data/monaco-nls.json +1379 -1379
- package/data/monaco-themes/vscode/dark_plus.json +201 -201
- package/data/monaco-themes/vscode/dark_theia.json +5 -5
- package/data/monaco-themes/vscode/dark_vs.json +393 -393
- package/data/monaco-themes/vscode/hc_black.json +457 -457
- package/data/monaco-themes/vscode/hc_light.json +590 -590
- package/data/monaco-themes/vscode/hc_theia.json +5 -5
- package/data/monaco-themes/vscode/hc_theia_light.json +5 -5
- package/data/monaco-themes/vscode/light_plus.json +202 -202
- package/data/monaco-themes/vscode/light_theia.json +10 -10
- package/data/monaco-themes/vscode/light_vs.json +421 -421
- package/lib/browser/index.d.ts +1 -1
- package/lib/browser/index.js +28 -28
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.d.ts +20 -24
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.d.ts.map +1 -1
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.js +122 -137
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.js.map +1 -1
- package/lib/browser/monaco-bulk-edit-service.d.ts +12 -14
- package/lib/browser/monaco-bulk-edit-service.d.ts.map +1 -1
- package/lib/browser/monaco-bulk-edit-service.js +66 -66
- package/lib/browser/monaco-bulk-edit-service.js.map +1 -1
- package/lib/browser/monaco-color-registry.d.ts +16 -16
- package/lib/browser/monaco-color-registry.js +82 -82
- package/lib/browser/monaco-command-registry.d.ts +19 -19
- package/lib/browser/monaco-command-registry.d.ts.map +1 -1
- package/lib/browser/monaco-command-registry.js +88 -85
- package/lib/browser/monaco-command-registry.js.map +1 -1
- package/lib/browser/monaco-command-service.d.ts +21 -26
- package/lib/browser/monaco-command-service.d.ts.map +1 -1
- package/lib/browser/monaco-command-service.js +93 -92
- package/lib/browser/monaco-command-service.js.map +1 -1
- package/lib/browser/monaco-command.d.ts +88 -94
- package/lib/browser/monaco-command.d.ts.map +1 -1
- package/lib/browser/monaco-command.js +294 -307
- package/lib/browser/monaco-command.js.map +1 -1
- package/lib/browser/monaco-context-key-service.d.ts +22 -22
- package/lib/browser/monaco-context-key-service.d.ts.map +1 -1
- package/lib/browser/monaco-context-key-service.js +146 -147
- package/lib/browser/monaco-context-key-service.js.map +1 -1
- package/lib/browser/monaco-context-menu.d.ts +17 -16
- package/lib/browser/monaco-context-menu.d.ts.map +1 -1
- package/lib/browser/monaco-context-menu.js +112 -102
- package/lib/browser/monaco-context-menu.js.map +1 -1
- package/lib/browser/monaco-diff-editor.d.ts +29 -29
- package/lib/browser/monaco-diff-editor.d.ts.map +1 -1
- package/lib/browser/monaco-diff-editor.js +74 -74
- package/lib/browser/monaco-diff-editor.js.map +1 -1
- package/lib/browser/monaco-diff-navigator-factory.d.ts +6 -7
- package/lib/browser/monaco-diff-navigator-factory.d.ts.map +1 -1
- package/lib/browser/monaco-diff-navigator-factory.js +45 -66
- package/lib/browser/monaco-diff-navigator-factory.js.map +1 -1
- package/lib/browser/monaco-editor-model.d.ts +158 -156
- package/lib/browser/monaco-editor-model.d.ts.map +1 -1
- package/lib/browser/monaco-editor-model.js +562 -559
- package/lib/browser/monaco-editor-model.js.map +1 -1
- package/lib/browser/monaco-editor-provider.d.ts +70 -89
- package/lib/browser/monaco-editor-provider.d.ts.map +1 -1
- package/lib/browser/monaco-editor-provider.js +386 -440
- package/lib/browser/monaco-editor-provider.js.map +1 -1
- package/lib/browser/monaco-editor-service.d.ts +32 -27
- package/lib/browser/monaco-editor-service.d.ts.map +1 -1
- package/lib/browser/monaco-editor-service.js +158 -155
- package/lib/browser/monaco-editor-service.js.map +1 -1
- package/lib/browser/monaco-editor-zone-widget.d.ts +43 -43
- package/lib/browser/monaco-editor-zone-widget.js +194 -194
- package/lib/browser/monaco-editor.d.ts +154 -151
- package/lib/browser/monaco-editor.d.ts.map +1 -1
- package/lib/browser/monaco-editor.js +542 -524
- package/lib/browser/monaco-editor.js.map +1 -1
- package/lib/browser/monaco-formatting-conflicts.d.ts +13 -13
- package/lib/browser/monaco-formatting-conflicts.js +111 -111
- package/lib/browser/monaco-formatting-conflicts.js.map +1 -1
- package/lib/browser/monaco-frontend-application-contribution.d.ts +22 -28
- package/lib/browser/monaco-frontend-application-contribution.d.ts.map +1 -1
- package/lib/browser/monaco-frontend-application-contribution.js +178 -215
- package/lib/browser/monaco-frontend-application-contribution.js.map +1 -1
- package/lib/browser/monaco-frontend-module.d.ts +7 -7
- package/lib/browser/monaco-frontend-module.d.ts.map +1 -1
- package/lib/browser/monaco-frontend-module.js +280 -271
- package/lib/browser/monaco-frontend-module.js.map +1 -1
- package/lib/browser/monaco-gotoline-quick-access.d.ts +11 -11
- package/lib/browser/monaco-gotoline-quick-access.js +64 -64
- package/lib/browser/monaco-gotosymbol-quick-access.d.ts +16 -16
- package/lib/browser/monaco-gotosymbol-quick-access.js +70 -70
- package/lib/browser/monaco-icon-registry.d.ts +10 -11
- package/lib/browser/monaco-icon-registry.d.ts.map +1 -1
- package/lib/browser/monaco-icon-registry.js +52 -50
- package/lib/browser/monaco-icon-registry.js.map +1 -1
- package/lib/browser/monaco-indexed-db.d.ts +28 -28
- package/lib/browser/monaco-indexed-db.js +131 -131
- package/lib/browser/monaco-init.d.ts +5 -0
- package/lib/browser/monaco-init.d.ts.map +1 -0
- package/lib/browser/monaco-init.js +125 -0
- package/lib/browser/monaco-init.js.map +1 -0
- package/lib/browser/monaco-keybinding.d.ts +16 -16
- package/lib/browser/monaco-keybinding.js +134 -134
- package/lib/browser/monaco-keybinding.js.map +1 -1
- package/lib/browser/monaco-keycode-map.d.ts +2 -2
- package/lib/browser/monaco-keycode-map.js +163 -163
- package/lib/browser/monaco-keycode-map.js.map +1 -1
- package/lib/browser/monaco-languages.d.ts +35 -35
- package/lib/browser/monaco-languages.js +180 -180
- package/lib/browser/monaco-marker-collection.d.ts +18 -18
- package/lib/browser/monaco-marker-collection.js +70 -70
- package/lib/browser/monaco-menu.d.ts +20 -20
- package/lib/browser/monaco-menu.js +145 -145
- package/lib/browser/monaco-mime-service.d.ts +10 -10
- package/lib/browser/monaco-mime-service.js +78 -78
- package/lib/browser/monaco-outline-contribution.d.ts +78 -78
- package/lib/browser/monaco-outline-contribution.js +384 -384
- package/lib/browser/monaco-outline-decorator.d.ts +12 -12
- package/lib/browser/monaco-outline-decorator.js +67 -67
- package/lib/browser/monaco-quick-access-registry.d.ts +11 -11
- package/lib/browser/monaco-quick-access-registry.js +99 -99
- package/lib/browser/monaco-quick-input-service.d.ts +99 -101
- package/lib/browser/monaco-quick-input-service.d.ts.map +1 -1
- package/lib/browser/monaco-quick-input-service.js +529 -568
- package/lib/browser/monaco-quick-input-service.js.map +1 -1
- package/lib/browser/monaco-resolved-keybinding.d.ts +23 -23
- package/lib/browser/monaco-resolved-keybinding.d.ts.map +1 -1
- package/lib/browser/monaco-resolved-keybinding.js +131 -131
- package/lib/browser/monaco-resolved-keybinding.js.map +1 -1
- package/lib/browser/monaco-snippet-suggest-provider.d.ts +66 -66
- package/lib/browser/monaco-snippet-suggest-provider.js +273 -273
- package/lib/browser/monaco-status-bar-contribution.d.ts +17 -17
- package/lib/browser/monaco-status-bar-contribution.js +121 -121
- package/lib/browser/monaco-text-model-service.d.ts +51 -51
- package/lib/browser/monaco-text-model-service.js +189 -189
- package/lib/browser/monaco-text-model-service.js.map +1 -1
- package/lib/browser/monaco-theming-service.d.ts +67 -67
- package/lib/browser/monaco-theming-service.js +171 -171
- package/lib/browser/monaco-to-protocol-converter.d.ts +26 -26
- package/lib/browser/monaco-to-protocol-converter.js +61 -61
- package/lib/browser/monaco-workspace.d.ts +83 -85
- package/lib/browser/monaco-workspace.d.ts.map +1 -1
- package/lib/browser/monaco-workspace.js +384 -384
- package/lib/browser/monaco-workspace.js.map +1 -1
- package/lib/browser/protocol-to-monaco-converter.d.ts +31 -31
- package/lib/browser/protocol-to-monaco-converter.js +133 -133
- package/lib/browser/simple-monaco-editor.d.ts +45 -44
- package/lib/browser/simple-monaco-editor.d.ts.map +1 -1
- package/lib/browser/simple-monaco-editor.js +184 -176
- package/lib/browser/simple-monaco-editor.js.map +1 -1
- package/lib/browser/textmate/index.d.ts +4 -4
- package/lib/browser/textmate/index.js +31 -31
- package/lib/browser/textmate/monaco-textmate-frontend-bindings.d.ts +11 -11
- package/lib/browser/textmate/monaco-textmate-frontend-bindings.js +91 -91
- package/lib/browser/textmate/monaco-textmate-service.d.ts +30 -30
- package/lib/browser/textmate/monaco-textmate-service.js +185 -185
- package/lib/browser/textmate/monaco-textmate-service.js.map +1 -1
- package/lib/browser/textmate/monaco-theme-registry.d.ts +27 -27
- package/lib/browser/textmate/monaco-theme-registry.js +173 -173
- package/lib/browser/textmate/monaco-theme-types.d.ts +20 -20
- package/lib/browser/textmate/monaco-theme-types.js +21 -21
- package/lib/browser/textmate/textmate-contribution.d.ts +9 -9
- package/lib/browser/textmate/textmate-contribution.js +27 -27
- package/lib/browser/textmate/textmate-registry.d.ts +31 -31
- package/lib/browser/textmate/textmate-registry.js +109 -109
- package/lib/browser/textmate/textmate-snippet-completion-provider.d.ts +26 -26
- package/lib/browser/textmate/textmate-snippet-completion-provider.js +53 -53
- package/lib/browser/textmate/textmate-tokenizer.d.ts +22 -22
- package/lib/browser/textmate/textmate-tokenizer.js +65 -65
- package/lib/browser/workspace-symbol-command.d.ts +55 -55
- package/lib/browser/workspace-symbol-command.js +215 -215
- package/lib/package.spec.js +25 -25
- package/package.json +10 -10
- package/src/browser/index.ts +17 -17
- package/src/browser/markdown-renderer/monaco-markdown-renderer.ts +109 -117
- package/src/browser/monaco-bulk-edit-service.ts +64 -64
- package/src/browser/monaco-color-registry.ts +73 -73
- package/src/browser/monaco-command-registry.ts +85 -82
- package/src/browser/monaco-command-service.ts +90 -99
- package/src/browser/monaco-command.ts +303 -313
- package/src/browser/monaco-context-key-service.ts +144 -143
- package/src/browser/monaco-context-menu.ts +100 -90
- package/src/browser/monaco-diff-editor.ts +100 -101
- package/src/browser/monaco-diff-navigator-factory.ts +39 -61
- package/src/browser/monaco-editor-model.ts +684 -681
- package/src/browser/monaco-editor-provider.ts +409 -452
- package/src/browser/monaco-editor-service.ts +149 -144
- package/src/browser/monaco-editor-zone-widget.ts +250 -250
- package/src/browser/monaco-editor.ts +663 -644
- package/src/browser/monaco-formatting-conflicts.ts +116 -116
- package/src/browser/monaco-frontend-application-contribution.ts +165 -200
- package/src/browser/monaco-frontend-module.ts +328 -320
- package/src/browser/monaco-gotoline-quick-access.ts +47 -47
- package/src/browser/monaco-gotosymbol-quick-access.ts +53 -53
- package/src/browser/monaco-icon-registry.ts +49 -47
- package/src/browser/monaco-indexed-db.ts +130 -130
- package/src/browser/monaco-init.ts +114 -0
- package/src/browser/monaco-keybinding.ts +111 -111
- package/src/browser/monaco-keycode-map.ts +171 -171
- package/src/browser/monaco-languages.ts +177 -177
- package/src/browser/monaco-marker-collection.ts +83 -83
- package/src/browser/monaco-menu.ts +142 -142
- package/src/browser/monaco-mime-service.ts +71 -71
- package/src/browser/monaco-outline-contribution.ts +404 -404
- package/src/browser/monaco-outline-decorator.ts +66 -66
- package/src/browser/monaco-quick-access-registry.ts +112 -112
- package/src/browser/monaco-quick-input-service.ts +647 -676
- package/src/browser/monaco-resolved-keybinding.ts +162 -162
- package/src/browser/monaco-snippet-suggest-provider.ts +306 -306
- package/src/browser/monaco-status-bar-contribution.ts +110 -110
- package/src/browser/monaco-text-model-service.ts +199 -199
- package/src/browser/monaco-theming-service.ts +204 -204
- package/src/browser/monaco-to-protocol-converter.ts +71 -71
- package/src/browser/monaco-workspace.ts +412 -412
- package/src/browser/protocol-to-monaco-converter.ts +158 -158
- package/src/browser/simple-monaco-editor.ts +217 -210
- package/src/browser/style/index.css +263 -263
- package/src/browser/textmate/index.ts +20 -20
- package/src/browser/textmate/monaco-textmate-frontend-bindings.ts +90 -90
- package/src/browser/textmate/monaco-textmate-service.ts +187 -187
- package/src/browser/textmate/monaco-theme-registry.ts +176 -176
- package/src/browser/textmate/monaco-theme-types.ts +37 -37
- package/src/browser/textmate/textmate-contribution.ts +29 -29
- package/src/browser/textmate/textmate-registry.ts +129 -129
- package/src/browser/textmate/textmate-snippet-completion-provider.ts +73 -73
- package/src/browser/textmate/textmate-tokenizer.ts +84 -84
- package/src/browser/workspace-symbol-command.ts +196 -196
- package/src/package.spec.ts +28 -28
|
@@ -1,644 +1,663 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, inject, unmanaged } from '@theia/core/shared/inversify';
|
|
18
|
-
import { ElementExt } from '@theia/core/shared/@phosphor/domutils';
|
|
19
|
-
import URI from '@theia/core/lib/common/uri';
|
|
20
|
-
import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
|
|
21
|
-
import { DisposableCollection, Disposable, Emitter, Event, nullToUndefined, MaybeNull } from '@theia/core/lib/common';
|
|
22
|
-
import {
|
|
23
|
-
Dimension,
|
|
24
|
-
EditorManager,
|
|
25
|
-
EditorWidget,
|
|
26
|
-
Position,
|
|
27
|
-
Range,
|
|
28
|
-
TextDocumentContentChangeDelta,
|
|
29
|
-
TextDocumentChangeEvent,
|
|
30
|
-
TextEditor,
|
|
31
|
-
RevealRangeOptions,
|
|
32
|
-
RevealPositionOptions,
|
|
33
|
-
DeltaDecorationParams,
|
|
34
|
-
ReplaceTextParams,
|
|
35
|
-
EditorDecoration,
|
|
36
|
-
EditorMouseEvent,
|
|
37
|
-
EncodingMode,
|
|
38
|
-
EditorDecorationOptions
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import
|
|
46
|
-
import
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import { IStandaloneEditorConstructionOptions, StandaloneEditor } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneCodeEditor';
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
export
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
protected readonly
|
|
79
|
-
|
|
80
|
-
protected readonly
|
|
81
|
-
protected
|
|
82
|
-
|
|
83
|
-
protected
|
|
84
|
-
|
|
85
|
-
protected readonly
|
|
86
|
-
protected readonly
|
|
87
|
-
protected readonly
|
|
88
|
-
protected readonly
|
|
89
|
-
readonly
|
|
90
|
-
|
|
91
|
-
readonly
|
|
92
|
-
|
|
93
|
-
readonly
|
|
94
|
-
|
|
95
|
-
readonly
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
this.
|
|
111
|
-
this.
|
|
112
|
-
this.
|
|
113
|
-
this.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.
|
|
119
|
-
this.
|
|
120
|
-
this.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
this.
|
|
171
|
-
|
|
172
|
-
this.toDispose.push(codeEditor.
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
this.
|
|
177
|
-
));
|
|
178
|
-
this.toDispose.push(codeEditor.
|
|
179
|
-
this.
|
|
180
|
-
));
|
|
181
|
-
this.toDispose.push(codeEditor.
|
|
182
|
-
this.
|
|
183
|
-
));
|
|
184
|
-
this.toDispose.push(codeEditor.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return this.
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
return this.
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
this.
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
get
|
|
251
|
-
return this.
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
case '
|
|
277
|
-
this.editor.
|
|
278
|
-
break;
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
case '
|
|
286
|
-
this.editor.
|
|
287
|
-
break;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
textarea.
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
this.
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
return {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
const
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
this._languageAutoDetected
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, inject, unmanaged } from '@theia/core/shared/inversify';
|
|
18
|
+
import { ElementExt } from '@theia/core/shared/@phosphor/domutils';
|
|
19
|
+
import URI from '@theia/core/lib/common/uri';
|
|
20
|
+
import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
|
|
21
|
+
import { DisposableCollection, Disposable, Emitter, Event, nullToUndefined, MaybeNull } from '@theia/core/lib/common';
|
|
22
|
+
import {
|
|
23
|
+
Dimension,
|
|
24
|
+
EditorManager,
|
|
25
|
+
EditorWidget,
|
|
26
|
+
Position,
|
|
27
|
+
Range,
|
|
28
|
+
TextDocumentContentChangeDelta,
|
|
29
|
+
TextDocumentChangeEvent,
|
|
30
|
+
TextEditor,
|
|
31
|
+
RevealRangeOptions,
|
|
32
|
+
RevealPositionOptions,
|
|
33
|
+
DeltaDecorationParams,
|
|
34
|
+
ReplaceTextParams,
|
|
35
|
+
EditorDecoration,
|
|
36
|
+
EditorMouseEvent,
|
|
37
|
+
EncodingMode,
|
|
38
|
+
EditorDecorationOptions,
|
|
39
|
+
MouseTargetType
|
|
40
|
+
} from '@theia/editor/lib/browser';
|
|
41
|
+
import { MonacoEditorModel } from './monaco-editor-model';
|
|
42
|
+
import { MonacoToProtocolConverter } from './monaco-to-protocol-converter';
|
|
43
|
+
import { ProtocolToMonacoConverter } from './protocol-to-monaco-converter';
|
|
44
|
+
import { TextEdit } from '@theia/core/shared/vscode-languageserver-protocol';
|
|
45
|
+
import { UTF8 } from '@theia/core/lib/common/encodings';
|
|
46
|
+
import * as monaco from '@theia/monaco-editor-core';
|
|
47
|
+
import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
48
|
+
import { ILanguageService } from '@theia/monaco-editor-core/esm/vs/editor/common/languages/language';
|
|
49
|
+
import { IInstantiationService, ServiceIdentifier } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiation';
|
|
50
|
+
import { ICodeEditor, IMouseTargetMargin } from '@theia/monaco-editor-core/esm/vs/editor/browser/editorBrowser';
|
|
51
|
+
import { IStandaloneEditorConstructionOptions, StandaloneEditor } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneCodeEditor';
|
|
52
|
+
import { ServiceCollection } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/serviceCollection';
|
|
53
|
+
import { MarkdownString } from '@theia/core/lib/common/markdown-rendering';
|
|
54
|
+
|
|
55
|
+
export type ServicePair<T> = [ServiceIdentifier<T>, T];
|
|
56
|
+
|
|
57
|
+
export interface EditorServiceOverrides extends Iterable<ServicePair<unknown>> { }
|
|
58
|
+
|
|
59
|
+
@injectable()
|
|
60
|
+
export class MonacoEditorServices {
|
|
61
|
+
|
|
62
|
+
@inject(MonacoToProtocolConverter)
|
|
63
|
+
protected readonly m2p: MonacoToProtocolConverter;
|
|
64
|
+
|
|
65
|
+
@inject(ProtocolToMonacoConverter)
|
|
66
|
+
protected readonly p2m: ProtocolToMonacoConverter;
|
|
67
|
+
|
|
68
|
+
@inject(ContextKeyService)
|
|
69
|
+
protected readonly contextKeyService: ContextKeyService;
|
|
70
|
+
|
|
71
|
+
constructor(@unmanaged() services: MonacoEditorServices) {
|
|
72
|
+
Object.assign(this, services);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export class MonacoEditor extends MonacoEditorServices implements TextEditor {
|
|
77
|
+
|
|
78
|
+
protected readonly toDispose = new DisposableCollection();
|
|
79
|
+
|
|
80
|
+
protected readonly autoSizing: boolean;
|
|
81
|
+
protected readonly minHeight: number;
|
|
82
|
+
protected readonly maxHeight: number;
|
|
83
|
+
protected editor: monaco.editor.IStandaloneCodeEditor;
|
|
84
|
+
|
|
85
|
+
protected readonly onCursorPositionChangedEmitter = new Emitter<Position>();
|
|
86
|
+
protected readonly onSelectionChangedEmitter = new Emitter<Range>();
|
|
87
|
+
protected readonly onFocusChangedEmitter = new Emitter<boolean>();
|
|
88
|
+
protected readonly onDocumentContentChangedEmitter = new Emitter<TextDocumentChangeEvent>();
|
|
89
|
+
protected readonly onMouseDownEmitter = new Emitter<EditorMouseEvent>();
|
|
90
|
+
readonly onDidChangeReadOnly = this.document.onDidChangeReadOnly;
|
|
91
|
+
protected readonly onLanguageChangedEmitter = new Emitter<string>();
|
|
92
|
+
readonly onLanguageChanged = this.onLanguageChangedEmitter.event;
|
|
93
|
+
protected readonly onScrollChangedEmitter = new Emitter<void>();
|
|
94
|
+
readonly onEncodingChanged = this.document.onDidChangeEncoding;
|
|
95
|
+
protected readonly onResizeEmitter = new Emitter<Dimension | null>();
|
|
96
|
+
readonly onDidResize = this.onResizeEmitter.event;
|
|
97
|
+
|
|
98
|
+
readonly documents = new Set<MonacoEditorModel>();
|
|
99
|
+
|
|
100
|
+
constructor(
|
|
101
|
+
readonly uri: URI,
|
|
102
|
+
readonly document: MonacoEditorModel,
|
|
103
|
+
readonly node: HTMLElement,
|
|
104
|
+
services: MonacoEditorServices,
|
|
105
|
+
options?: MonacoEditor.IOptions,
|
|
106
|
+
override?: EditorServiceOverrides
|
|
107
|
+
) {
|
|
108
|
+
super(services);
|
|
109
|
+
this.toDispose.pushAll([
|
|
110
|
+
this.onCursorPositionChangedEmitter,
|
|
111
|
+
this.onSelectionChangedEmitter,
|
|
112
|
+
this.onFocusChangedEmitter,
|
|
113
|
+
this.onDocumentContentChangedEmitter,
|
|
114
|
+
this.onMouseDownEmitter,
|
|
115
|
+
this.onLanguageChangedEmitter,
|
|
116
|
+
this.onScrollChangedEmitter
|
|
117
|
+
]);
|
|
118
|
+
this.documents.add(document);
|
|
119
|
+
this.autoSizing = options && options.autoSizing !== undefined ? options.autoSizing : false;
|
|
120
|
+
this.minHeight = options && options.minHeight !== undefined ? options.minHeight : -1;
|
|
121
|
+
this.maxHeight = options && options.maxHeight !== undefined ? options.maxHeight : -1;
|
|
122
|
+
this.toDispose.push(this.create({
|
|
123
|
+
...MonacoEditor.createReadOnlyOptions(document.readOnly),
|
|
124
|
+
...options
|
|
125
|
+
}, override));
|
|
126
|
+
this.addHandlers(this.editor);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
getEncoding(): string {
|
|
130
|
+
return this.document.getEncoding() || UTF8;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
setEncoding(encoding: string, mode: EncodingMode): Promise<void> {
|
|
134
|
+
return this.document.setEncoding(encoding, mode);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
protected create(options?: monaco.editor.IStandaloneEditorConstructionOptions | IStandaloneEditorConstructionOptions, override?: EditorServiceOverrides): Disposable {
|
|
138
|
+
const combinedOptions = {
|
|
139
|
+
...options,
|
|
140
|
+
lightbulb: { enabled: true },
|
|
141
|
+
fixedOverflowWidgets: true,
|
|
142
|
+
scrollbar: {
|
|
143
|
+
useShadows: false,
|
|
144
|
+
verticalHasArrows: false,
|
|
145
|
+
horizontalHasArrows: false,
|
|
146
|
+
verticalScrollbarSize: 10,
|
|
147
|
+
horizontalScrollbarSize: 10,
|
|
148
|
+
...options?.scrollbar,
|
|
149
|
+
}
|
|
150
|
+
} as IStandaloneEditorConstructionOptions;
|
|
151
|
+
const instantiator = this.getInstantiatorWithOverrides(override);
|
|
152
|
+
/**
|
|
153
|
+
* @monaco-uplift. Should be guaranteed to work.
|
|
154
|
+
* Incomparable enums prevent TypeScript from believing that public IStandaloneCodeEditor is satisfied by private StandaloneCodeEditor
|
|
155
|
+
*/
|
|
156
|
+
return this.editor = instantiator.createInstance(StandaloneEditor, this.node, combinedOptions) as unknown as monaco.editor.IStandaloneCodeEditor;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
protected getInstantiatorWithOverrides(override?: EditorServiceOverrides): IInstantiationService {
|
|
160
|
+
const instantiator = StandaloneServices.get(IInstantiationService);
|
|
161
|
+
if (override) {
|
|
162
|
+
const overrideServices = new ServiceCollection(...override);
|
|
163
|
+
return instantiator.createChild(overrideServices);
|
|
164
|
+
}
|
|
165
|
+
return instantiator;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
protected addHandlers(codeEditor: monaco.editor.IStandaloneCodeEditor): void {
|
|
169
|
+
this.toDispose.push(codeEditor.onDidChangeModelLanguage(e =>
|
|
170
|
+
this.fireLanguageChanged(e.newLanguage)
|
|
171
|
+
));
|
|
172
|
+
this.toDispose.push(codeEditor.onDidChangeConfiguration(() => this.refresh()));
|
|
173
|
+
this.toDispose.push(codeEditor.onDidChangeModel(() => this.refresh()));
|
|
174
|
+
this.toDispose.push(codeEditor.onDidChangeModelContent(e => {
|
|
175
|
+
this.refresh();
|
|
176
|
+
this.onDocumentContentChangedEmitter.fire({ document: this.document, contentChanges: e.changes.map(this.mapModelContentChange.bind(this)) });
|
|
177
|
+
}));
|
|
178
|
+
this.toDispose.push(codeEditor.onDidChangeCursorPosition(() =>
|
|
179
|
+
this.onCursorPositionChangedEmitter.fire(this.cursor)
|
|
180
|
+
));
|
|
181
|
+
this.toDispose.push(codeEditor.onDidChangeCursorSelection(() =>
|
|
182
|
+
this.onSelectionChangedEmitter.fire(this.selection)
|
|
183
|
+
));
|
|
184
|
+
this.toDispose.push(codeEditor.onDidFocusEditorText(() =>
|
|
185
|
+
this.onFocusChangedEmitter.fire(this.isFocused())
|
|
186
|
+
));
|
|
187
|
+
this.toDispose.push(codeEditor.onDidBlurEditorText(() =>
|
|
188
|
+
this.onFocusChangedEmitter.fire(this.isFocused())
|
|
189
|
+
));
|
|
190
|
+
this.toDispose.push(codeEditor.onMouseDown(e => {
|
|
191
|
+
const { element, position, range } = e.target;
|
|
192
|
+
this.onMouseDownEmitter.fire({
|
|
193
|
+
target: {
|
|
194
|
+
type: e.target.type as unknown as MouseTargetType,
|
|
195
|
+
element: element || undefined,
|
|
196
|
+
mouseColumn: this.m2p.asPosition(undefined, e.target.mouseColumn).character,
|
|
197
|
+
range: range && this.m2p.asRange(range) || undefined,
|
|
198
|
+
position: position && this.m2p.asPosition(position.lineNumber, position.column) || undefined,
|
|
199
|
+
detail: (e.target as unknown as IMouseTargetMargin).detail || {},
|
|
200
|
+
},
|
|
201
|
+
event: e.event.browserEvent
|
|
202
|
+
});
|
|
203
|
+
}));
|
|
204
|
+
this.toDispose.push(codeEditor.onDidScrollChange(e => {
|
|
205
|
+
this.onScrollChangedEmitter.fire(undefined);
|
|
206
|
+
}));
|
|
207
|
+
this.toDispose.push(this.onDidChangeReadOnly(readOnly => {
|
|
208
|
+
codeEditor.updateOptions(MonacoEditor.createReadOnlyOptions(readOnly));
|
|
209
|
+
}));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
getVisibleRanges(): Range[] {
|
|
213
|
+
return this.editor.getVisibleRanges().map(range => this.m2p.asRange(range));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
protected mapModelContentChange(change: monaco.editor.IModelContentChange): TextDocumentContentChangeDelta {
|
|
217
|
+
return {
|
|
218
|
+
range: this.m2p.asRange(change.range),
|
|
219
|
+
rangeLength: change.rangeLength,
|
|
220
|
+
text: change.text
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
get onDispose(): Event<void> {
|
|
225
|
+
return this.toDispose.onDispose;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
get onDocumentContentChanged(): Event<TextDocumentChangeEvent> {
|
|
229
|
+
return this.onDocumentContentChangedEmitter.event;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
get isReadonly(): boolean | MarkdownString {
|
|
233
|
+
return this.document.readOnly;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
get cursor(): Position {
|
|
237
|
+
const { lineNumber, column } = this.editor.getPosition()!;
|
|
238
|
+
return this.m2p.asPosition(lineNumber, column);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
set cursor(cursor: Position) {
|
|
242
|
+
const position = this.p2m.asPosition(cursor);
|
|
243
|
+
this.editor.setPosition(position);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
get onCursorPositionChanged(): Event<Position> {
|
|
247
|
+
return this.onCursorPositionChangedEmitter.event;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
get selection(): Range {
|
|
251
|
+
return this.m2p.asRange(this.editor.getSelection()!);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
set selection(selection: Range) {
|
|
255
|
+
const range = this.p2m.asRange(selection);
|
|
256
|
+
this.editor.setSelection(range);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
get onSelectionChanged(): Event<Range> {
|
|
260
|
+
return this.onSelectionChangedEmitter.event;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
get onScrollChanged(): Event<void> {
|
|
264
|
+
return this.onScrollChangedEmitter.event;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
revealPosition(raw: Position, options: RevealPositionOptions = { vertical: 'center' }): void {
|
|
268
|
+
const position = this.p2m.asPosition(raw);
|
|
269
|
+
switch (options.vertical) {
|
|
270
|
+
case 'auto':
|
|
271
|
+
this.editor.revealPosition(position);
|
|
272
|
+
break;
|
|
273
|
+
case 'center':
|
|
274
|
+
this.editor.revealPositionInCenter(position);
|
|
275
|
+
break;
|
|
276
|
+
case 'centerIfOutsideViewport':
|
|
277
|
+
this.editor.revealPositionInCenterIfOutsideViewport(position);
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
revealRange(raw: Range, options: RevealRangeOptions = { at: 'center' }): void {
|
|
283
|
+
const range = this.p2m.asRange(raw);
|
|
284
|
+
switch (options.at) {
|
|
285
|
+
case 'top':
|
|
286
|
+
this.editor.revealRangeAtTop(range!);
|
|
287
|
+
break;
|
|
288
|
+
case 'center':
|
|
289
|
+
this.editor.revealRangeInCenter(range!);
|
|
290
|
+
break;
|
|
291
|
+
case 'centerIfOutsideViewport':
|
|
292
|
+
this.editor.revealRangeInCenterIfOutsideViewport(range!);
|
|
293
|
+
break;
|
|
294
|
+
case 'auto':
|
|
295
|
+
this.editor.revealRange(range!);
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
focus(): void {
|
|
301
|
+
/**
|
|
302
|
+
* `this.editor.focus` forcefully changes the focus editor state,
|
|
303
|
+
* regardless whether the textarea actually received the focus.
|
|
304
|
+
* It could lead to issues like https://github.com/eclipse-theia/theia/issues/7902
|
|
305
|
+
* Instead we focus the underlying textarea.
|
|
306
|
+
*/
|
|
307
|
+
const node = this.editor.getDomNode();
|
|
308
|
+
if (node) {
|
|
309
|
+
const textarea = node.querySelector('textarea') as HTMLElement;
|
|
310
|
+
textarea.focus();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
blur(): void {
|
|
315
|
+
const node = this.editor.getDomNode();
|
|
316
|
+
if (node) {
|
|
317
|
+
const textarea = node.querySelector('textarea') as HTMLElement;
|
|
318
|
+
textarea.blur();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
isFocused({ strict }: { strict: boolean } = { strict: false }): boolean {
|
|
323
|
+
if (!this.editor.hasTextFocus()) {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
if (strict) {
|
|
327
|
+
return !this.isSuggestWidgetVisible() && !this.isFindWidgetVisible() && !this.isRenameInputVisible();
|
|
328
|
+
}
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
get onFocusChanged(): Event<boolean> {
|
|
333
|
+
return this.onFocusChangedEmitter.event;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
get onMouseDown(): Event<EditorMouseEvent> {
|
|
337
|
+
return this.onMouseDownEmitter.event;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* `true` if the suggest widget is visible in the editor. Otherwise, `false`.
|
|
342
|
+
*/
|
|
343
|
+
isSuggestWidgetVisible(): boolean {
|
|
344
|
+
return this.contextKeyService.match('suggestWidgetVisible', this.editor.getDomNode() || this.node);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* `true` if the find (and replace) widget is visible in the editor. Otherwise, `false`.
|
|
349
|
+
*/
|
|
350
|
+
isFindWidgetVisible(): boolean {
|
|
351
|
+
return this.contextKeyService.match('findWidgetVisible', this.editor.getDomNode() || this.node);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* `true` if the name rename refactoring input HTML element is visible. Otherwise, `false`.
|
|
356
|
+
*/
|
|
357
|
+
isRenameInputVisible(): boolean {
|
|
358
|
+
return this.contextKeyService.match('renameInputVisible', this.editor.getDomNode() || this.node);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
dispose(): void {
|
|
362
|
+
this.toDispose.dispose();
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
366
|
+
trigger(source: string, handlerId: string, payload: any): void {
|
|
367
|
+
this.editor.trigger(source, handlerId, payload);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
getControl(): monaco.editor.IStandaloneCodeEditor {
|
|
371
|
+
return this.editor;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
refresh(): void {
|
|
375
|
+
this.autoresize();
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
resizeToFit(): void {
|
|
379
|
+
this.autoresize();
|
|
380
|
+
// eslint-disable-next-line no-null/no-null
|
|
381
|
+
this.onResizeEmitter.fire(null);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
setSize(dimension: Dimension): void {
|
|
385
|
+
this.resize(dimension);
|
|
386
|
+
this.onResizeEmitter.fire(dimension);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
protected autoresize(): void {
|
|
390
|
+
if (this.autoSizing) {
|
|
391
|
+
// eslint-disable-next-line no-null/no-null
|
|
392
|
+
this.resize(null);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
protected resize(dimension: Dimension | null): void {
|
|
397
|
+
if (this.node) {
|
|
398
|
+
const layoutSize = this.computeLayoutSize(this.node, dimension);
|
|
399
|
+
this.editor.layout(layoutSize);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
protected computeLayoutSize(hostNode: HTMLElement, dimension: monaco.editor.IDimension | null): monaco.editor.IDimension {
|
|
404
|
+
if (dimension && dimension.width >= 0 && dimension.height >= 0) {
|
|
405
|
+
return dimension;
|
|
406
|
+
}
|
|
407
|
+
const boxSizing = ElementExt.boxSizing(hostNode);
|
|
408
|
+
|
|
409
|
+
const width = (!dimension || dimension.width < 0) ?
|
|
410
|
+
this.getWidth(hostNode, boxSizing) :
|
|
411
|
+
dimension.width;
|
|
412
|
+
|
|
413
|
+
const height = (!dimension || dimension.height < 0) ?
|
|
414
|
+
this.getHeight(hostNode, boxSizing) :
|
|
415
|
+
dimension.height;
|
|
416
|
+
|
|
417
|
+
return { width, height };
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
protected getWidth(hostNode: HTMLElement, boxSizing: ElementExt.IBoxSizing): number {
|
|
421
|
+
return hostNode.offsetWidth - boxSizing.horizontalSum;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
protected getHeight(hostNode: HTMLElement, boxSizing: ElementExt.IBoxSizing): number {
|
|
425
|
+
if (!this.autoSizing) {
|
|
426
|
+
return hostNode.offsetHeight - boxSizing.verticalSum;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
const lineHeight = this.editor.getOption(monaco.editor.EditorOption.lineHeight);
|
|
430
|
+
const lineCount = this.editor.getModel()!.getLineCount();
|
|
431
|
+
const contentHeight = lineHeight * lineCount;
|
|
432
|
+
|
|
433
|
+
const horizontalScrollbarHeight = this.editor.getLayoutInfo().horizontalScrollbarHeight;
|
|
434
|
+
|
|
435
|
+
const editorHeight = contentHeight + horizontalScrollbarHeight;
|
|
436
|
+
if (this.minHeight >= 0) {
|
|
437
|
+
const minHeight = lineHeight * this.minHeight + horizontalScrollbarHeight;
|
|
438
|
+
if (editorHeight < minHeight) {
|
|
439
|
+
return minHeight;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
if (this.maxHeight >= 0) {
|
|
443
|
+
const maxHeight = lineHeight * this.maxHeight + horizontalScrollbarHeight;
|
|
444
|
+
return Math.min(maxHeight, editorHeight);
|
|
445
|
+
}
|
|
446
|
+
return editorHeight;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
isActionSupported(id: string): boolean {
|
|
450
|
+
const action = this.editor.getAction(id);
|
|
451
|
+
return !!action && action.isSupported();
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
async runAction(id: string): Promise<void> {
|
|
455
|
+
const action = this.editor.getAction(id);
|
|
456
|
+
if (action && action.isSupported()) {
|
|
457
|
+
await action.run();
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
deltaDecorations(params: DeltaDecorationParams): string[] {
|
|
462
|
+
const oldDecorations = params.oldDecorations;
|
|
463
|
+
const newDecorations = this.toDeltaDecorations(params);
|
|
464
|
+
return this.editor.deltaDecorations(oldDecorations, newDecorations);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
protected toDeltaDecorations(params: DeltaDecorationParams): monaco.editor.IModelDeltaDecoration[] {
|
|
468
|
+
return params.newDecorations.map(({ options: theiaOptions, range }) => {
|
|
469
|
+
const options: monaco.editor.IModelDecorationOptions = {
|
|
470
|
+
...theiaOptions,
|
|
471
|
+
hoverMessage: this.fromStringToMarkdownString(theiaOptions.hoverMessage),
|
|
472
|
+
glyphMarginHoverMessage: this.fromStringToMarkdownString(theiaOptions.glyphMarginHoverMessage)
|
|
473
|
+
};
|
|
474
|
+
return {
|
|
475
|
+
options,
|
|
476
|
+
range: this.p2m.asRange(range),
|
|
477
|
+
};
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
protected fromStringToMarkdownString(hoverMessage?: string | monaco.IMarkdownString | monaco.IMarkdownString[]): monaco.IMarkdownString | monaco.IMarkdownString[] | undefined {
|
|
482
|
+
if (typeof hoverMessage === 'string') {
|
|
483
|
+
return { value: hoverMessage };
|
|
484
|
+
}
|
|
485
|
+
return hoverMessage;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
protected fromMarkdownToString(maybeMarkdown?: null | string | monaco.IMarkdownString | monaco.IMarkdownString[]): string | undefined {
|
|
489
|
+
if (!maybeMarkdown) {
|
|
490
|
+
return undefined;
|
|
491
|
+
}
|
|
492
|
+
if (typeof maybeMarkdown === 'string') {
|
|
493
|
+
return maybeMarkdown;
|
|
494
|
+
}
|
|
495
|
+
if (Array.isArray(maybeMarkdown)) {
|
|
496
|
+
return maybeMarkdown.map(({ value }) => value).join('\n');
|
|
497
|
+
}
|
|
498
|
+
return maybeMarkdown.value;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
getLinesDecorations(startLineNumber: number, endLineNumber: number): (EditorDecoration & Readonly<{ id: string }>)[] {
|
|
502
|
+
const toPosition = (line: number): monaco.Position => this.p2m.asPosition({ line, character: 0 });
|
|
503
|
+
const start = toPosition(startLineNumber).lineNumber;
|
|
504
|
+
const end = toPosition(endLineNumber).lineNumber;
|
|
505
|
+
return this.editor
|
|
506
|
+
.getModel()!
|
|
507
|
+
.getLinesDecorations(start, end)
|
|
508
|
+
.map(this.toEditorDecoration.bind(this));
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
protected toEditorDecoration(decoration: monaco.editor.IModelDecoration): EditorDecoration & Readonly<{ id: string }> {
|
|
512
|
+
const range = this.m2p.asRange(decoration.range);
|
|
513
|
+
const { id, options: monacoOptions } = decoration;
|
|
514
|
+
const options: MaybeNull<EditorDecorationOptions> = {
|
|
515
|
+
...monacoOptions,
|
|
516
|
+
hoverMessage: this.fromMarkdownToString(monacoOptions.hoverMessage),
|
|
517
|
+
glyphMarginHoverMessage: this.fromMarkdownToString(monacoOptions.hoverMessage),
|
|
518
|
+
};
|
|
519
|
+
return {
|
|
520
|
+
options: nullToUndefined(options),
|
|
521
|
+
range,
|
|
522
|
+
id
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
getVisibleColumn(position: Position): number {
|
|
527
|
+
return this.editor.getVisibleColumnFromPosition(this.p2m.asPosition(position));
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
async replaceText(params: ReplaceTextParams): Promise<boolean> {
|
|
531
|
+
const edits: monaco.editor.IIdentifiedSingleEditOperation[] = params.replaceOperations.map(param => {
|
|
532
|
+
const range = monaco.Range.fromPositions(this.p2m.asPosition(param.range.start), this.p2m.asPosition(param.range.end));
|
|
533
|
+
return {
|
|
534
|
+
forceMoveMarkers: true,
|
|
535
|
+
identifier: {
|
|
536
|
+
major: range.startLineNumber,
|
|
537
|
+
minor: range.startColumn
|
|
538
|
+
},
|
|
539
|
+
range,
|
|
540
|
+
text: param.text
|
|
541
|
+
};
|
|
542
|
+
});
|
|
543
|
+
return this.editor.executeEdits(params.source, edits);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
executeEdits(edits: TextEdit[]): boolean {
|
|
547
|
+
return this.editor.executeEdits('MonacoEditor', this.p2m.asTextEdits(edits) as monaco.editor.IIdentifiedSingleEditOperation[]);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
storeViewState(): object {
|
|
551
|
+
return this.editor.saveViewState()!;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
restoreViewState(state: monaco.editor.ICodeEditorViewState): void {
|
|
555
|
+
this.editor.restoreViewState(state);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/* `true` because it is derived from an URI during the instantiation */
|
|
559
|
+
protected _languageAutoDetected = true;
|
|
560
|
+
|
|
561
|
+
get languageAutoDetected(): boolean {
|
|
562
|
+
return this._languageAutoDetected;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
async detectLanguage(): Promise<void> {
|
|
566
|
+
const languageService = StandaloneServices.get(ILanguageService);
|
|
567
|
+
const firstLine = this.document.textEditorModel.getLineContent(1);
|
|
568
|
+
const model = this.getControl().getModel();
|
|
569
|
+
const language = languageService.createByFilepathOrFirstLine(model && model.uri, firstLine);
|
|
570
|
+
this.setLanguage(language.languageId);
|
|
571
|
+
this._languageAutoDetected = true;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
setLanguage(languageId: string): void {
|
|
575
|
+
for (const document of this.documents) {
|
|
576
|
+
monaco.editor.setModelLanguage(document.textEditorModel, languageId);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
protected fireLanguageChanged(languageId: string): void {
|
|
581
|
+
this._languageAutoDetected = false;
|
|
582
|
+
this.onLanguageChangedEmitter.fire(languageId);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
getResourceUri(): URI {
|
|
586
|
+
return this.uri;
|
|
587
|
+
}
|
|
588
|
+
createMoveToUri(resourceUri: URI): URI {
|
|
589
|
+
return this.uri.withPath(resourceUri.path);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
export namespace MonacoEditor {
|
|
595
|
+
export interface ICommonOptions {
|
|
596
|
+
/**
|
|
597
|
+
* Whether an editor should be auto resized on a content change.
|
|
598
|
+
*
|
|
599
|
+
* #### Fixme
|
|
600
|
+
* remove when https://github.com/Microsoft/monaco-editor/issues/103 is resolved
|
|
601
|
+
*/
|
|
602
|
+
autoSizing?: boolean;
|
|
603
|
+
/**
|
|
604
|
+
* A minimal height of an editor in lines.
|
|
605
|
+
*
|
|
606
|
+
* #### Fixme
|
|
607
|
+
* remove when https://github.com/Microsoft/monaco-editor/issues/103 is resolved
|
|
608
|
+
*/
|
|
609
|
+
minHeight?: number;
|
|
610
|
+
/**
|
|
611
|
+
* A maximal height of an editor in lines.
|
|
612
|
+
*
|
|
613
|
+
* #### Fixme
|
|
614
|
+
* remove when https://github.com/Microsoft/monaco-editor/issues/103 is resolved
|
|
615
|
+
*/
|
|
616
|
+
maxHeight?: number;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
export interface IOptions extends ICommonOptions, monaco.editor.IStandaloneEditorConstructionOptions { }
|
|
620
|
+
|
|
621
|
+
export function getAll(manager: EditorManager): MonacoEditor[] {
|
|
622
|
+
return manager.all.map(e => get(e)).filter(e => !!e) as MonacoEditor[];
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
export function getCurrent(manager: EditorManager): MonacoEditor | undefined {
|
|
626
|
+
return get(manager.currentEditor);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
export function getActive(manager: EditorManager): MonacoEditor | undefined {
|
|
630
|
+
return get(manager.activeEditor);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
export function get(editorWidget: EditorWidget | undefined): MonacoEditor | undefined {
|
|
634
|
+
if (editorWidget && editorWidget.editor instanceof MonacoEditor) {
|
|
635
|
+
return editorWidget.editor;
|
|
636
|
+
}
|
|
637
|
+
return undefined;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
export function findByDocument(manager: EditorManager, document: MonacoEditorModel): MonacoEditor[] {
|
|
641
|
+
return getAll(manager).filter(candidate => candidate.documents.has(document));
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
export function getWidgetFor(manager: EditorManager, control: monaco.editor.ICodeEditor | ICodeEditor | undefined | null): EditorWidget | undefined {
|
|
645
|
+
if (!control) {
|
|
646
|
+
return undefined;
|
|
647
|
+
}
|
|
648
|
+
return manager.all.find(widget => {
|
|
649
|
+
const candidate = get(widget);
|
|
650
|
+
return candidate && candidate.getControl() === control;
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
export function createReadOnlyOptions(readOnly?: boolean | MarkdownString): monaco.editor.IEditorOptions {
|
|
655
|
+
if (typeof readOnly === 'boolean') {
|
|
656
|
+
return { readOnly };
|
|
657
|
+
}
|
|
658
|
+
if (readOnly) {
|
|
659
|
+
return { readOnly: true, readOnlyMessage: readOnly };
|
|
660
|
+
}
|
|
661
|
+
return {};
|
|
662
|
+
}
|
|
663
|
+
}
|