@theia/monaco 1.24.0-next.46 → 1.24.0-next.49
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/monaco-bulk-edit-service.d.ts +6 -4
- package/lib/browser/monaco-bulk-edit-service.d.ts.map +1 -1
- package/lib/browser/monaco-bulk-edit-service.js.map +1 -1
- package/lib/browser/monaco-color-registry.d.ts +6 -3
- package/lib/browser/monaco-color-registry.d.ts.map +1 -1
- package/lib/browser/monaco-color-registry.js +17 -13
- package/lib/browser/monaco-color-registry.js.map +1 -1
- package/lib/browser/monaco-command-service.d.ts +6 -5
- package/lib/browser/monaco-command-service.d.ts.map +1 -1
- package/lib/browser/monaco-command-service.js +2 -2
- package/lib/browser/monaco-command-service.js.map +1 -1
- package/lib/browser/monaco-command.d.ts +2 -1
- package/lib/browser/monaco-command.d.ts.map +1 -1
- package/lib/browser/monaco-command.js +17 -16
- package/lib/browser/monaco-command.js.map +1 -1
- package/lib/browser/monaco-context-key-service.d.ts +10 -8
- package/lib/browser/monaco-context-key-service.d.ts.map +1 -1
- package/lib/browser/monaco-context-key-service.js +18 -9
- package/lib/browser/monaco-context-key-service.js.map +1 -1
- package/lib/browser/monaco-context-menu.d.ts +8 -2
- package/lib/browser/monaco-context-menu.d.ts.map +1 -1
- package/lib/browser/monaco-context-menu.js +22 -4
- package/lib/browser/monaco-context-menu.js.map +1 -1
- package/lib/browser/monaco-diagnostic-collection.d.ts +4 -6
- package/lib/browser/monaco-diagnostic-collection.d.ts.map +1 -1
- package/lib/browser/monaco-diagnostic-collection.js +1 -0
- package/lib/browser/monaco-diagnostic-collection.js.map +1 -1
- package/lib/browser/monaco-diff-editor.d.ts +8 -10
- package/lib/browser/monaco-diff-editor.d.ts.map +1 -1
- package/lib/browser/monaco-diff-editor.js +4 -1
- package/lib/browser/monaco-diff-editor.js.map +1 -1
- package/lib/browser/monaco-diff-navigator-factory.d.ts +3 -4
- package/lib/browser/monaco-diff-navigator-factory.d.ts.map +1 -1
- package/lib/browser/monaco-diff-navigator-factory.js +14 -9
- package/lib/browser/monaco-diff-navigator-factory.js.map +1 -1
- package/lib/browser/monaco-editor-model.d.ts +20 -13
- package/lib/browser/monaco-editor-model.d.ts.map +1 -1
- package/lib/browser/monaco-editor-model.js +39 -14
- package/lib/browser/monaco-editor-model.js.map +1 -1
- package/lib/browser/monaco-editor-provider.d.ts +13 -19
- package/lib/browser/monaco-editor-provider.d.ts.map +1 -1
- package/lib/browser/monaco-editor-provider.js +39 -96
- package/lib/browser/monaco-editor-provider.js.map +1 -1
- package/lib/browser/monaco-editor-service.d.ts +9 -8
- package/lib/browser/monaco-editor-service.d.ts.map +1 -1
- package/lib/browser/monaco-editor-service.js +19 -8
- package/lib/browser/monaco-editor-service.js.map +1 -1
- package/lib/browser/monaco-editor-zone-widget.d.ts +3 -3
- package/lib/browser/monaco-editor-zone-widget.d.ts.map +1 -1
- package/lib/browser/monaco-editor-zone-widget.js +3 -2
- package/lib/browser/monaco-editor-zone-widget.js.map +1 -1
- package/lib/browser/monaco-editor.d.ts +20 -18
- package/lib/browser/monaco-editor.d.ts.map +1 -1
- package/lib/browser/monaco-editor.js +53 -19
- package/lib/browser/monaco-editor.js.map +1 -1
- package/lib/browser/monaco-formatting-conflicts.d.ts +1 -1
- package/lib/browser/monaco-formatting-conflicts.d.ts.map +1 -1
- package/lib/browser/monaco-formatting-conflicts.js +2 -1
- package/lib/browser/monaco-formatting-conflicts.js.map +1 -1
- package/lib/browser/monaco-frontend-application-contribution.d.ts +10 -1
- package/lib/browser/monaco-frontend-application-contribution.d.ts.map +1 -1
- package/lib/browser/monaco-frontend-application-contribution.js +42 -1
- package/lib/browser/monaco-frontend-application-contribution.js.map +1 -1
- package/lib/browser/monaco-frontend-module.d.ts +2 -1
- package/lib/browser/monaco-frontend-module.d.ts.map +1 -1
- package/lib/browser/monaco-frontend-module.js +8 -5
- package/lib/browser/monaco-frontend-module.js.map +1 -1
- package/lib/browser/monaco-gotoline-quick-access.d.ts +4 -2
- package/lib/browser/monaco-gotoline-quick-access.d.ts.map +1 -1
- package/lib/browser/monaco-gotoline-quick-access.js +9 -4
- package/lib/browser/monaco-gotoline-quick-access.js.map +1 -1
- package/lib/browser/monaco-gotosymbol-quick-access.d.ts +10 -3
- package/lib/browser/monaco-gotosymbol-quick-access.d.ts.map +1 -1
- package/lib/browser/monaco-gotosymbol-quick-access.js +19 -8
- package/lib/browser/monaco-gotosymbol-quick-access.js.map +1 -1
- package/lib/browser/monaco-indexed-db.d.ts +1 -1
- package/lib/browser/monaco-indexed-db.d.ts.map +1 -1
- package/lib/browser/monaco-indexed-db.js.map +1 -1
- package/lib/browser/monaco-keybinding.d.ts.map +1 -1
- package/lib/browser/monaco-keybinding.js +4 -2
- 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.d.ts.map +1 -1
- package/lib/browser/monaco-keycode-map.js +122 -122
- package/lib/browser/monaco-keycode-map.js.map +1 -1
- package/lib/browser/monaco-languages.d.ts +1 -1
- package/lib/browser/monaco-languages.d.ts.map +1 -1
- package/lib/browser/monaco-languages.js +1 -0
- package/lib/browser/monaco-languages.js.map +1 -1
- package/lib/browser/monaco-menu.js +7 -7
- package/lib/browser/monaco-menu.js.map +1 -1
- package/lib/browser/monaco-mime-service.d.ts.map +1 -1
- package/lib/browser/monaco-mime-service.js +8 -4
- package/lib/browser/monaco-mime-service.js.map +1 -1
- package/lib/browser/monaco-outline-contribution.d.ts +15 -16
- package/lib/browser/monaco-outline-contribution.d.ts.map +1 -1
- package/lib/browser/monaco-outline-contribution.js +21 -19
- package/lib/browser/monaco-outline-contribution.js.map +1 -1
- package/lib/browser/monaco-quick-access-registry.d.ts.map +1 -1
- package/lib/browser/monaco-quick-access-registry.js +11 -13
- package/lib/browser/monaco-quick-access-registry.js.map +1 -1
- package/lib/browser/monaco-quick-input-service.d.ts +46 -25
- package/lib/browser/monaco-quick-input-service.d.ts.map +1 -1
- package/lib/browser/monaco-quick-input-service.js +40 -29
- package/lib/browser/monaco-quick-input-service.js.map +1 -1
- package/lib/browser/monaco-resolved-keybinding.d.ts +9 -7
- package/lib/browser/monaco-resolved-keybinding.d.ts.map +1 -1
- package/lib/browser/monaco-resolved-keybinding.js +35 -14
- package/lib/browser/monaco-resolved-keybinding.js.map +1 -1
- package/lib/browser/monaco-snippet-suggest-provider.d.ts +1 -1
- package/lib/browser/monaco-snippet-suggest-provider.d.ts.map +1 -1
- package/lib/browser/monaco-snippet-suggest-provider.js +5 -3
- package/lib/browser/monaco-snippet-suggest-provider.js.map +1 -1
- package/lib/browser/monaco-status-bar-contribution.d.ts +2 -2
- package/lib/browser/monaco-status-bar-contribution.d.ts.map +1 -1
- package/lib/browser/monaco-status-bar-contribution.js.map +1 -1
- package/lib/browser/monaco-text-model-service.d.ts +14 -8
- package/lib/browser/monaco-text-model-service.d.ts.map +1 -1
- package/lib/browser/monaco-text-model-service.js +35 -17
- package/lib/browser/monaco-text-model-service.js.map +1 -1
- package/lib/browser/monaco-theming-service.d.ts +1 -1
- package/lib/browser/monaco-theming-service.d.ts.map +1 -1
- package/lib/browser/monaco-theming-service.js.map +1 -1
- package/lib/browser/monaco-to-protocol-converter.d.ts +1 -1
- package/lib/browser/monaco-to-protocol-converter.d.ts.map +1 -1
- package/lib/browser/monaco-to-protocol-converter.js.map +1 -1
- package/lib/browser/monaco-workspace.d.ts +7 -6
- package/lib/browser/monaco-workspace.d.ts.map +1 -1
- package/lib/browser/monaco-workspace.js +13 -7
- package/lib/browser/monaco-workspace.js.map +1 -1
- package/lib/browser/protocol-to-monaco-converter.d.ts +1 -1
- package/lib/browser/protocol-to-monaco-converter.d.ts.map +1 -1
- package/lib/browser/protocol-to-monaco-converter.js +1 -0
- package/lib/browser/protocol-to-monaco-converter.js.map +1 -1
- package/lib/browser/textmate/monaco-textmate-service.d.ts.map +1 -1
- package/lib/browser/textmate/monaco-textmate-service.js +14 -11
- package/lib/browser/textmate/monaco-textmate-service.js.map +1 -1
- package/lib/browser/textmate/monaco-theme-registry.d.ts +5 -3
- package/lib/browser/textmate/monaco-theme-registry.d.ts.map +1 -1
- package/lib/browser/textmate/monaco-theme-registry.js +6 -3
- package/lib/browser/textmate/monaco-theme-registry.js.map +1 -1
- package/lib/browser/textmate/monaco-theme-types.d.ts +5 -4
- package/lib/browser/textmate/monaco-theme-types.d.ts.map +1 -1
- package/lib/browser/textmate/monaco-theme-types.js +1 -0
- package/lib/browser/textmate/monaco-theme-types.js.map +1 -1
- package/lib/browser/textmate/textmate-contribution.d.ts.map +1 -1
- package/lib/browser/textmate/textmate-contribution.js +1 -0
- package/lib/browser/textmate/textmate-contribution.js.map +1 -1
- package/lib/browser/textmate/textmate-snippet-completion-provider.d.ts +1 -1
- package/lib/browser/textmate/textmate-snippet-completion-provider.d.ts.map +1 -1
- package/lib/browser/textmate/textmate-snippet-completion-provider.js +3 -1
- package/lib/browser/textmate/textmate-snippet-completion-provider.js.map +1 -1
- package/lib/browser/textmate/textmate-tokenizer.d.ts +1 -1
- package/lib/browser/textmate/textmate-tokenizer.d.ts.map +1 -1
- package/lib/browser/textmate/textmate-tokenizer.js +2 -2
- package/lib/browser/textmate/textmate-tokenizer.js.map +1 -1
- package/package.json +9 -10
- package/src/browser/monaco-bulk-edit-service.ts +9 -4
- package/src/browser/monaco-color-registry.ts +17 -14
- package/src/browser/monaco-command-service.ts +8 -7
- package/src/browser/monaco-command.ts +18 -16
- package/src/browser/monaco-context-key-service.ts +25 -16
- package/src/browser/monaco-context-menu.ts +23 -6
- package/src/browser/monaco-diagnostic-collection.ts +4 -5
- package/src/browser/monaco-diff-editor.ts +12 -14
- package/src/browser/monaco-diff-navigator-factory.ts +18 -14
- package/src/browser/monaco-editor-model.ts +56 -24
- package/src/browser/monaco-editor-provider.ts +48 -114
- package/src/browser/monaco-editor-service.ts +27 -16
- package/src/browser/monaco-editor-zone-widget.ts +6 -2
- package/src/browser/monaco-editor.ts +85 -44
- package/src/browser/monaco-formatting-conflicts.ts +10 -5
- package/src/browser/monaco-frontend-application-contribution.ts +40 -2
- package/src/browser/monaco-frontend-module.ts +18 -14
- package/src/browser/monaco-gotoline-quick-access.ts +10 -5
- package/src/browser/monaco-gotosymbol-quick-access.ts +17 -6
- package/src/browser/monaco-indexed-db.ts +1 -0
- package/src/browser/monaco-keybinding.ts +3 -2
- package/src/browser/monaco-keycode-map.ts +72 -71
- package/src/browser/monaco-languages.ts +1 -0
- package/src/browser/monaco-menu.ts +7 -7
- package/src/browser/monaco-mime-service.ts +9 -5
- package/src/browser/monaco-outline-contribution.ts +36 -32
- package/src/browser/monaco-quick-access-registry.ts +29 -19
- package/src/browser/monaco-quick-input-service.ts +102 -59
- package/src/browser/monaco-resolved-keybinding.ts +52 -28
- package/src/browser/monaco-snippet-suggest-provider.ts +5 -3
- package/src/browser/monaco-status-bar-contribution.ts +2 -1
- package/src/browser/monaco-text-model-service.ts +49 -26
- package/src/browser/monaco-theming-service.ts +1 -0
- package/src/browser/monaco-to-protocol-converter.ts +1 -0
- package/src/browser/monaco-workspace.ts +28 -19
- package/src/browser/protocol-to-monaco-converter.ts +1 -0
- package/src/browser/textmate/monaco-textmate-service.ts +15 -12
- package/src/browser/textmate/monaco-theme-registry.ts +10 -5
- package/src/browser/textmate/monaco-theme-types.ts +5 -4
- package/src/browser/textmate/textmate-contribution.ts +1 -0
- package/src/browser/textmate/textmate-snippet-completion-provider.ts +4 -1
- package/src/browser/textmate/textmate-tokenizer.ts +3 -2
- package/lib/browser/monaco-browser-module.d.ts +0 -5
- package/lib/browser/monaco-browser-module.d.ts.map +0 -1
- package/lib/browser/monaco-browser-module.js +0 -27
- package/lib/browser/monaco-browser-module.js.map +0 -1
- package/lib/browser/monaco-comparers.d.ts +0 -10
- package/lib/browser/monaco-comparers.d.ts.map +0 -1
- package/lib/browser/monaco-comparers.js +0 -109
- package/lib/browser/monaco-comparers.js.map +0 -1
- package/lib/browser/monaco-loader.d.ts +0 -4
- package/lib/browser/monaco-loader.d.ts.map +0 -1
- package/lib/browser/monaco-loader.js +0 -177
- package/lib/browser/monaco-loader.js.map +0 -1
- package/lib/electron-browser/monaco-electron-module.d.ts +0 -5
- package/lib/electron-browser/monaco-electron-module.d.ts.map +0 -1
- package/lib/electron-browser/monaco-electron-module.js +0 -50
- package/lib/electron-browser/monaco-electron-module.js.map +0 -1
- package/src/browser/monaco-browser-module.ts +0 -26
- package/src/browser/monaco-comparers.ts +0 -125
- package/src/browser/monaco-loader.ts +0 -193
- package/src/electron-browser/monaco-electron-module.ts +0 -52
- package/src/typings/monaco/index.d.ts +0 -2471
|
@@ -25,6 +25,12 @@ import { MonacoEditorService } from './monaco-editor-service';
|
|
|
25
25
|
import { MonacoTextModelService } from './monaco-text-model-service';
|
|
26
26
|
import { ProtocolToMonacoConverter } from './protocol-to-monaco-converter';
|
|
27
27
|
import { nls } from '@theia/core/lib/common/nls';
|
|
28
|
+
import { ContextKeyService as VSCodeContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/browser/contextKeyService';
|
|
29
|
+
import { EditorExtensionsRegistry } from '@theia/monaco-editor-core/esm/vs/editor/browser/editorExtensions';
|
|
30
|
+
import { CommandsRegistry, ICommandService } from '@theia/monaco-editor-core/esm/vs/platform/commands/common/commands';
|
|
31
|
+
import * as monaco from '@theia/monaco-editor-core';
|
|
32
|
+
import { EndOfLineSequence } from '@theia/monaco-editor-core/esm/vs/editor/common/model';
|
|
33
|
+
import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
28
34
|
|
|
29
35
|
export namespace MonacoCommands {
|
|
30
36
|
|
|
@@ -67,8 +73,8 @@ export class MonacoEditorCommandHandlers implements CommandContribution {
|
|
|
67
73
|
@inject(MonacoTextModelService)
|
|
68
74
|
protected readonly textModelService: MonacoTextModelService;
|
|
69
75
|
|
|
70
|
-
@inject(
|
|
71
|
-
protected readonly contextKeyService:
|
|
76
|
+
@inject(VSCodeContextKeyService)
|
|
77
|
+
protected readonly contextKeyService: VSCodeContextKeyService;
|
|
72
78
|
|
|
73
79
|
@inject(ApplicationShell)
|
|
74
80
|
protected readonly shell: ApplicationShell;
|
|
@@ -129,12 +135,11 @@ export class MonacoEditorCommandHandlers implements CommandContribution {
|
|
|
129
135
|
* and execute them using the instantiation service of the current editor.
|
|
130
136
|
*/
|
|
131
137
|
protected registerMonacoCommands(): void {
|
|
132
|
-
const
|
|
133
|
-
const editorActions = new Map(editorRegistry.getEditorActions().map(({ id, label }) => [id, label]));
|
|
138
|
+
const editorActions = new Map(EditorExtensionsRegistry.getEditorActions().map(({ id, label }) => [id, label]));
|
|
134
139
|
|
|
135
|
-
const { codeEditorService
|
|
136
|
-
const
|
|
137
|
-
const monacoCommands =
|
|
140
|
+
const { codeEditorService } = this;
|
|
141
|
+
const globalInstantiationService = StandaloneServices.initialize({});
|
|
142
|
+
const monacoCommands = CommandsRegistry.getCommands();
|
|
138
143
|
for (const id of monacoCommands.keys()) {
|
|
139
144
|
if (MonacoCommands.EXCLUDE_ACTIONS.has(id)) {
|
|
140
145
|
continue;
|
|
@@ -153,13 +158,10 @@ export class MonacoEditorCommandHandlers implements CommandContribution {
|
|
|
153
158
|
}
|
|
154
159
|
return action.run();
|
|
155
160
|
}
|
|
156
|
-
|
|
157
|
-
!(id.startsWith('_execute') || id === 'setContext' || MonacoCommands.COMMON_ACTIONS.has(id));
|
|
158
|
-
const instantiationService = editorCommand ? editor && editor['_instantiationService'] : globalInstantiationService;
|
|
159
|
-
if (!instantiationService) {
|
|
161
|
+
if (!globalInstantiationService) {
|
|
160
162
|
return;
|
|
161
163
|
}
|
|
162
|
-
return
|
|
164
|
+
return globalInstantiationService.invokeFunction(
|
|
163
165
|
monacoCommands.get(id)!.handler,
|
|
164
166
|
...args
|
|
165
167
|
);
|
|
@@ -171,7 +173,7 @@ export class MonacoEditorCommandHandlers implements CommandContribution {
|
|
|
171
173
|
const action = editor && editor.getAction(id);
|
|
172
174
|
return !!action && action.isSupported();
|
|
173
175
|
}
|
|
174
|
-
if (!!
|
|
176
|
+
if (!!EditorExtensionsRegistry.getEditorCommand(id)) {
|
|
175
177
|
return !!editor;
|
|
176
178
|
}
|
|
177
179
|
return true;
|
|
@@ -199,7 +201,7 @@ export class MonacoEditorCommandHandlers implements CommandContribution {
|
|
|
199
201
|
protected newShowReferenceHandler(): MonacoEditorCommandHandler {
|
|
200
202
|
return {
|
|
201
203
|
execute: (editor: MonacoEditor, uri: string, position: Position, locations: Location[]) => {
|
|
202
|
-
|
|
204
|
+
StandaloneServices.get(ICommandService).executeCommand(
|
|
203
205
|
'editor.action.showReferences',
|
|
204
206
|
monaco.Uri.parse(uri),
|
|
205
207
|
this.p2m.asPosition(position),
|
|
@@ -242,9 +244,9 @@ export class MonacoEditorCommandHandlers implements CommandContribution {
|
|
|
242
244
|
const model = editor.document && editor.document.textEditorModel;
|
|
243
245
|
if (model) {
|
|
244
246
|
if (lineEnding === 'CRLF' || lineEnding === '\r\n') {
|
|
245
|
-
model.pushEOL(
|
|
247
|
+
model.pushEOL(EndOfLineSequence.CRLF);
|
|
246
248
|
} else {
|
|
247
|
-
model.pushEOL(
|
|
249
|
+
model.pushEOL(EndOfLineSequence.LF);
|
|
248
250
|
}
|
|
249
251
|
}
|
|
250
252
|
}
|
|
@@ -15,16 +15,18 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
18
|
-
import { ContextKeyService, ContextKey, ContextKeyChangeEvent, ScopedValueStore } from '@theia/core/lib/browser/context-key-service';
|
|
18
|
+
import { ContextKeyService as TheiaContextKeyService, ContextKey, ContextKeyChangeEvent, ScopedValueStore } from '@theia/core/lib/browser/context-key-service';
|
|
19
19
|
import { Emitter } from '@theia/core';
|
|
20
|
+
import { AbstractContextKeyService, ContextKeyService as VSCodeContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/browser/contextKeyService';
|
|
21
|
+
import { ContextKeyExpr, ContextKeyExpression, IContext } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
|
|
20
22
|
|
|
21
23
|
@injectable()
|
|
22
|
-
export class MonacoContextKeyService implements
|
|
24
|
+
export class MonacoContextKeyService implements TheiaContextKeyService {
|
|
23
25
|
protected readonly onDidChangeEmitter = new Emitter<ContextKeyChangeEvent>();
|
|
24
26
|
readonly onDidChange = this.onDidChangeEmitter.event;
|
|
25
27
|
|
|
26
|
-
@inject(
|
|
27
|
-
protected readonly contextKeyService:
|
|
28
|
+
@inject(VSCodeContextKeyService)
|
|
29
|
+
protected readonly contextKeyService: VSCodeContextKeyService;
|
|
28
30
|
|
|
29
31
|
@postConstruct()
|
|
30
32
|
protected init(): void {
|
|
@@ -39,18 +41,21 @@ export class MonacoContextKeyService implements ContextKeyService {
|
|
|
39
41
|
return this.contextKeyService.createKey(key, defaultValue);
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
activeContext?: HTMLElement |
|
|
44
|
+
activeContext?: HTMLElement | IContext;
|
|
43
45
|
|
|
44
46
|
match(expression: string, context?: HTMLElement): boolean {
|
|
45
47
|
const parsed = this.parse(expression);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
if (parsed) {
|
|
49
|
+
const ctx = this.identifyContext(context);
|
|
50
|
+
if (!ctx) {
|
|
51
|
+
return this.contextKeyService.contextMatchesRules(parsed);
|
|
52
|
+
}
|
|
53
|
+
return parsed.evaluate(ctx);
|
|
49
54
|
}
|
|
50
|
-
return
|
|
55
|
+
return true;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
|
-
protected identifyContext(callersContext?: HTMLElement |
|
|
58
|
+
protected identifyContext(callersContext?: HTMLElement | IContext): IContext | undefined {
|
|
54
59
|
if (callersContext && 'getValue' in callersContext) {
|
|
55
60
|
return callersContext;
|
|
56
61
|
} else if (this.activeContext && 'getValue' in this.activeContext) {
|
|
@@ -63,11 +68,11 @@ export class MonacoContextKeyService implements ContextKeyService {
|
|
|
63
68
|
return undefined;
|
|
64
69
|
}
|
|
65
70
|
|
|
66
|
-
protected readonly expressions = new Map<string,
|
|
67
|
-
protected parse(when: string):
|
|
71
|
+
protected readonly expressions = new Map<string, ContextKeyExpression>();
|
|
72
|
+
protected parse(when: string): ContextKeyExpression | undefined {
|
|
68
73
|
let expression = this.expressions.get(when);
|
|
69
74
|
if (!expression) {
|
|
70
|
-
expression =
|
|
75
|
+
expression = ContextKeyExpr.deserialize(when);
|
|
71
76
|
if (expression) {
|
|
72
77
|
this.expressions.set(when, expression);
|
|
73
78
|
}
|
|
@@ -76,7 +81,7 @@ export class MonacoContextKeyService implements ContextKeyService {
|
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
parseKeys(expression: string): Set<string> | undefined {
|
|
79
|
-
const expr =
|
|
84
|
+
const expr = ContextKeyExpr.deserialize(expression);
|
|
80
85
|
return expr ? new Set<string>(expr.keys()) : expr;
|
|
81
86
|
}
|
|
82
87
|
|
|
@@ -96,8 +101,12 @@ export class MonacoContextKeyService implements ContextKeyService {
|
|
|
96
101
|
}
|
|
97
102
|
}
|
|
98
103
|
|
|
99
|
-
createScoped(target
|
|
100
|
-
|
|
104
|
+
createScoped(target: HTMLElement): ScopedValueStore {
|
|
105
|
+
const scoped = this.contextKeyService.createScoped(target);
|
|
106
|
+
if (scoped instanceof AbstractContextKeyService) {
|
|
107
|
+
return scoped as AbstractContextKeyService & { createScoped(): ScopedValueStore };
|
|
108
|
+
}
|
|
109
|
+
return this;
|
|
101
110
|
}
|
|
102
111
|
|
|
103
112
|
setContext(key: string, value: unknown): void {
|
|
@@ -18,13 +18,25 @@ import { injectable, inject } from '@theia/core/shared/inversify';
|
|
|
18
18
|
import { MenuPath } from '@theia/core/lib/common/menu';
|
|
19
19
|
import { EDITOR_CONTEXT_MENU } from '@theia/editor/lib/browser';
|
|
20
20
|
import { ContextMenuRenderer, toAnchor } from '@theia/core/lib/browser';
|
|
21
|
-
import IContextMenuService = monaco.editor.IContextMenuService;
|
|
22
|
-
import IContextMenuDelegate = monaco.editor.IContextMenuDelegate;
|
|
23
21
|
import { Menu } from '@theia/core/shared/@phosphor/widgets';
|
|
24
22
|
import { CommandRegistry } from '@theia/core/shared/@phosphor/commands';
|
|
23
|
+
import { IContextMenuService } from '@theia/monaco-editor-core/esm/vs/platform/contextview/browser/contextView';
|
|
24
|
+
import { IContextMenuDelegate } from '@theia/monaco-editor-core/esm/vs/base/browser/contextmenu';
|
|
25
|
+
import { MenuItemAction } from '@theia/monaco-editor-core/esm/vs/platform/actions/common/actions';
|
|
26
|
+
import { Event, Emitter } from '@theia/monaco-editor-core/esm/vs/base/common/event';
|
|
25
27
|
|
|
26
28
|
@injectable()
|
|
27
29
|
export class MonacoContextMenuService implements IContextMenuService {
|
|
30
|
+
declare readonly _serviceBrand: undefined;
|
|
31
|
+
|
|
32
|
+
protected readonly onDidShowContextMenuEmitter = new Emitter<void>();
|
|
33
|
+
get onDidShowContextMenu(): Event<void> {
|
|
34
|
+
return this.onDidShowContextMenuEmitter.event;
|
|
35
|
+
};
|
|
36
|
+
protected readonly onDidHideContextMenuEmitter = new Emitter<void>();
|
|
37
|
+
get onDidHideContextMenu(): Event<void> {
|
|
38
|
+
return this.onDidShowContextMenuEmitter.event;
|
|
39
|
+
};
|
|
28
40
|
|
|
29
41
|
constructor(@inject(ContextMenuRenderer) protected readonly contextMenuRenderer: ContextMenuRenderer) {
|
|
30
42
|
}
|
|
@@ -32,14 +44,18 @@ export class MonacoContextMenuService implements IContextMenuService {
|
|
|
32
44
|
showContextMenu(delegate: IContextMenuDelegate): void {
|
|
33
45
|
const anchor = toAnchor(delegate.getAnchor());
|
|
34
46
|
const actions = delegate.getActions();
|
|
47
|
+
const onHide = () => {
|
|
48
|
+
delegate.onHide?.(false);
|
|
49
|
+
this.onDidHideContextMenuEmitter.fire();
|
|
50
|
+
};
|
|
35
51
|
|
|
36
52
|
// Actions for editor context menu come as 'MenuItemAction' items
|
|
37
53
|
// In case of 'Quick Fix' actions come as 'CodeActionAction' items
|
|
38
|
-
if (actions.length > 0 && actions[0] instanceof
|
|
54
|
+
if (actions.length > 0 && actions[0] instanceof MenuItemAction) {
|
|
39
55
|
this.contextMenuRenderer.render({
|
|
40
56
|
menuPath: this.menuPath(),
|
|
41
57
|
anchor,
|
|
42
|
-
onHide
|
|
58
|
+
onHide
|
|
43
59
|
});
|
|
44
60
|
} else {
|
|
45
61
|
const commands = new CommandRegistry();
|
|
@@ -52,7 +68,7 @@ export class MonacoContextMenuService implements IContextMenuService {
|
|
|
52
68
|
commands.addCommand(commandId, {
|
|
53
69
|
label: action.label,
|
|
54
70
|
className: action.class,
|
|
55
|
-
isToggled: () => action.checked,
|
|
71
|
+
isToggled: () => Boolean(action.checked),
|
|
56
72
|
isEnabled: () => action.enabled,
|
|
57
73
|
execute: () => action.run()
|
|
58
74
|
});
|
|
@@ -61,9 +77,10 @@ export class MonacoContextMenuService implements IContextMenuService {
|
|
|
61
77
|
command: commandId
|
|
62
78
|
});
|
|
63
79
|
}
|
|
64
|
-
menu.aboutToClose.connect(() =>
|
|
80
|
+
menu.aboutToClose.connect(() => onHide);
|
|
65
81
|
menu.open(anchor.x, anchor.y);
|
|
66
82
|
}
|
|
83
|
+
this.onDidShowContextMenuEmitter.fire();
|
|
67
84
|
}
|
|
68
85
|
|
|
69
86
|
protected menuPath(): MenuPath {
|
|
@@ -17,8 +17,7 @@
|
|
|
17
17
|
import { Diagnostic } from '@theia/core/shared/vscode-languageserver-protocol';
|
|
18
18
|
import { DisposableCollection, Disposable } from '@theia/core/lib/common/disposable';
|
|
19
19
|
import { ProtocolToMonacoConverter } from './protocol-to-monaco-converter';
|
|
20
|
-
import
|
|
21
|
-
import IMarkerData = monaco.editor.IMarkerData;
|
|
20
|
+
import * as monaco from '@theia/monaco-editor-core';
|
|
22
21
|
|
|
23
22
|
export class MonacoDiagnosticCollection implements Disposable {
|
|
24
23
|
|
|
@@ -57,7 +56,7 @@ export class MonacoDiagnosticCollection implements Disposable {
|
|
|
57
56
|
|
|
58
57
|
export class MonacoModelDiagnostics implements Disposable {
|
|
59
58
|
readonly uri: monaco.Uri;
|
|
60
|
-
protected _markers: IMarkerData[] = [];
|
|
59
|
+
protected _markers: monaco.editor.IMarkerData[] = [];
|
|
61
60
|
protected _diagnostics: Diagnostic[] = [];
|
|
62
61
|
constructor(
|
|
63
62
|
uri: string,
|
|
@@ -80,7 +79,7 @@ export class MonacoModelDiagnostics implements Disposable {
|
|
|
80
79
|
return this._diagnostics;
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
get markers(): ReadonlyArray<IMarkerData> {
|
|
82
|
+
get markers(): ReadonlyArray<monaco.editor.IMarkerData> {
|
|
84
83
|
return this._markers;
|
|
85
84
|
}
|
|
86
85
|
|
|
@@ -94,7 +93,7 @@ export class MonacoModelDiagnostics implements Disposable {
|
|
|
94
93
|
this.doUpdateModelMarkers(model ? model : undefined);
|
|
95
94
|
}
|
|
96
95
|
|
|
97
|
-
protected doUpdateModelMarkers(model:
|
|
96
|
+
protected doUpdateModelMarkers(model: monaco.editor.ITextModel | undefined): void {
|
|
98
97
|
if (model && this.uri.toString() === model.uri.toString()) {
|
|
99
98
|
monaco.editor.setModelMarkers(model, this.owner, this._markers);
|
|
100
99
|
}
|
|
@@ -18,14 +18,13 @@ import URI from '@theia/core/lib/common/uri';
|
|
|
18
18
|
import { Disposable } from '@theia/core/lib/common';
|
|
19
19
|
import { Dimension, DiffNavigator, DeltaDecorationParams } from '@theia/editor/lib/browser';
|
|
20
20
|
import { MonacoEditorModel } from './monaco-editor-model';
|
|
21
|
-
import { MonacoEditor, MonacoEditorServices } from './monaco-editor';
|
|
21
|
+
import { EditorServiceOverrides, MonacoEditor, MonacoEditorServices } from './monaco-editor';
|
|
22
22
|
import { MonacoDiffNavigatorFactory } from './monaco-diff-navigator-factory';
|
|
23
23
|
import { DiffUris } from '@theia/core/lib/browser/diff-uris';
|
|
24
|
-
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import IEditorOverrideServices = monaco.editor.IEditorOverrideServices;
|
|
24
|
+
import * as monaco from '@theia/monaco-editor-core';
|
|
25
|
+
import { IDiffEditorConstructionOptions } from '@theia/monaco-editor-core/esm/vs/editor/browser/editorBrowser';
|
|
26
|
+
import { IDiffNavigatorOptions } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneEditor';
|
|
27
|
+
import { StandaloneDiffEditor } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneCodeEditor';
|
|
29
28
|
|
|
30
29
|
export namespace MonacoDiffEditor {
|
|
31
30
|
export interface IOptions extends MonacoEditor.ICommonOptions, IDiffEditorConstructionOptions, IDiffNavigatorOptions {
|
|
@@ -33,7 +32,7 @@ export namespace MonacoDiffEditor {
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
export class MonacoDiffEditor extends MonacoEditor {
|
|
36
|
-
protected _diffEditor: IStandaloneDiffEditor;
|
|
35
|
+
protected _diffEditor: monaco.editor.IStandaloneDiffEditor;
|
|
37
36
|
protected _diffNavigator: DiffNavigator;
|
|
38
37
|
|
|
39
38
|
constructor(
|
|
@@ -44,7 +43,7 @@ export class MonacoDiffEditor extends MonacoEditor {
|
|
|
44
43
|
services: MonacoEditorServices,
|
|
45
44
|
protected readonly diffNavigatorFactory: MonacoDiffNavigatorFactory,
|
|
46
45
|
options?: MonacoDiffEditor.IOptions,
|
|
47
|
-
override?:
|
|
46
|
+
override?: EditorServiceOverrides,
|
|
48
47
|
) {
|
|
49
48
|
super(uri, modifiedModel, node, services, options, override);
|
|
50
49
|
this.documents.add(originalModel);
|
|
@@ -54,7 +53,7 @@ export class MonacoDiffEditor extends MonacoEditor {
|
|
|
54
53
|
this._diffEditor.setModel({ original, modified });
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
get diffEditor(): IStandaloneDiffEditor {
|
|
56
|
+
get diffEditor(): monaco.editor.IStandaloneDiffEditor {
|
|
58
57
|
return this._diffEditor;
|
|
59
58
|
}
|
|
60
59
|
|
|
@@ -62,11 +61,10 @@ export class MonacoDiffEditor extends MonacoEditor {
|
|
|
62
61
|
return this._diffNavigator;
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
protected override create(options?: IDiffEditorConstructionOptions, override?:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
fixedOverflowWidgets: true
|
|
69
|
-
}, override);
|
|
64
|
+
protected override create(options?: IDiffEditorConstructionOptions, override?: EditorServiceOverrides): Disposable {
|
|
65
|
+
const instantiator = this.getInstantiatorWithOverrides(override);
|
|
66
|
+
this._diffEditor = instantiator
|
|
67
|
+
.createInstance(StandaloneDiffEditor, this.node, { ...options, fixedOverflowWidgets: true }) as unknown as monaco.editor.IStandaloneDiffEditor;
|
|
70
68
|
this.editor = this._diffEditor.getModifiedEditor();
|
|
71
69
|
return this._diffEditor;
|
|
72
70
|
}
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
|
|
17
17
|
import { injectable } from '@theia/core/shared/inversify';
|
|
18
18
|
import { DiffNavigator } from '@theia/editor/lib/browser';
|
|
19
|
-
|
|
20
|
-
import
|
|
21
|
-
import
|
|
19
|
+
import * as monaco from '@theia/monaco-editor-core';
|
|
20
|
+
import { DiffNavigator as MonacoDiffNavigator } from '@theia/monaco-editor-core/esm/vs/editor/browser/widget/diffNavigator';
|
|
21
|
+
import { IStandaloneDiffEditor } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneCodeEditor';
|
|
22
22
|
|
|
23
23
|
@injectable()
|
|
24
24
|
export class MonacoDiffNavigatorFactory {
|
|
@@ -29,29 +29,33 @@ export class MonacoDiffNavigatorFactory {
|
|
|
29
29
|
hasPrevious: () => false,
|
|
30
30
|
next: () => { },
|
|
31
31
|
previous: () => { },
|
|
32
|
-
revealFirst: false,
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
createdDiffNavigator(editor: IStandaloneDiffEditor, options?: IDiffNavigatorOptions): DiffNavigator {
|
|
36
|
-
const navigator =
|
|
34
|
+
createdDiffNavigator(editor: IStandaloneDiffEditor | monaco.editor.IStandaloneDiffEditor, options?: monaco.editor.IDiffNavigatorOptions): DiffNavigator {
|
|
35
|
+
const navigator = new MonacoDiffNavigator(editor as IStandaloneDiffEditor, options);
|
|
37
36
|
const ensureInitialized = (fwd: boolean) => {
|
|
38
|
-
if (navigator
|
|
39
|
-
navigator
|
|
37
|
+
if (navigator['nextIdx'] < 0) {
|
|
38
|
+
navigator['_initIdx'](fwd);
|
|
40
39
|
}
|
|
41
40
|
};
|
|
42
|
-
return
|
|
41
|
+
return {
|
|
43
42
|
canNavigate: () => navigator.canNavigate(),
|
|
44
43
|
hasNext: () => {
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
if (navigator.canNavigate()) {
|
|
45
|
+
ensureInitialized(true);
|
|
46
|
+
return navigator['nextIdx'] + 1 < navigator['ranges'].length;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
47
49
|
},
|
|
48
50
|
hasPrevious: () => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
if (navigator.canNavigate()) {
|
|
52
|
+
ensureInitialized(false);
|
|
53
|
+
return navigator['nextIdx'] > 0;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
51
56
|
},
|
|
52
57
|
next: () => navigator.next(),
|
|
53
58
|
previous: () => navigator.previous(),
|
|
54
|
-
revealFirst: navigator.revealFirst,
|
|
55
59
|
};
|
|
56
60
|
}
|
|
57
61
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { Position, Range, TextDocumentSaveReason, TextDocumentContentChangeEvent } from '@theia/core/shared/vscode-languageserver-protocol';
|
|
18
|
-
import { TextEditorDocument, EncodingMode, FindMatchesOptions, FindMatch, EditorPreferences
|
|
18
|
+
import { TextEditorDocument, EncodingMode, FindMatchesOptions, FindMatch, EditorPreferences } from '@theia/editor/lib/browser';
|
|
19
19
|
import { DisposableCollection, Disposable } from '@theia/core/lib/common/disposable';
|
|
20
20
|
import { Emitter, Event } from '@theia/core/lib/common/event';
|
|
21
21
|
import { CancellationTokenSource, CancellationToken } from '@theia/core/lib/common/cancellation';
|
|
@@ -24,18 +24,24 @@ import { Saveable, SaveOptions } from '@theia/core/lib/browser/saveable';
|
|
|
24
24
|
import { MonacoToProtocolConverter } from './monaco-to-protocol-converter';
|
|
25
25
|
import { ProtocolToMonacoConverter } from './protocol-to-monaco-converter';
|
|
26
26
|
import { ILogger, Loggable, Log } from '@theia/core/lib/common/logger';
|
|
27
|
+
import { IIdentifiedSingleEditOperation, ITextBufferFactory, ITextModel, ITextSnapshot } from '@theia/monaco-editor-core/esm/vs/editor/common/model';
|
|
28
|
+
import { IResolvedTextEditorModel } from '@theia/monaco-editor-core/esm/vs/editor/common/services/resolverService';
|
|
29
|
+
import * as monaco from '@theia/monaco-editor-core';
|
|
30
|
+
import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
31
|
+
import { ILanguageService } from '@theia/monaco-editor-core/esm/vs/editor/common/languages/language';
|
|
32
|
+
import { IModelService } from '@theia/monaco-editor-core/esm/vs/editor/common/services/model';
|
|
33
|
+
import { createTextBufferFactoryFromStream } from '@theia/monaco-editor-core/esm/vs/editor/common/model/textModel';
|
|
34
|
+
import { editorGeneratedPreferenceProperties } from '@theia/editor/lib/browser/editor-generated-preference-schema';
|
|
27
35
|
|
|
28
36
|
export {
|
|
29
37
|
TextDocumentSaveReason
|
|
30
38
|
};
|
|
31
39
|
|
|
32
|
-
type ITextEditorModel = monaco.editor.ITextEditorModel;
|
|
33
|
-
|
|
34
40
|
export interface WillSaveMonacoModelEvent {
|
|
35
41
|
readonly model: MonacoEditorModel;
|
|
36
42
|
readonly reason: TextDocumentSaveReason;
|
|
37
43
|
readonly options?: SaveOptions;
|
|
38
|
-
waitUntil(thenable: Thenable<
|
|
44
|
+
waitUntil(thenable: Thenable<IIdentifiedSingleEditOperation[]>): void;
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
export interface MonacoModelContentChangedEvent {
|
|
@@ -43,10 +49,10 @@ export interface MonacoModelContentChangedEvent {
|
|
|
43
49
|
readonly contentChanges: TextDocumentContentChangeEvent[];
|
|
44
50
|
}
|
|
45
51
|
|
|
46
|
-
export class MonacoEditorModel implements
|
|
52
|
+
export class MonacoEditorModel implements IResolvedTextEditorModel, TextEditorDocument {
|
|
47
53
|
|
|
48
|
-
autoSave: '
|
|
49
|
-
autoSaveDelay
|
|
54
|
+
autoSave: EditorPreferences['files.autoSave'] = 'afterDelay';
|
|
55
|
+
autoSaveDelay = 500;
|
|
50
56
|
suppressOpenEditorWhenDirty = false;
|
|
51
57
|
lineNumbersMinChars = 3;
|
|
52
58
|
|
|
@@ -54,7 +60,7 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument {
|
|
|
54
60
|
readonly onWillSaveLoopTimeOut = 1500;
|
|
55
61
|
protected bufferSavedVersionId: number;
|
|
56
62
|
|
|
57
|
-
protected model:
|
|
63
|
+
protected model: ITextModel;
|
|
58
64
|
protected readonly resolveModel: Promise<void>;
|
|
59
65
|
|
|
60
66
|
protected readonly toDispose = new DisposableCollection();
|
|
@@ -63,7 +69,7 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument {
|
|
|
63
69
|
protected readonly onDidChangeContentEmitter = new Emitter<MonacoModelContentChangedEvent>();
|
|
64
70
|
readonly onDidChangeContent = this.onDidChangeContentEmitter.event;
|
|
65
71
|
|
|
66
|
-
protected readonly onDidSaveModelEmitter = new Emitter<
|
|
72
|
+
protected readonly onDidSaveModelEmitter = new Emitter<ITextModel>();
|
|
67
73
|
readonly onDidSaveModel = this.onDidSaveModelEmitter.event;
|
|
68
74
|
|
|
69
75
|
protected readonly onWillSaveModelEmitter = new Emitter<WillSaveMonacoModelEvent>();
|
|
@@ -105,6 +111,18 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument {
|
|
|
105
111
|
this.toDispose.dispose();
|
|
106
112
|
}
|
|
107
113
|
|
|
114
|
+
isDisposed(): boolean {
|
|
115
|
+
return this.toDispose.disposed;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
resolve(): Promise<void> {
|
|
119
|
+
return this.resolveModel;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
isResolved(): boolean {
|
|
123
|
+
return Boolean(this.model);
|
|
124
|
+
}
|
|
125
|
+
|
|
108
126
|
setEncoding(encoding: string, mode: EncodingMode): Promise<void> {
|
|
109
127
|
if (mode === EncodingMode.Decode && this.dirty) {
|
|
110
128
|
return Promise.resolve();
|
|
@@ -147,7 +165,7 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument {
|
|
|
147
165
|
* Only this method can create an instance of `monaco.editor.IModel`,
|
|
148
166
|
* there should not be other calls to `monaco.editor.createModel`.
|
|
149
167
|
*/
|
|
150
|
-
protected initialize(value: string |
|
|
168
|
+
protected initialize(value: string | ITextBufferFactory): void {
|
|
151
169
|
if (!this.toDispose.disposed) {
|
|
152
170
|
const uri = monaco.Uri.parse(this.resource.uri.toString());
|
|
153
171
|
let firstLine;
|
|
@@ -160,8 +178,8 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument {
|
|
|
160
178
|
} else {
|
|
161
179
|
firstLine = value.getFirstLineText(1000);
|
|
162
180
|
}
|
|
163
|
-
const languageSelection =
|
|
164
|
-
this.model =
|
|
181
|
+
const languageSelection = StandaloneServices.get(ILanguageService).createByFilepathOrFirstLine(uri, firstLine);
|
|
182
|
+
this.model = StandaloneServices.get(IModelService).createModel(value, languageSelection, uri);
|
|
165
183
|
this.resourceVersion = this.resource.version;
|
|
166
184
|
this.updateSavedVersionId();
|
|
167
185
|
this.toDispose.push(this.model);
|
|
@@ -221,10 +239,15 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument {
|
|
|
221
239
|
|
|
222
240
|
protected _languageId: string | undefined;
|
|
223
241
|
get languageId(): string {
|
|
224
|
-
return this._languageId !== undefined ? this._languageId : this.model.
|
|
242
|
+
return this._languageId !== undefined ? this._languageId : this.model.getLanguageId();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
getLanguageId(): string | undefined {
|
|
246
|
+
return this.languageId;
|
|
225
247
|
}
|
|
248
|
+
|
|
226
249
|
/**
|
|
227
|
-
* It's a hack to dispatch close notification with an old language id
|
|
250
|
+
* It's a hack to dispatch close notification with an old language id; don't use it.
|
|
228
251
|
*/
|
|
229
252
|
setLanguageId(languageId: string | undefined): void {
|
|
230
253
|
this._languageId = languageId;
|
|
@@ -273,11 +296,22 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument {
|
|
|
273
296
|
return this.resource.saveContents === undefined;
|
|
274
297
|
}
|
|
275
298
|
|
|
299
|
+
isReadonly(): boolean {
|
|
300
|
+
return this.readOnly;
|
|
301
|
+
}
|
|
302
|
+
|
|
276
303
|
get onDispose(): monaco.IEvent<void> {
|
|
277
304
|
return this.toDispose.onDispose;
|
|
278
305
|
}
|
|
279
306
|
|
|
280
|
-
get
|
|
307
|
+
get onWillDispose(): Event<void> {
|
|
308
|
+
return this.toDispose.onDispose;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// We have a TypeScript problem here. There is a const enum `DefaultEndOfLine` used for ITextModel and a non-const redeclaration of that enum in the public API in
|
|
312
|
+
// Monaco.editor. The values will be the same, but TS won't accept that the two enums are equivalent, so it says these types are irreconcilable.
|
|
313
|
+
get textEditorModel(): monaco.editor.ITextModel & ITextModel {
|
|
314
|
+
// @ts-expect-error ts(2322)
|
|
281
315
|
return this.model;
|
|
282
316
|
}
|
|
283
317
|
|
|
@@ -288,7 +322,7 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument {
|
|
|
288
322
|
* @returns the list of matches.
|
|
289
323
|
*/
|
|
290
324
|
findMatches(options: FindMatchesOptions): FindMatch[] {
|
|
291
|
-
const wordSeparators = this.editorPreferences
|
|
325
|
+
const wordSeparators = this.editorPreferences?.['editor.wordSeparators'] ?? editorGeneratedPreferenceProperties['editor.wordSeparators'].default as string;
|
|
292
326
|
const results: monaco.editor.FindMatch[] = this.model.findMatches(
|
|
293
327
|
options.searchString,
|
|
294
328
|
false,
|
|
@@ -368,13 +402,13 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument {
|
|
|
368
402
|
}
|
|
369
403
|
|
|
370
404
|
this.resourceVersion = this.resource.version;
|
|
371
|
-
this.updateModel(() =>
|
|
405
|
+
this.updateModel(() => StandaloneServices.get(IModelService).updateModel(this.model, value), {
|
|
372
406
|
ignoreDirty: true,
|
|
373
407
|
ignoreContentChanges: true
|
|
374
408
|
});
|
|
375
409
|
this.trace(log => log('MonacoEditorModel.doSync - exit'));
|
|
376
410
|
}
|
|
377
|
-
protected async readContents(): Promise<string |
|
|
411
|
+
protected async readContents(): Promise<string | ITextBufferFactory | undefined> {
|
|
378
412
|
try {
|
|
379
413
|
const options = { encoding: this.getEncoding() };
|
|
380
414
|
const content = await (this.resource.readStream ? this.resource.readStream(options) : this.resource.readContents(options));
|
|
@@ -382,7 +416,7 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument {
|
|
|
382
416
|
if (typeof content === 'string') {
|
|
383
417
|
value = content;
|
|
384
418
|
} else {
|
|
385
|
-
value =
|
|
419
|
+
value = createTextBufferFactoryFromStream(content);
|
|
386
420
|
}
|
|
387
421
|
this.updateContentEncoding();
|
|
388
422
|
this.setValid(true);
|
|
@@ -410,7 +444,7 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument {
|
|
|
410
444
|
}
|
|
411
445
|
|
|
412
446
|
protected doAutoSave(): void {
|
|
413
|
-
if (this.autoSave
|
|
447
|
+
if (this.autoSave !== 'off') {
|
|
414
448
|
const token = this.cancelSave();
|
|
415
449
|
this.toDisposeOnAutoSave.dispose();
|
|
416
450
|
const handle = window.setTimeout(() => {
|
|
@@ -611,10 +645,8 @@ export class MonacoEditorModel implements ITextEditorModel, TextEditorDocument {
|
|
|
611
645
|
this.trace(log => log('MonacoEditorModel.revert - exit'));
|
|
612
646
|
}
|
|
613
647
|
|
|
614
|
-
createSnapshot():
|
|
615
|
-
return
|
|
616
|
-
value: this.getText()
|
|
617
|
-
};
|
|
648
|
+
createSnapshot(preserveBOM?: boolean): ITextSnapshot {
|
|
649
|
+
return this.model.createSnapshot(preserveBOM);
|
|
618
650
|
}
|
|
619
651
|
|
|
620
652
|
applySnapshot(snapshot: { value: string }): void {
|