@theia/monaco 1.34.1 → 1.34.3
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/LICENSE +641 -641
- 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 +392 -392
- 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 +24 -24
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.js +137 -137
- package/lib/browser/monaco-bulk-edit-service.d.ts +14 -14
- package/lib/browser/monaco-bulk-edit-service.js +66 -66
- 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.js +82 -82
- package/lib/browser/monaco-command-service.d.ts +26 -26
- package/lib/browser/monaco-command-service.js +92 -92
- package/lib/browser/monaco-command.d.ts +94 -94
- package/lib/browser/monaco-command.js +306 -306
- package/lib/browser/monaco-context-key-service.d.ts +22 -22
- package/lib/browser/monaco-context-key-service.js +147 -147
- package/lib/browser/monaco-context-menu.d.ts +16 -16
- package/lib/browser/monaco-context-menu.js +102 -102
- package/lib/browser/monaco-diagnostic-collection.d.ts +28 -28
- package/lib/browser/monaco-diagnostic-collection.js +86 -86
- package/lib/browser/monaco-diff-editor.d.ts +29 -29
- package/lib/browser/monaco-diff-editor.js +74 -74
- package/lib/browser/monaco-diff-navigator-factory.d.ts +7 -7
- package/lib/browser/monaco-diff-navigator-factory.js +66 -66
- package/lib/browser/monaco-editor-model.d.ts +156 -156
- package/lib/browser/monaco-editor-model.js +555 -555
- package/lib/browser/monaco-editor-provider.d.ts +89 -89
- package/lib/browser/monaco-editor-provider.js +440 -440
- package/lib/browser/monaco-editor-service.d.ts +27 -27
- package/lib/browser/monaco-editor-service.js +151 -151
- 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 +151 -151
- package/lib/browser/monaco-editor.js +497 -497
- package/lib/browser/monaco-formatting-conflicts.d.ts +13 -13
- package/lib/browser/monaco-formatting-conflicts.js +110 -110
- package/lib/browser/monaco-frontend-application-contribution.d.ts +26 -26
- package/lib/browser/monaco-frontend-application-contribution.js +201 -201
- package/lib/browser/monaco-frontend-module.d.ts +7 -7
- package/lib/browser/monaco-frontend-module.js +266 -266
- 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-indexed-db.d.ts +28 -28
- package/lib/browser/monaco-indexed-db.js +131 -131
- package/lib/browser/monaco-keybinding-contexts.d.ts +15 -15
- package/lib/browser/monaco-keybinding-contexts.js +50 -50
- package/lib/browser/monaco-keybinding.d.ts +16 -16
- package/lib/browser/monaco-keybinding.js +134 -134
- package/lib/browser/monaco-keycode-map.d.ts +2 -2
- package/lib/browser/monaco-keycode-map.js +163 -163
- package/lib/browser/monaco-languages.d.ts +27 -27
- package/lib/browser/monaco-languages.js +136 -136
- 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 -99
- package/lib/browser/monaco-quick-input-service.js +555 -555
- package/lib/browser/monaco-resolved-keybinding.d.ts +23 -23
- package/lib/browser/monaco-resolved-keybinding.js +131 -131
- package/lib/browser/monaco-snippet-suggest-provider.d.ts +64 -64
- package/lib/browser/monaco-snippet-suggest-provider.js +269 -269
- package/lib/browser/monaco-status-bar-contribution.d.ts +17 -17
- package/lib/browser/monaco-status-bar-contribution.js +120 -120
- package/lib/browser/monaco-text-model-service.d.ts +51 -51
- package/lib/browser/monaco-text-model-service.js +184 -184
- 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 -83
- package/lib/browser/monaco-workspace.js +369 -369
- package/lib/browser/protocol-to-monaco-converter.d.ts +31 -31
- package/lib/browser/protocol-to-monaco-converter.js +133 -133
- 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 +12 -12
- package/lib/browser/textmate/monaco-textmate-frontend-bindings.js +94 -94
- 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-theme-registry.d.ts +27 -27
- package/lib/browser/textmate/monaco-theme-registry.js +171 -171
- 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 +8 -8
- package/src/browser/index.ts +17 -17
- package/src/browser/markdown-renderer/monaco-markdown-renderer.ts +117 -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 +82 -82
- package/src/browser/monaco-command-service.ts +99 -99
- package/src/browser/monaco-command.ts +311 -311
- package/src/browser/monaco-context-key-service.ts +143 -143
- package/src/browser/monaco-context-menu.ts +90 -90
- package/src/browser/monaco-diagnostic-collection.ts +101 -101
- package/src/browser/monaco-diff-editor.ts +101 -101
- package/src/browser/monaco-diff-navigator-factory.ts +61 -61
- package/src/browser/monaco-editor-model.ts +681 -681
- package/src/browser/monaco-editor-provider.ts +452 -452
- package/src/browser/monaco-editor-service.ts +144 -144
- package/src/browser/monaco-editor-zone-widget.ts +250 -250
- package/src/browser/monaco-editor.ts +644 -644
- package/src/browser/monaco-formatting-conflicts.ts +115 -115
- package/src/browser/monaco-frontend-application-contribution.ts +188 -188
- package/src/browser/monaco-frontend-module.ts +314 -314
- package/src/browser/monaco-gotoline-quick-access.ts +47 -47
- package/src/browser/monaco-gotosymbol-quick-access.ts +53 -53
- package/src/browser/monaco-indexed-db.ts +130 -130
- package/src/browser/monaco-keybinding-contexts.ts +43 -43
- package/src/browser/monaco-keybinding.ts +111 -111
- package/src/browser/monaco-keycode-map.ts +171 -171
- package/src/browser/monaco-languages.ts +129 -129
- 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 +651 -651
- package/src/browser/monaco-resolved-keybinding.ts +162 -162
- package/src/browser/monaco-snippet-suggest-provider.ts +300 -300
- package/src/browser/monaco-status-bar-contribution.ts +109 -109
- package/src/browser/monaco-text-model-service.ts +194 -194
- 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 +393 -393
- package/src/browser/protocol-to-monaco-converter.ts +158 -158
- package/src/browser/style/index.css +267 -267
- package/src/browser/textmate/index.ts +20 -20
- package/src/browser/textmate/monaco-textmate-frontend-bindings.ts +94 -94
- 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,115 +1,115 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2020 Red Hat, Inc. 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 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
-
import { PreferenceService, FrontendApplicationContribution, PreferenceLanguageOverrideService } from '@theia/core/lib/browser';
|
|
19
|
-
import { EditorManager } from '@theia/editor/lib/browser';
|
|
20
|
-
import { MonacoQuickInputService } from './monaco-quick-input-service';
|
|
21
|
-
import * as monaco from '@theia/monaco-editor-core';
|
|
22
|
-
import { FormattingConflicts, FormattingMode } from '@theia/monaco-editor-core/esm/vs/editor/contrib/format/browser/format';
|
|
23
|
-
import { DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider } from '@theia/monaco-editor-core/esm/vs/editor/common/languages';
|
|
24
|
-
import { ITextModel } from '@theia/monaco-editor-core/esm/vs/editor/common/model';
|
|
25
|
-
|
|
26
|
-
type FormattingEditProvider = DocumentFormattingEditProvider | DocumentRangeFormattingEditProvider;
|
|
27
|
-
|
|
28
|
-
const PREFERENCE_NAME = 'editor.defaultFormatter';
|
|
29
|
-
|
|
30
|
-
@injectable()
|
|
31
|
-
export class MonacoFormattingConflictsContribution implements FrontendApplicationContribution {
|
|
32
|
-
|
|
33
|
-
@inject(MonacoQuickInputService)
|
|
34
|
-
protected readonly monacoQuickInputService: MonacoQuickInputService;
|
|
35
|
-
|
|
36
|
-
@inject(PreferenceService)
|
|
37
|
-
protected readonly preferenceService: PreferenceService;
|
|
38
|
-
|
|
39
|
-
@inject(PreferenceLanguageOverrideService)
|
|
40
|
-
protected readonly preferenceSchema: PreferenceLanguageOverrideService;
|
|
41
|
-
|
|
42
|
-
@inject(EditorManager)
|
|
43
|
-
protected readonly editorManager: EditorManager;
|
|
44
|
-
|
|
45
|
-
async initialize(): Promise<void> {
|
|
46
|
-
|
|
47
|
-
FormattingConflicts.setFormatterSelector(<T extends FormattingEditProvider>(
|
|
48
|
-
formatters: T[], document: ITextModel, mode: FormattingMode) =>
|
|
49
|
-
this.selectFormatter(formatters, document, mode));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
protected async setDefaultFormatter(language: string, formatter: string): Promise<void> {
|
|
53
|
-
const name = this.preferenceSchema.overridePreferenceName({
|
|
54
|
-
preferenceName: PREFERENCE_NAME,
|
|
55
|
-
overrideIdentifier: language
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
await this.preferenceService.set(name, formatter);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
private getDefaultFormatter(language: string): string | undefined {
|
|
62
|
-
const name = this.preferenceSchema.overridePreferenceName({
|
|
63
|
-
preferenceName: PREFERENCE_NAME,
|
|
64
|
-
overrideIdentifier: language
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
return this.preferenceService.get<string>(name);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
private async selectFormatter<T extends FormattingEditProvider>(
|
|
71
|
-
formatters: T[], document: monaco.editor.ITextModel | ITextModel, mode: FormattingMode): Promise<T | undefined> {
|
|
72
|
-
|
|
73
|
-
if (formatters.length === 0) {
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (formatters.length === 1) {
|
|
78
|
-
return formatters[0];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const currentEditor = this.editorManager.currentEditor;
|
|
82
|
-
if (!currentEditor) {
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const languageId = currentEditor.editor.document.languageId;
|
|
87
|
-
const defaultFormatterId = this.getDefaultFormatter(languageId);
|
|
88
|
-
|
|
89
|
-
if (defaultFormatterId) {
|
|
90
|
-
const formatter = formatters.find(f => f.extensionId && f.extensionId.value === defaultFormatterId);
|
|
91
|
-
if (formatter) {
|
|
92
|
-
return formatter;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return new Promise<T | undefined>(async (resolve, reject) => {
|
|
97
|
-
const items = formatters
|
|
98
|
-
.filter(formatter => formatter.displayName)
|
|
99
|
-
.map(formatter => ({
|
|
100
|
-
label: formatter.displayName!,
|
|
101
|
-
detail: formatter.extensionId ? formatter.extensionId.value : undefined,
|
|
102
|
-
value: formatter,
|
|
103
|
-
}))
|
|
104
|
-
.sort((a, b) => a.label!.localeCompare(b.label!));
|
|
105
|
-
|
|
106
|
-
const selectedFormatter = await this.monacoQuickInputService.showQuickPick(items, { placeholder: 'Select formatter for the current document' });
|
|
107
|
-
if (selectedFormatter) {
|
|
108
|
-
this.setDefaultFormatter(languageId, selectedFormatter.detail ? selectedFormatter.detail : '');
|
|
109
|
-
resolve(selectedFormatter.value);
|
|
110
|
-
} else {
|
|
111
|
-
resolve(undefined);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2020 Red Hat, Inc. 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 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
+
import { PreferenceService, FrontendApplicationContribution, PreferenceLanguageOverrideService } from '@theia/core/lib/browser';
|
|
19
|
+
import { EditorManager } from '@theia/editor/lib/browser';
|
|
20
|
+
import { MonacoQuickInputService } from './monaco-quick-input-service';
|
|
21
|
+
import * as monaco from '@theia/monaco-editor-core';
|
|
22
|
+
import { FormattingConflicts, FormattingMode } from '@theia/monaco-editor-core/esm/vs/editor/contrib/format/browser/format';
|
|
23
|
+
import { DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider } from '@theia/monaco-editor-core/esm/vs/editor/common/languages';
|
|
24
|
+
import { ITextModel } from '@theia/monaco-editor-core/esm/vs/editor/common/model';
|
|
25
|
+
|
|
26
|
+
type FormattingEditProvider = DocumentFormattingEditProvider | DocumentRangeFormattingEditProvider;
|
|
27
|
+
|
|
28
|
+
const PREFERENCE_NAME = 'editor.defaultFormatter';
|
|
29
|
+
|
|
30
|
+
@injectable()
|
|
31
|
+
export class MonacoFormattingConflictsContribution implements FrontendApplicationContribution {
|
|
32
|
+
|
|
33
|
+
@inject(MonacoQuickInputService)
|
|
34
|
+
protected readonly monacoQuickInputService: MonacoQuickInputService;
|
|
35
|
+
|
|
36
|
+
@inject(PreferenceService)
|
|
37
|
+
protected readonly preferenceService: PreferenceService;
|
|
38
|
+
|
|
39
|
+
@inject(PreferenceLanguageOverrideService)
|
|
40
|
+
protected readonly preferenceSchema: PreferenceLanguageOverrideService;
|
|
41
|
+
|
|
42
|
+
@inject(EditorManager)
|
|
43
|
+
protected readonly editorManager: EditorManager;
|
|
44
|
+
|
|
45
|
+
async initialize(): Promise<void> {
|
|
46
|
+
|
|
47
|
+
FormattingConflicts.setFormatterSelector(<T extends FormattingEditProvider>(
|
|
48
|
+
formatters: T[], document: ITextModel, mode: FormattingMode) =>
|
|
49
|
+
this.selectFormatter(formatters, document, mode));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
protected async setDefaultFormatter(language: string, formatter: string): Promise<void> {
|
|
53
|
+
const name = this.preferenceSchema.overridePreferenceName({
|
|
54
|
+
preferenceName: PREFERENCE_NAME,
|
|
55
|
+
overrideIdentifier: language
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
await this.preferenceService.set(name, formatter);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private getDefaultFormatter(language: string): string | undefined {
|
|
62
|
+
const name = this.preferenceSchema.overridePreferenceName({
|
|
63
|
+
preferenceName: PREFERENCE_NAME,
|
|
64
|
+
overrideIdentifier: language
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return this.preferenceService.get<string>(name);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private async selectFormatter<T extends FormattingEditProvider>(
|
|
71
|
+
formatters: T[], document: monaco.editor.ITextModel | ITextModel, mode: FormattingMode): Promise<T | undefined> {
|
|
72
|
+
|
|
73
|
+
if (formatters.length === 0) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (formatters.length === 1) {
|
|
78
|
+
return formatters[0];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const currentEditor = this.editorManager.currentEditor;
|
|
82
|
+
if (!currentEditor) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const languageId = currentEditor.editor.document.languageId;
|
|
87
|
+
const defaultFormatterId = this.getDefaultFormatter(languageId);
|
|
88
|
+
|
|
89
|
+
if (defaultFormatterId) {
|
|
90
|
+
const formatter = formatters.find(f => f.extensionId && f.extensionId.value === defaultFormatterId);
|
|
91
|
+
if (formatter) {
|
|
92
|
+
return formatter;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return new Promise<T | undefined>(async (resolve, reject) => {
|
|
97
|
+
const items = formatters
|
|
98
|
+
.filter(formatter => formatter.displayName)
|
|
99
|
+
.map(formatter => ({
|
|
100
|
+
label: formatter.displayName!,
|
|
101
|
+
detail: formatter.extensionId ? formatter.extensionId.value : undefined,
|
|
102
|
+
value: formatter,
|
|
103
|
+
}))
|
|
104
|
+
.sort((a, b) => a.label!.localeCompare(b.label!));
|
|
105
|
+
|
|
106
|
+
const selectedFormatter = await this.monacoQuickInputService.showQuickPick(items, { placeholder: 'Select formatter for the current document' });
|
|
107
|
+
if (selectedFormatter) {
|
|
108
|
+
this.setDefaultFormatter(languageId, selectedFormatter.detail ? selectedFormatter.detail : '');
|
|
109
|
+
resolve(selectedFormatter.value);
|
|
110
|
+
} else {
|
|
111
|
+
resolve(undefined);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -1,188 +1,188 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Ericsson 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 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
18
|
-
import { ColorTheme, CssStyleCollector, FrontendApplicationContribution, PreferenceSchemaProvider, QuickAccessRegistry, StylingParticipant } from '@theia/core/lib/browser';
|
|
19
|
-
import { MonacoSnippetSuggestProvider } from './monaco-snippet-suggest-provider';
|
|
20
|
-
import * as monaco from '@theia/monaco-editor-core';
|
|
21
|
-
import { setSnippetSuggestSupport } from '@theia/monaco-editor-core/esm/vs/editor/contrib/suggest/browser/suggest';
|
|
22
|
-
import { CompletionItemProvider } from '@theia/monaco-editor-core/esm/vs/editor/common/languages';
|
|
23
|
-
import { MonacoEditorService } from './monaco-editor-service';
|
|
24
|
-
import { MonacoTextModelService } from './monaco-text-model-service';
|
|
25
|
-
import { ContextKeyService as VSCodeContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/browser/contextKeyService';
|
|
26
|
-
import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
27
|
-
import { ICodeEditorService } from '@theia/monaco-editor-core/esm/vs/editor/browser/services/codeEditorService';
|
|
28
|
-
import { ITextModelService } from '@theia/monaco-editor-core/esm/vs/editor/common/services/resolverService';
|
|
29
|
-
import { IContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
|
|
30
|
-
import { IContextMenuService } from '@theia/monaco-editor-core/esm/vs/platform/contextview/browser/contextView';
|
|
31
|
-
import { MonacoContextMenuService } from './monaco-context-menu';
|
|
32
|
-
import { MonacoThemingService } from './monaco-theming-service';
|
|
33
|
-
import { isHighContrast } from '@theia/core/lib/common/theme';
|
|
34
|
-
import { editorOptionsRegistry, IEditorOption } from '@theia/monaco-editor-core/esm/vs/editor/common/config/editorOptions';
|
|
35
|
-
import { MAX_SAFE_INTEGER } from '@theia/core';
|
|
36
|
-
import { editorGeneratedPreferenceProperties } from '@theia/editor/lib/browser/editor-generated-preference-schema';
|
|
37
|
-
|
|
38
|
-
let theiaDidInitialize = false;
|
|
39
|
-
const originalInitialize = StandaloneServices.initialize;
|
|
40
|
-
StandaloneServices.initialize = overrides => {
|
|
41
|
-
if (!theiaDidInitialize) {
|
|
42
|
-
console.warn('Monaco was initialized before overrides were installed by Theia\'s initialization.'
|
|
43
|
-
+ ' Please check the lifecycle of services that use Monaco and ensure that Monaco entities are not instantiated before Theia is initialized.', new Error());
|
|
44
|
-
}
|
|
45
|
-
return originalInitialize(overrides);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
@injectable()
|
|
49
|
-
export class MonacoFrontendApplicationContribution implements FrontendApplicationContribution, StylingParticipant {
|
|
50
|
-
|
|
51
|
-
@inject(MonacoEditorService)
|
|
52
|
-
protected readonly codeEditorService: MonacoEditorService;
|
|
53
|
-
|
|
54
|
-
@inject(MonacoTextModelService)
|
|
55
|
-
protected readonly textModelService: MonacoTextModelService;
|
|
56
|
-
|
|
57
|
-
@inject(VSCodeContextKeyService)
|
|
58
|
-
protected readonly contextKeyService: VSCodeContextKeyService;
|
|
59
|
-
|
|
60
|
-
@inject(MonacoSnippetSuggestProvider)
|
|
61
|
-
protected readonly snippetSuggestProvider: MonacoSnippetSuggestProvider;
|
|
62
|
-
|
|
63
|
-
@inject(PreferenceSchemaProvider)
|
|
64
|
-
protected readonly preferenceSchema: PreferenceSchemaProvider;
|
|
65
|
-
|
|
66
|
-
@inject(QuickAccessRegistry)
|
|
67
|
-
protected readonly quickAccessRegistry: QuickAccessRegistry;
|
|
68
|
-
|
|
69
|
-
@inject(MonacoContextMenuService)
|
|
70
|
-
protected readonly contextMenuService: MonacoContextMenuService;
|
|
71
|
-
|
|
72
|
-
@inject(MonacoThemingService) protected readonly monacoThemingService: MonacoThemingService;
|
|
73
|
-
|
|
74
|
-
@postConstruct()
|
|
75
|
-
protected init(): void {
|
|
76
|
-
this.addAdditionalPreferenceValidations();
|
|
77
|
-
const { codeEditorService, textModelService, contextKeyService, contextMenuService } = this;
|
|
78
|
-
theiaDidInitialize = true;
|
|
79
|
-
StandaloneServices.initialize({
|
|
80
|
-
[ICodeEditorService.toString()]: codeEditorService,
|
|
81
|
-
[ITextModelService.toString()]: textModelService,
|
|
82
|
-
[IContextKeyService.toString()]: contextKeyService,
|
|
83
|
-
[IContextMenuService.toString()]: contextMenuService,
|
|
84
|
-
});
|
|
85
|
-
// Monaco registers certain quick access providers (e.g. QuickCommandAccess) at import time, but we want to use our own.
|
|
86
|
-
this.quickAccessRegistry.clear();
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @monaco-uplift.Should be guaranteed to work.
|
|
90
|
-
* Incomparable enums prevent TypeScript from believing that public ITextModel satisfied private ITextModel
|
|
91
|
-
*/
|
|
92
|
-
setSnippetSuggestSupport(this.snippetSuggestProvider as unknown as CompletionItemProvider);
|
|
93
|
-
|
|
94
|
-
for (const language of monaco.languages.getLanguages()) {
|
|
95
|
-
this.preferenceSchema.registerOverrideIdentifier(language.id);
|
|
96
|
-
}
|
|
97
|
-
const registerLanguage = monaco.languages.register.bind(monaco.languages);
|
|
98
|
-
monaco.languages.register = language => {
|
|
99
|
-
// first register override identifier, because monaco will immediately update already opened documents and then initialize with bad preferences.
|
|
100
|
-
this.preferenceSchema.registerOverrideIdentifier(language.id);
|
|
101
|
-
registerLanguage(language);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
this.monacoThemingService.initialize();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
initialize(): void { }
|
|
108
|
-
|
|
109
|
-
registerThemeStyle(theme: ColorTheme, collector: CssStyleCollector): void {
|
|
110
|
-
if (isHighContrast(theme.type)) {
|
|
111
|
-
const focusBorder = theme.getColor('focusBorder');
|
|
112
|
-
const contrastBorder = theme.getColor('contrastBorder');
|
|
113
|
-
if (focusBorder) {
|
|
114
|
-
// Quick input
|
|
115
|
-
collector.addRule(`
|
|
116
|
-
.quick-input-list .monaco-list-row {
|
|
117
|
-
outline-offset: -1px;
|
|
118
|
-
}
|
|
119
|
-
.quick-input-list .monaco-list-row.focused {
|
|
120
|
-
outline: 1px dotted ${focusBorder};
|
|
121
|
-
}
|
|
122
|
-
.quick-input-list .monaco-list-row:hover {
|
|
123
|
-
outline: 1px dashed ${focusBorder};
|
|
124
|
-
}
|
|
125
|
-
`);
|
|
126
|
-
// Input box always displays an outline, even when unfocused
|
|
127
|
-
collector.addRule(`
|
|
128
|
-
.monaco-editor .find-widget .monaco-inputbox {
|
|
129
|
-
outline: var(--theia-border-width) solid;
|
|
130
|
-
outline-offset: calc(-1 * var(--theia-border-width));
|
|
131
|
-
outline-color: var(--theia-focusBorder);
|
|
132
|
-
}
|
|
133
|
-
`);
|
|
134
|
-
}
|
|
135
|
-
if (contrastBorder) {
|
|
136
|
-
collector.addRule(`
|
|
137
|
-
.quick-input-widget {
|
|
138
|
-
outline: 1px solid ${contrastBorder};
|
|
139
|
-
outline-offset: -1px;
|
|
140
|
-
}
|
|
141
|
-
`);
|
|
142
|
-
}
|
|
143
|
-
} else {
|
|
144
|
-
collector.addRule(`
|
|
145
|
-
.quick-input-widget {
|
|
146
|
-
box-shadow: rgb(0 0 0 / 36%) 0px 0px 8px 2px;
|
|
147
|
-
}
|
|
148
|
-
`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* For reasons that are unclear, while most preferences that apply in editors are validated, a few are not.
|
|
154
|
-
* There is a utility in `examples/api-samples/src/browser/monaco-editor-preferences/monaco-editor-preference-extractor.ts` to help determine which are not.
|
|
155
|
-
* Check `src/vs/editor/common/config/editorOptions.ts` for constructor arguments and to make sure that the preference names used to extract constructors are still accurate.
|
|
156
|
-
*/
|
|
157
|
-
protected addAdditionalPreferenceValidations(): void {
|
|
158
|
-
let editorIntConstructor: undefined | (new (...args: unknown[]) => IEditorOption<number, number>);
|
|
159
|
-
let editorBoolConstructor: undefined | (new (...args: unknown[]) => IEditorOption<number, boolean>);
|
|
160
|
-
let editorStringEnumConstructor: undefined | (new (...args: unknown[]) => IEditorOption<number, string>);
|
|
161
|
-
for (const validator of editorOptionsRegistry) {
|
|
162
|
-
/* eslint-disable @typescript-eslint/no-explicit-any,max-len */
|
|
163
|
-
if (editorIntConstructor && editorBoolConstructor && editorStringEnumConstructor) { break; }
|
|
164
|
-
if (validator.name === 'acceptSuggestionOnCommitCharacter') {
|
|
165
|
-
editorBoolConstructor = validator.constructor as any;
|
|
166
|
-
} else if (validator.name === 'acceptSuggestionOnEnter') {
|
|
167
|
-
editorStringEnumConstructor = validator.constructor as any;
|
|
168
|
-
} else if (validator.name === 'accessibilityPageSize') {
|
|
169
|
-
editorIntConstructor = validator.constructor as any;
|
|
170
|
-
}
|
|
171
|
-
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
172
|
-
}
|
|
173
|
-
if (editorIntConstructor && editorBoolConstructor && editorStringEnumConstructor) {
|
|
174
|
-
let id = 200; // Needs to be bigger than the biggest index in the EditorOption enum.
|
|
175
|
-
editorOptionsRegistry.push(
|
|
176
|
-
new editorIntConstructor(id++, 'tabSize', 4, 1, MAX_SAFE_INTEGER, editorGeneratedPreferenceProperties['editor.tabSize']),
|
|
177
|
-
new editorBoolConstructor(id++, 'insertSpaces', true, editorGeneratedPreferenceProperties['editor.insertSpaces']),
|
|
178
|
-
new editorBoolConstructor(id++, 'detectIndentation', true, editorGeneratedPreferenceProperties['editor.detectIndentation']),
|
|
179
|
-
new editorBoolConstructor(id++, 'trimAutoWhitespace', true, editorGeneratedPreferenceProperties['editor.trimAutoWhitespace']),
|
|
180
|
-
new editorBoolConstructor(id++, 'largeFileOptimizations', true, editorGeneratedPreferenceProperties['editor.largeFileOptimizations']),
|
|
181
|
-
new editorBoolConstructor(id++, 'wordBasedSuggestions', true, editorGeneratedPreferenceProperties['editor.wordBasedSuggestions']),
|
|
182
|
-
new editorStringEnumConstructor(id++, 'wordBasedSuggestionsMode', 'matchingDocuments', editorGeneratedPreferenceProperties['editor.wordBasedSuggestionsMode'].enum, editorGeneratedPreferenceProperties['editor.wordBasedSuggestionsMode']),
|
|
183
|
-
new editorBoolConstructor(id++, 'stablePeek', false, editorGeneratedPreferenceProperties['editor.stablePeek']),
|
|
184
|
-
new editorIntConstructor(id++, 'maxTokenizationLineLength', 20000, 1, MAX_SAFE_INTEGER, editorGeneratedPreferenceProperties['editor.maxTokenizationLineLength']),
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Ericsson 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 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
18
|
+
import { ColorTheme, CssStyleCollector, FrontendApplicationContribution, PreferenceSchemaProvider, QuickAccessRegistry, StylingParticipant } from '@theia/core/lib/browser';
|
|
19
|
+
import { MonacoSnippetSuggestProvider } from './monaco-snippet-suggest-provider';
|
|
20
|
+
import * as monaco from '@theia/monaco-editor-core';
|
|
21
|
+
import { setSnippetSuggestSupport } from '@theia/monaco-editor-core/esm/vs/editor/contrib/suggest/browser/suggest';
|
|
22
|
+
import { CompletionItemProvider } from '@theia/monaco-editor-core/esm/vs/editor/common/languages';
|
|
23
|
+
import { MonacoEditorService } from './monaco-editor-service';
|
|
24
|
+
import { MonacoTextModelService } from './monaco-text-model-service';
|
|
25
|
+
import { ContextKeyService as VSCodeContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/browser/contextKeyService';
|
|
26
|
+
import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
27
|
+
import { ICodeEditorService } from '@theia/monaco-editor-core/esm/vs/editor/browser/services/codeEditorService';
|
|
28
|
+
import { ITextModelService } from '@theia/monaco-editor-core/esm/vs/editor/common/services/resolverService';
|
|
29
|
+
import { IContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
|
|
30
|
+
import { IContextMenuService } from '@theia/monaco-editor-core/esm/vs/platform/contextview/browser/contextView';
|
|
31
|
+
import { MonacoContextMenuService } from './monaco-context-menu';
|
|
32
|
+
import { MonacoThemingService } from './monaco-theming-service';
|
|
33
|
+
import { isHighContrast } from '@theia/core/lib/common/theme';
|
|
34
|
+
import { editorOptionsRegistry, IEditorOption } from '@theia/monaco-editor-core/esm/vs/editor/common/config/editorOptions';
|
|
35
|
+
import { MAX_SAFE_INTEGER } from '@theia/core';
|
|
36
|
+
import { editorGeneratedPreferenceProperties } from '@theia/editor/lib/browser/editor-generated-preference-schema';
|
|
37
|
+
|
|
38
|
+
let theiaDidInitialize = false;
|
|
39
|
+
const originalInitialize = StandaloneServices.initialize;
|
|
40
|
+
StandaloneServices.initialize = overrides => {
|
|
41
|
+
if (!theiaDidInitialize) {
|
|
42
|
+
console.warn('Monaco was initialized before overrides were installed by Theia\'s initialization.'
|
|
43
|
+
+ ' Please check the lifecycle of services that use Monaco and ensure that Monaco entities are not instantiated before Theia is initialized.', new Error());
|
|
44
|
+
}
|
|
45
|
+
return originalInitialize(overrides);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
@injectable()
|
|
49
|
+
export class MonacoFrontendApplicationContribution implements FrontendApplicationContribution, StylingParticipant {
|
|
50
|
+
|
|
51
|
+
@inject(MonacoEditorService)
|
|
52
|
+
protected readonly codeEditorService: MonacoEditorService;
|
|
53
|
+
|
|
54
|
+
@inject(MonacoTextModelService)
|
|
55
|
+
protected readonly textModelService: MonacoTextModelService;
|
|
56
|
+
|
|
57
|
+
@inject(VSCodeContextKeyService)
|
|
58
|
+
protected readonly contextKeyService: VSCodeContextKeyService;
|
|
59
|
+
|
|
60
|
+
@inject(MonacoSnippetSuggestProvider)
|
|
61
|
+
protected readonly snippetSuggestProvider: MonacoSnippetSuggestProvider;
|
|
62
|
+
|
|
63
|
+
@inject(PreferenceSchemaProvider)
|
|
64
|
+
protected readonly preferenceSchema: PreferenceSchemaProvider;
|
|
65
|
+
|
|
66
|
+
@inject(QuickAccessRegistry)
|
|
67
|
+
protected readonly quickAccessRegistry: QuickAccessRegistry;
|
|
68
|
+
|
|
69
|
+
@inject(MonacoContextMenuService)
|
|
70
|
+
protected readonly contextMenuService: MonacoContextMenuService;
|
|
71
|
+
|
|
72
|
+
@inject(MonacoThemingService) protected readonly monacoThemingService: MonacoThemingService;
|
|
73
|
+
|
|
74
|
+
@postConstruct()
|
|
75
|
+
protected init(): void {
|
|
76
|
+
this.addAdditionalPreferenceValidations();
|
|
77
|
+
const { codeEditorService, textModelService, contextKeyService, contextMenuService } = this;
|
|
78
|
+
theiaDidInitialize = true;
|
|
79
|
+
StandaloneServices.initialize({
|
|
80
|
+
[ICodeEditorService.toString()]: codeEditorService,
|
|
81
|
+
[ITextModelService.toString()]: textModelService,
|
|
82
|
+
[IContextKeyService.toString()]: contextKeyService,
|
|
83
|
+
[IContextMenuService.toString()]: contextMenuService,
|
|
84
|
+
});
|
|
85
|
+
// Monaco registers certain quick access providers (e.g. QuickCommandAccess) at import time, but we want to use our own.
|
|
86
|
+
this.quickAccessRegistry.clear();
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @monaco-uplift.Should be guaranteed to work.
|
|
90
|
+
* Incomparable enums prevent TypeScript from believing that public ITextModel satisfied private ITextModel
|
|
91
|
+
*/
|
|
92
|
+
setSnippetSuggestSupport(this.snippetSuggestProvider as unknown as CompletionItemProvider);
|
|
93
|
+
|
|
94
|
+
for (const language of monaco.languages.getLanguages()) {
|
|
95
|
+
this.preferenceSchema.registerOverrideIdentifier(language.id);
|
|
96
|
+
}
|
|
97
|
+
const registerLanguage = monaco.languages.register.bind(monaco.languages);
|
|
98
|
+
monaco.languages.register = language => {
|
|
99
|
+
// first register override identifier, because monaco will immediately update already opened documents and then initialize with bad preferences.
|
|
100
|
+
this.preferenceSchema.registerOverrideIdentifier(language.id);
|
|
101
|
+
registerLanguage(language);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
this.monacoThemingService.initialize();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
initialize(): void { }
|
|
108
|
+
|
|
109
|
+
registerThemeStyle(theme: ColorTheme, collector: CssStyleCollector): void {
|
|
110
|
+
if (isHighContrast(theme.type)) {
|
|
111
|
+
const focusBorder = theme.getColor('focusBorder');
|
|
112
|
+
const contrastBorder = theme.getColor('contrastBorder');
|
|
113
|
+
if (focusBorder) {
|
|
114
|
+
// Quick input
|
|
115
|
+
collector.addRule(`
|
|
116
|
+
.quick-input-list .monaco-list-row {
|
|
117
|
+
outline-offset: -1px;
|
|
118
|
+
}
|
|
119
|
+
.quick-input-list .monaco-list-row.focused {
|
|
120
|
+
outline: 1px dotted ${focusBorder};
|
|
121
|
+
}
|
|
122
|
+
.quick-input-list .monaco-list-row:hover {
|
|
123
|
+
outline: 1px dashed ${focusBorder};
|
|
124
|
+
}
|
|
125
|
+
`);
|
|
126
|
+
// Input box always displays an outline, even when unfocused
|
|
127
|
+
collector.addRule(`
|
|
128
|
+
.monaco-editor .find-widget .monaco-inputbox {
|
|
129
|
+
outline: var(--theia-border-width) solid;
|
|
130
|
+
outline-offset: calc(-1 * var(--theia-border-width));
|
|
131
|
+
outline-color: var(--theia-focusBorder);
|
|
132
|
+
}
|
|
133
|
+
`);
|
|
134
|
+
}
|
|
135
|
+
if (contrastBorder) {
|
|
136
|
+
collector.addRule(`
|
|
137
|
+
.quick-input-widget {
|
|
138
|
+
outline: 1px solid ${contrastBorder};
|
|
139
|
+
outline-offset: -1px;
|
|
140
|
+
}
|
|
141
|
+
`);
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
collector.addRule(`
|
|
145
|
+
.quick-input-widget {
|
|
146
|
+
box-shadow: rgb(0 0 0 / 36%) 0px 0px 8px 2px;
|
|
147
|
+
}
|
|
148
|
+
`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* For reasons that are unclear, while most preferences that apply in editors are validated, a few are not.
|
|
154
|
+
* There is a utility in `examples/api-samples/src/browser/monaco-editor-preferences/monaco-editor-preference-extractor.ts` to help determine which are not.
|
|
155
|
+
* Check `src/vs/editor/common/config/editorOptions.ts` for constructor arguments and to make sure that the preference names used to extract constructors are still accurate.
|
|
156
|
+
*/
|
|
157
|
+
protected addAdditionalPreferenceValidations(): void {
|
|
158
|
+
let editorIntConstructor: undefined | (new (...args: unknown[]) => IEditorOption<number, number>);
|
|
159
|
+
let editorBoolConstructor: undefined | (new (...args: unknown[]) => IEditorOption<number, boolean>);
|
|
160
|
+
let editorStringEnumConstructor: undefined | (new (...args: unknown[]) => IEditorOption<number, string>);
|
|
161
|
+
for (const validator of editorOptionsRegistry) {
|
|
162
|
+
/* eslint-disable @typescript-eslint/no-explicit-any,max-len */
|
|
163
|
+
if (editorIntConstructor && editorBoolConstructor && editorStringEnumConstructor) { break; }
|
|
164
|
+
if (validator.name === 'acceptSuggestionOnCommitCharacter') {
|
|
165
|
+
editorBoolConstructor = validator.constructor as any;
|
|
166
|
+
} else if (validator.name === 'acceptSuggestionOnEnter') {
|
|
167
|
+
editorStringEnumConstructor = validator.constructor as any;
|
|
168
|
+
} else if (validator.name === 'accessibilityPageSize') {
|
|
169
|
+
editorIntConstructor = validator.constructor as any;
|
|
170
|
+
}
|
|
171
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
172
|
+
}
|
|
173
|
+
if (editorIntConstructor && editorBoolConstructor && editorStringEnumConstructor) {
|
|
174
|
+
let id = 200; // Needs to be bigger than the biggest index in the EditorOption enum.
|
|
175
|
+
editorOptionsRegistry.push(
|
|
176
|
+
new editorIntConstructor(id++, 'tabSize', 4, 1, MAX_SAFE_INTEGER, editorGeneratedPreferenceProperties['editor.tabSize']),
|
|
177
|
+
new editorBoolConstructor(id++, 'insertSpaces', true, editorGeneratedPreferenceProperties['editor.insertSpaces']),
|
|
178
|
+
new editorBoolConstructor(id++, 'detectIndentation', true, editorGeneratedPreferenceProperties['editor.detectIndentation']),
|
|
179
|
+
new editorBoolConstructor(id++, 'trimAutoWhitespace', true, editorGeneratedPreferenceProperties['editor.trimAutoWhitespace']),
|
|
180
|
+
new editorBoolConstructor(id++, 'largeFileOptimizations', true, editorGeneratedPreferenceProperties['editor.largeFileOptimizations']),
|
|
181
|
+
new editorBoolConstructor(id++, 'wordBasedSuggestions', true, editorGeneratedPreferenceProperties['editor.wordBasedSuggestions']),
|
|
182
|
+
new editorStringEnumConstructor(id++, 'wordBasedSuggestionsMode', 'matchingDocuments', editorGeneratedPreferenceProperties['editor.wordBasedSuggestionsMode'].enum, editorGeneratedPreferenceProperties['editor.wordBasedSuggestionsMode']),
|
|
183
|
+
new editorBoolConstructor(id++, 'stablePeek', false, editorGeneratedPreferenceProperties['editor.stablePeek']),
|
|
184
|
+
new editorIntConstructor(id++, 'maxTokenizationLineLength', 20000, 1, MAX_SAFE_INTEGER, editorGeneratedPreferenceProperties['editor.maxTokenizationLineLength']),
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|