@theia/monaco 1.56.0 → 1.57.0-next.136
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 +26 -13
- package/lib/browser/content-hover-widget-patcher.d.ts +9 -0
- package/lib/browser/content-hover-widget-patcher.d.ts.map +1 -0
- package/lib/browser/content-hover-widget-patcher.js +63 -0
- package/lib/browser/content-hover-widget-patcher.js.map +1 -0
- package/lib/browser/default-content-hover-widget-patcher.d.ts +9 -0
- package/lib/browser/default-content-hover-widget-patcher.d.ts.map +1 -0
- package/lib/browser/default-content-hover-widget-patcher.js +49 -0
- package/lib/browser/default-content-hover-widget-patcher.js.map +1 -0
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.d.ts +1 -1
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.d.ts.map +1 -1
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.js +1 -1
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.js.map +1 -1
- package/lib/browser/monaco-diff-editor.js +2 -2
- package/lib/browser/monaco-diff-editor.js.map +1 -1
- package/lib/browser/monaco-editor-model.d.ts.map +1 -1
- package/lib/browser/monaco-editor-model.js +2 -2
- package/lib/browser/monaco-editor-model.js.map +1 -1
- package/lib/browser/monaco-editor.d.ts.map +1 -1
- package/lib/browser/monaco-editor.js +7 -4
- package/lib/browser/monaco-editor.js.map +1 -1
- package/lib/browser/monaco-frontend-application-contribution.d.ts +5 -0
- package/lib/browser/monaco-frontend-application-contribution.d.ts.map +1 -1
- package/lib/browser/monaco-frontend-application-contribution.js +21 -1
- package/lib/browser/monaco-frontend-application-contribution.js.map +1 -1
- package/lib/browser/monaco-frontend-module.d.ts +1 -1
- package/lib/browser/monaco-frontend-module.d.ts.map +1 -1
- package/lib/browser/monaco-frontend-module.js +5 -1
- package/lib/browser/monaco-frontend-module.js.map +1 -1
- package/lib/browser/monaco-init.d.ts +1 -0
- package/lib/browser/monaco-init.d.ts.map +1 -1
- package/lib/browser/monaco-init.js +12 -19
- package/lib/browser/monaco-init.js.map +1 -1
- package/lib/browser/monaco-quick-input-service.d.ts +15 -5
- package/lib/browser/monaco-quick-input-service.d.ts.map +1 -1
- package/lib/browser/monaco-quick-input-service.js +33 -22
- package/lib/browser/monaco-quick-input-service.js.map +1 -1
- package/lib/browser/monaco-workspace.d.ts +2 -1
- package/lib/browser/monaco-workspace.d.ts.map +1 -1
- package/lib/browser/monaco-workspace.js +3 -2
- package/lib/browser/monaco-workspace.js.map +1 -1
- package/lib/browser/simple-monaco-editor.d.ts +1 -1
- package/lib/browser/simple-monaco-editor.d.ts.map +1 -1
- package/lib/browser/simple-monaco-editor.js +3 -2
- package/lib/browser/simple-monaco-editor.js.map +1 -1
- package/package.json +10 -10
- package/src/browser/content-hover-widget-patcher.ts +74 -0
- package/src/browser/default-content-hover-widget-patcher.ts +50 -0
- package/src/browser/markdown-renderer/monaco-markdown-renderer.ts +2 -1
- package/src/browser/monaco-diff-editor.ts +1 -1
- package/src/browser/monaco-editor-model.ts +3 -3
- package/src/browser/monaco-editor.ts +17 -4
- package/src/browser/monaco-frontend-application-contribution.ts +23 -2
- package/src/browser/monaco-frontend-module.ts +11 -6
- package/src/browser/monaco-init.ts +13 -19
- package/src/browser/monaco-quick-input-service.ts +47 -31
- package/src/browser/monaco-workspace.ts +4 -2
- package/src/browser/simple-monaco-editor.ts +3 -2
|
@@ -33,9 +33,17 @@ import { MonacoEditor } from './monaco-editor';
|
|
|
33
33
|
import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
34
34
|
import { StandaloneThemeService } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneThemeService';
|
|
35
35
|
import { IStandaloneThemeService } from '@theia/monaco-editor-core/esm/vs/editor/standalone/common/standaloneTheme';
|
|
36
|
+
import { SecondaryWindowService } from '@theia/core/lib/browser/window/secondary-window-service';
|
|
37
|
+
import { registerWindow } from '@theia/monaco-editor-core/esm/vs/base/browser/dom';
|
|
38
|
+
|
|
39
|
+
type CodeWindow = Window & typeof globalThis & {
|
|
40
|
+
vscodeWindowId: number;
|
|
41
|
+
};
|
|
36
42
|
|
|
37
43
|
@injectable()
|
|
38
44
|
export class MonacoFrontendApplicationContribution implements FrontendApplicationContribution, StylingParticipant {
|
|
45
|
+
protected readonly windowsById = new Map<number, monaco.IDisposable>();
|
|
46
|
+
protected nextWindowId = 2; // the main window has the id "1"
|
|
39
47
|
|
|
40
48
|
@inject(MonacoTextModelService)
|
|
41
49
|
protected readonly textModelService: MonacoTextModelService;
|
|
@@ -56,6 +64,9 @@ export class MonacoFrontendApplicationContribution implements FrontendApplicatio
|
|
|
56
64
|
@inject(SecondaryWindowHandler)
|
|
57
65
|
protected readonly secondaryWindowHandler: SecondaryWindowHandler;
|
|
58
66
|
|
|
67
|
+
@inject(SecondaryWindowService)
|
|
68
|
+
protected readonly secondaryWindowService: SecondaryWindowService;
|
|
69
|
+
|
|
59
70
|
@postConstruct()
|
|
60
71
|
protected init(): void {
|
|
61
72
|
this.addAdditionalPreferenceValidations();
|
|
@@ -98,6 +109,17 @@ export class MonacoFrontendApplicationContribution implements FrontendApplicatio
|
|
|
98
109
|
themeService.registerEditorContainer(widget.node);
|
|
99
110
|
}
|
|
100
111
|
});
|
|
112
|
+
this.secondaryWindowService.onWindowOpened(window => {
|
|
113
|
+
const codeWindow: CodeWindow = window as CodeWindow;
|
|
114
|
+
codeWindow.vscodeWindowId = this.nextWindowId++;
|
|
115
|
+
|
|
116
|
+
this.windowsById.set(codeWindow.vscodeWindowId, registerWindow(codeWindow));
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
this.secondaryWindowService.onWindowClosed(window => {
|
|
120
|
+
const codeWindow: CodeWindow = window as CodeWindow;
|
|
121
|
+
this.windowsById.get(codeWindow.vscodeWindowId)?.dispose();
|
|
122
|
+
});
|
|
101
123
|
}
|
|
102
124
|
|
|
103
125
|
registerThemeStyle(theme: ColorTheme, collector: CssStyleCollector): void {
|
|
@@ -172,8 +194,7 @@ export class MonacoFrontendApplicationContribution implements FrontendApplicatio
|
|
|
172
194
|
new editorBoolConstructor(id++, 'detectIndentation', true, editorGeneratedPreferenceProperties['editor.detectIndentation']),
|
|
173
195
|
new editorBoolConstructor(id++, 'trimAutoWhitespace', true, editorGeneratedPreferenceProperties['editor.trimAutoWhitespace']),
|
|
174
196
|
new editorBoolConstructor(id++, 'largeFileOptimizations', true, editorGeneratedPreferenceProperties['editor.largeFileOptimizations']),
|
|
175
|
-
new
|
|
176
|
-
new editorStringEnumConstructor(id++, 'wordBasedSuggestionsMode', 'matchingDocuments', editorGeneratedPreferenceProperties['editor.wordBasedSuggestionsMode'].enum, editorGeneratedPreferenceProperties['editor.wordBasedSuggestionsMode']),
|
|
197
|
+
new editorStringEnumConstructor(id++, 'wordBasedSuggestions', 'matchingDocuments', editorGeneratedPreferenceProperties['editor.wordBasedSuggestions'].enum, editorGeneratedPreferenceProperties['editor.wordBasedSuggestions']),
|
|
177
198
|
new editorBoolConstructor(id++, 'stablePeek', false, editorGeneratedPreferenceProperties['editor.stablePeek']),
|
|
178
199
|
new editorIntConstructor(id++, 'maxTokenizationLineLength', 20000, 1, MAX_SAFE_INTEGER, editorGeneratedPreferenceProperties['editor.maxTokenizationLineLength']),
|
|
179
200
|
);
|
|
@@ -66,16 +66,18 @@ import { GotoLineQuickAccessContribution } from './monaco-gotoline-quick-access'
|
|
|
66
66
|
import { GotoSymbolQuickAccessContribution } from './monaco-gotosymbol-quick-access';
|
|
67
67
|
import { QuickAccessContribution, QuickAccessRegistry } from '@theia/core/lib/browser/quick-input/quick-access';
|
|
68
68
|
import { MonacoQuickAccessRegistry } from './monaco-quick-access-registry';
|
|
69
|
-
import { ConfigurationTarget, IConfigurationChangeEvent, IConfigurationService } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configuration';
|
|
70
|
-
import { StandaloneConfigurationService } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
71
|
-
import { Configuration } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configurationModels';
|
|
69
|
+
import { ConfigurationTarget, IConfigurationChangeEvent, IConfigurationService } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configuration.js';
|
|
70
|
+
import { StandaloneConfigurationService, StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
71
|
+
import { Configuration } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configurationModels.js';
|
|
72
72
|
import { MarkdownRenderer } from '@theia/core/lib/browser/markdown-rendering/markdown-renderer';
|
|
73
73
|
import { MonacoMarkdownRenderer } from './markdown-renderer/monaco-markdown-renderer';
|
|
74
74
|
import { ThemeService } from '@theia/core/lib/browser/theming';
|
|
75
75
|
import { ThemeServiceWithDB } from './monaco-indexed-db';
|
|
76
|
-
import { IContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
|
|
77
|
-
import { IThemeService } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/themeService';
|
|
76
|
+
import { IContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey.js';
|
|
77
|
+
import { IThemeService } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/themeService.js';
|
|
78
78
|
import { ActiveMonacoUndoRedoHandler, FocusedMonacoUndoRedoHandler } from './monaco-undo-redo-handler';
|
|
79
|
+
import { ILogService } from '@theia/monaco-editor-core/esm/vs/platform/log/common/log';
|
|
80
|
+
import { DefaultContentHoverWidgetPatcher } from './default-content-hover-widget-patcher';
|
|
79
81
|
|
|
80
82
|
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
81
83
|
bind(MonacoThemingService).toSelf().inSingletonScope();
|
|
@@ -183,13 +185,16 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
|
183
185
|
bind(ActiveMonacoUndoRedoHandler).toSelf().inSingletonScope();
|
|
184
186
|
bind(UndoRedoHandler).toService(FocusedMonacoUndoRedoHandler);
|
|
185
187
|
bind(UndoRedoHandler).toService(ActiveMonacoUndoRedoHandler);
|
|
188
|
+
|
|
189
|
+
bind(DefaultContentHoverWidgetPatcher).toSelf().inSingletonScope();
|
|
190
|
+
bind(FrontendApplicationContribution).toService(DefaultContentHoverWidgetPatcher);
|
|
186
191
|
});
|
|
187
192
|
|
|
188
193
|
export const MonacoConfigurationService = Symbol('MonacoConfigurationService');
|
|
189
194
|
export function createMonacoConfigurationService(container: interfaces.Container): IConfigurationService {
|
|
190
195
|
const preferences = container.get<PreferenceService>(PreferenceService);
|
|
191
196
|
const preferenceSchemaProvider = container.get<PreferenceSchemaProvider>(PreferenceSchemaProvider);
|
|
192
|
-
const service = new StandaloneConfigurationService();
|
|
197
|
+
const service = new StandaloneConfigurationService(StandaloneServices.get(ILogService));
|
|
193
198
|
const _configuration: Configuration = service['_configuration'];
|
|
194
199
|
|
|
195
200
|
_configuration.getValue = (section, overrides) => {
|
|
@@ -16,33 +16,18 @@
|
|
|
16
16
|
|
|
17
17
|
/*
|
|
18
18
|
* The code in this file is responsible for overriding service implementations in the Monaco editor with our own Theia-based implementations.
|
|
19
|
-
* Since we only get a single chance to call `
|
|
20
|
-
* `StandaloneServices.get()` or `
|
|
19
|
+
* Since we only get a single chance to call `StandaloneServices.initialize()` with our overrides, we need to make sure that initialize is called before the first call to
|
|
20
|
+
* `StandaloneServices.get()` or `StandaloneServices.initialize()`. As we do not control the mechanics of Inversify instance constructions, the approach here is to call
|
|
21
21
|
* `MonacoInit.init()` from the `index.js` file after all container modules are loaded, but before the first object is fetched from it.
|
|
22
22
|
* `StandaloneServices.initialize()` is called with service descriptors, not service instances. This lets us finish all overrides before any inversify object is constructed and
|
|
23
23
|
* might call `initialize()` while being constructed.
|
|
24
24
|
* The service descriptors require a constructor function, so we declare dummy class for each Monaco service we override. But instead of returning an instance of the dummy class,
|
|
25
25
|
* we fetch the implementation of the monaco service from the inversify container.
|
|
26
|
-
* The inversify-constructed services must not call StandaloneServices.get() or StandaloneServices.initialize() from their constructors. Calling `get`()` in postConstruct
|
|
26
|
+
* The inversify-constructed services must not call StandaloneServices.get() or StandaloneServices.initialize() from their constructors. Calling `get`()` in postConstruct methods
|
|
27
27
|
* is allowed.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
// Before importing anything from monaco we need to override its localization function
|
|
31
|
-
import * as MonacoNls from '@theia/monaco-editor-core/esm/vs/nls';
|
|
32
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
33
|
-
import { FormatType, Localization } from '@theia/core/lib/common/i18n/localization';
|
|
34
|
-
|
|
35
|
-
Object.assign(MonacoNls, {
|
|
36
|
-
localize(_key: string, label: string, ...args: FormatType[]): string {
|
|
37
|
-
if (nls.locale) {
|
|
38
|
-
const defaultKey = nls.getDefaultKey(label);
|
|
39
|
-
if (defaultKey) {
|
|
40
|
-
return nls.localize(defaultKey, label, ...args);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return Localization.format(label, args);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
31
|
|
|
47
32
|
import { Container } from '@theia/core/shared/inversify';
|
|
48
33
|
import { ICodeEditorService } from '@theia/monaco-editor-core/esm/vs/editor/browser/services/codeEditorService';
|
|
@@ -65,6 +50,9 @@ import { MonacoQuickInputImplementation } from './monaco-quick-input-service';
|
|
|
65
50
|
import { IQuickInputService } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/common/quickInput';
|
|
66
51
|
import { IStandaloneThemeService } from '@theia/monaco-editor-core/esm/vs/editor/standalone/common/standaloneTheme';
|
|
67
52
|
import { MonacoStandaloneThemeService } from './monaco-standalone-theme-service';
|
|
53
|
+
import { createContentHoverWidgetPatcher } from './content-hover-widget-patcher';
|
|
54
|
+
|
|
55
|
+
export const contentHoverWidgetPatcher = createContentHoverWidgetPatcher();
|
|
68
56
|
|
|
69
57
|
class MonacoEditorServiceConstructor {
|
|
70
58
|
/**
|
|
@@ -118,6 +106,12 @@ class MonacoQuickInputImplementationConstructor {
|
|
|
118
106
|
}
|
|
119
107
|
}
|
|
120
108
|
|
|
109
|
+
class MonacoStandaloneThemeServiceConstructor {
|
|
110
|
+
constructor(container: Container) {
|
|
111
|
+
return new MonacoStandaloneThemeService();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
121
115
|
export namespace MonacoInit {
|
|
122
116
|
export function init(container: Container): void {
|
|
123
117
|
StandaloneServices.initialize({
|
|
@@ -128,7 +122,7 @@ export namespace MonacoInit {
|
|
|
128
122
|
[IBulkEditService.toString()]: new SyncDescriptor(MonacoBulkEditServiceConstructor, [container]),
|
|
129
123
|
[ICommandService.toString()]: new SyncDescriptor(MonacoCommandServiceConstructor, [container]),
|
|
130
124
|
[IQuickInputService.toString()]: new SyncDescriptor(MonacoQuickInputImplementationConstructor, [container]),
|
|
131
|
-
[IStandaloneThemeService.toString()]: new
|
|
125
|
+
[IStandaloneThemeService.toString()]: new SyncDescriptor(MonacoStandaloneThemeServiceConstructor, [])
|
|
132
126
|
});
|
|
133
127
|
}
|
|
134
128
|
}
|
|
@@ -31,17 +31,18 @@ import { MonacoResolvedKeybinding } from './monaco-resolved-keybinding';
|
|
|
31
31
|
import { IQuickAccessController } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/common/quickAccess';
|
|
32
32
|
import { QuickAccessController } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/browser/quickAccess';
|
|
33
33
|
import { IContextKey, IContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
|
|
34
|
-
import { IListOptions, List } from '@theia/monaco-editor-core/esm/vs/base/browser/ui/list/listWidget';
|
|
35
34
|
import * as monaco from '@theia/monaco-editor-core';
|
|
36
35
|
import { ResolvedKeybinding } from '@theia/monaco-editor-core/esm/vs/base/common/keybindings';
|
|
37
36
|
import { IInstantiationService } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiation';
|
|
38
37
|
import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
39
38
|
import { IMatch } from '@theia/monaco-editor-core/esm/vs/base/common/filters';
|
|
40
|
-
import { IListRenderer, IListVirtualDelegate } from '@theia/monaco-editor-core/esm/vs/base/browser/ui/list/list';
|
|
41
39
|
import { CancellationToken, Event } from '@theia/core';
|
|
42
40
|
import { MonacoColorRegistry } from './monaco-color-registry';
|
|
43
41
|
import { ThemeService } from '@theia/core/lib/browser/theming';
|
|
44
42
|
import { IStandaloneThemeService } from '@theia/monaco-editor-core/esm/vs/editor/standalone/common/standaloneTheme';
|
|
43
|
+
import { ILayoutService } from '@theia/monaco-editor-core/esm/vs/platform/layout/browser/layoutService';
|
|
44
|
+
import { IHoverDelegate, IHoverDelegateOptions } from '@theia/monaco-editor-core/esm/vs/base/browser/ui/hover/hoverDelegate';
|
|
45
|
+
import { IHoverWidget } from '@theia/monaco-editor-core/esm/vs/base/browser/ui/hover/hover';
|
|
45
46
|
|
|
46
47
|
// Copied from @vscode/src/vs/base/parts/quickInput/browser/quickInputList.ts
|
|
47
48
|
export interface IListElement {
|
|
@@ -59,8 +60,21 @@ export interface IListElement {
|
|
|
59
60
|
readonly fireButtonTriggered: (event: IQuickPickItemButtonEvent<IQuickPickItem>) => void;
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
class HoverDelegate implements IHoverDelegate {
|
|
64
|
+
showHover(options: IHoverDelegateOptions, focus?: boolean | undefined): IHoverWidget | undefined {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
onDidHideHover?: (() => void) | undefined;
|
|
68
|
+
delay: number;
|
|
69
|
+
placement?: 'mouse' | 'element' | undefined;
|
|
70
|
+
showNativeHover?: boolean | undefined;
|
|
71
|
+
|
|
72
|
+
}
|
|
62
73
|
@injectable()
|
|
63
74
|
export class MonacoQuickInputImplementation implements IQuickInputService {
|
|
75
|
+
get currentQuickInput(): IQuickInput | undefined {
|
|
76
|
+
return this.controller.currentQuickInput;
|
|
77
|
+
}
|
|
64
78
|
|
|
65
79
|
declare readonly _serviceBrand: undefined;
|
|
66
80
|
|
|
@@ -77,7 +91,6 @@ export class MonacoQuickInputImplementation implements IQuickInputService {
|
|
|
77
91
|
protected readonly themeService: ThemeService;
|
|
78
92
|
|
|
79
93
|
protected container: HTMLElement;
|
|
80
|
-
private quickInputList: List<unknown>;
|
|
81
94
|
|
|
82
95
|
protected inQuickOpen: IContextKey<boolean>;
|
|
83
96
|
|
|
@@ -113,19 +126,19 @@ export class MonacoQuickInputImplementation implements IQuickInputService {
|
|
|
113
126
|
return this.controller.createQuickWidget();
|
|
114
127
|
}
|
|
115
128
|
|
|
116
|
-
createQuickPick<T extends IQuickPickItem>(): IQuickPick<T
|
|
117
|
-
|
|
129
|
+
createQuickPick<T extends IQuickPickItem>(options: { useSeparators: true; }): IQuickPick<T, { useSeparators: true; }>;
|
|
130
|
+
createQuickPick<T extends IQuickPickItem>(options: { useSeparators: false; }): IQuickPick<T, { useSeparators: false; }>;
|
|
131
|
+
createQuickPick<T extends IQuickPickItem>(options: { useSeparators: boolean }): IQuickPick<T, { useSeparators: true; }> | IQuickPick<T, { useSeparators: false; }> {
|
|
132
|
+
return this.controller.createQuickPick({
|
|
133
|
+
useSeparators: options.useSeparators
|
|
134
|
+
});
|
|
118
135
|
}
|
|
119
|
-
|
|
120
136
|
createInputBox(): IInputBox {
|
|
121
137
|
return this.controller.createInputBox();
|
|
122
138
|
}
|
|
123
139
|
|
|
124
140
|
open(filter: string): void {
|
|
125
141
|
this.quickAccess.show(filter);
|
|
126
|
-
setTimeout(() => {
|
|
127
|
-
this.quickInputList.focusNth(0);
|
|
128
|
-
}, 300);
|
|
129
142
|
}
|
|
130
143
|
|
|
131
144
|
input(options?: IInputOptions, token?: monaco.CancellationToken): Promise<string | undefined> {
|
|
@@ -185,21 +198,10 @@ export class MonacoQuickInputImplementation implements IQuickInputService {
|
|
|
185
198
|
}
|
|
186
199
|
|
|
187
200
|
private initController(): void {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
private updateLayout(): void {
|
|
193
|
-
// Initialize the layout using screen dimensions as monaco computes the actual sizing.
|
|
194
|
-
// https://github.com/microsoft/vscode/blob/6261075646f055b99068d3688932416f2346dd3b/src/vs/base/parts/quickinput/browser/quickInput.ts#L1799
|
|
195
|
-
this.controller.layout(this.getClientDimension(), 0);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
private getClientDimension(): monaco.editor.IDimension {
|
|
199
|
-
return { width: window.innerWidth, height: window.innerHeight };
|
|
200
|
-
}
|
|
201
|
+
const contextKeyService = StandaloneServices.get(IContextKeyService);
|
|
202
|
+
const instantiationService = StandaloneServices.get(IInstantiationService);
|
|
203
|
+
const layoutService = StandaloneServices.get(ILayoutService);
|
|
201
204
|
|
|
202
|
-
private getOptions(): IQuickInputOptions {
|
|
203
205
|
const options: IQuickInputOptions = {
|
|
204
206
|
idPrefix: 'quickInput_',
|
|
205
207
|
container: this.container,
|
|
@@ -208,14 +210,23 @@ export class MonacoQuickInputImplementation implements IQuickInputService {
|
|
|
208
210
|
backKeybindingLabel: () => undefined,
|
|
209
211
|
setContextKey: (id?: string) => this.setContextKey(id),
|
|
210
212
|
returnFocus: () => this.container.focus(),
|
|
211
|
-
|
|
212
|
-
user: string, container: HTMLElement, delegate: IListVirtualDelegate<T>, renderers: IListRenderer<T, unknown>[], listOptions: IListOptions<T>
|
|
213
|
-
): List<T> => this.quickInputList = new List(user, container, delegate, renderers, listOptions),
|
|
213
|
+
hoverDelegate: new HoverDelegate(),
|
|
214
214
|
linkOpenerDelegate: () => {
|
|
215
215
|
// @monaco-uplift: not sure what to do here
|
|
216
216
|
}
|
|
217
217
|
};
|
|
218
|
-
|
|
218
|
+
this.controller = new QuickInputController(options, layoutService, instantiationService, contextKeyService);
|
|
219
|
+
this.updateLayout();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
private updateLayout(): void {
|
|
223
|
+
// Initialize the layout using screen dimensions as monaco computes the actual sizing.
|
|
224
|
+
// https://github.com/microsoft/vscode/blob/6261075646f055b99068d3688932416f2346dd3b/src/vs/base/parts/quickinput/browser/quickInput.ts#L1799
|
|
225
|
+
this.controller.layout(this.getClientDimension(), 0);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private getClientDimension(): monaco.editor.IDimension {
|
|
229
|
+
return { width: window.innerWidth, height: window.innerHeight };
|
|
219
230
|
}
|
|
220
231
|
|
|
221
232
|
// @monaco-uplift
|
|
@@ -258,13 +269,18 @@ export class MonacoQuickInputImplementation implements IQuickInputService {
|
|
|
258
269
|
listInactiveSelectionForeground: this.colorRegistry.toCssVariableName('list.InactiveSelectionForeground'),
|
|
259
270
|
listHoverBackground: this.colorRegistry.toCssVariableName('list.HoverBackground'),
|
|
260
271
|
listHoverForeground: this.colorRegistry.toCssVariableName('list.HoverForeground'),
|
|
261
|
-
|
|
272
|
+
listDropOverBackground: this.colorRegistry.toCssVariableName('list.DropOverBackground'),
|
|
273
|
+
listDropBetweenBackground: this.colorRegistry.toCssVariableName('list.DropBetweenBackground'),
|
|
262
274
|
listSelectionOutline: this.colorRegistry.toCssVariableName('activeContrastBorder'),
|
|
263
275
|
listHoverOutline: this.colorRegistry.toCssVariableName('activeContrastBorder'),
|
|
264
276
|
treeIndentGuidesStroke: this.colorRegistry.toCssVariableName('tree.indentGuidesStroke'),
|
|
265
277
|
treeInactiveIndentGuidesStroke: this.colorRegistry.toCssVariableName('tree.inactiveIndentGuidesStroke'),
|
|
278
|
+
treeStickyScrollBackground: this.colorRegistry.toCssVariableName('tree.StickyScrollBackground'),
|
|
279
|
+
treeStickyScrollBorder: this.colorRegistry.toCssVariableName('tree.tickyScrollBorde'),
|
|
280
|
+
treeStickyScrollShadow: this.colorRegistry.toCssVariableName('tree.StickyScrollShadow'),
|
|
266
281
|
tableColumnsBorder: this.colorRegistry.toCssVariableName('tree.tableColumnsBorder'),
|
|
267
282
|
tableOddRowsBackgroundColor: this.colorRegistry.toCssVariableName('tree.tableOddRowsBackground'),
|
|
283
|
+
|
|
268
284
|
},
|
|
269
285
|
inputBox: {
|
|
270
286
|
inputForeground: this.colorRegistry.toCssVariableName('inputForeground'),
|
|
@@ -434,11 +450,11 @@ export class MonacoQuickInputService implements QuickInputService {
|
|
|
434
450
|
}
|
|
435
451
|
|
|
436
452
|
createQuickPick<T extends QuickPickItem>(): QuickPick<T> {
|
|
437
|
-
const quickPick = this.monacoService.createQuickPick<MonacoQuickPickItem<T>>();
|
|
453
|
+
const quickPick = this.monacoService.createQuickPick<MonacoQuickPickItem<T>>({ useSeparators: true });
|
|
438
454
|
return this.wrapQuickPick(quickPick);
|
|
439
455
|
}
|
|
440
456
|
|
|
441
|
-
wrapQuickPick<T extends QuickPickItem>(wrapped: IQuickPick<MonacoQuickPickItem<T
|
|
457
|
+
wrapQuickPick<T extends QuickPickItem>(wrapped: IQuickPick<MonacoQuickPickItem<T>, { useSeparators: true }>): QuickPick<T> {
|
|
442
458
|
return new MonacoQuickPick(wrapped, this.keybindingRegistry);
|
|
443
459
|
}
|
|
444
460
|
|
|
@@ -532,7 +548,7 @@ class MonacoQuickInput {
|
|
|
532
548
|
}
|
|
533
549
|
|
|
534
550
|
class MonacoQuickPick<T extends QuickPickItem> extends MonacoQuickInput implements QuickPick<T> {
|
|
535
|
-
constructor(protected override readonly wrapped: IQuickPick<MonacoQuickPickItem<T
|
|
551
|
+
constructor(protected override readonly wrapped: IQuickPick<MonacoQuickPickItem<T>, { useSeparators: true }>, protected readonly keybindingRegistry: KeybindingRegistry) {
|
|
536
552
|
super(wrapped);
|
|
537
553
|
}
|
|
538
554
|
|
|
@@ -221,14 +221,16 @@ export class MonacoWorkspace {
|
|
|
221
221
|
* Applies given edits to the given model.
|
|
222
222
|
* The model is saved if no editors is opened for it.
|
|
223
223
|
*/
|
|
224
|
-
applyBackgroundEdit(model: MonacoEditorModel, editOperations: monaco.editor.IIdentifiedSingleEditOperation[],
|
|
224
|
+
applyBackgroundEdit(model: MonacoEditorModel, editOperations: monaco.editor.IIdentifiedSingleEditOperation[],
|
|
225
|
+
shouldSave?: boolean | ((openEditor: MonacoEditor | undefined, wasDirty: boolean) => boolean)): Promise<void> {
|
|
225
226
|
return this.suppressOpenIfDirty(model, async () => {
|
|
226
227
|
const editor = MonacoEditor.findByDocument(this.editorManager, model)[0];
|
|
228
|
+
const wasDirty = !!editor?.document.dirty;
|
|
227
229
|
const cursorState = editor && editor.getControl().getSelections() || [];
|
|
228
230
|
model.textEditorModel.pushStackElement();
|
|
229
231
|
model.textEditorModel.pushEditOperations(cursorState, editOperations, () => cursorState);
|
|
230
232
|
model.textEditorModel.pushStackElement();
|
|
231
|
-
if (!editor && shouldSave) {
|
|
233
|
+
if ((typeof shouldSave === 'function' && shouldSave(editor, wasDirty)) || (!editor && shouldSave)) {
|
|
232
234
|
await model.save();
|
|
233
235
|
}
|
|
234
236
|
});
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { EditorServiceOverrides, MonacoEditor, MonacoEditorServices } from './monaco-editor';
|
|
18
18
|
|
|
19
|
-
import { CodeEditorWidget, ICodeEditorWidgetOptions } from '@theia/monaco-editor-core/esm/vs/editor/browser/widget/codeEditorWidget';
|
|
19
|
+
import { CodeEditorWidget, ICodeEditorWidgetOptions } from '@theia/monaco-editor-core/esm/vs/editor/browser/widget/codeEditor/codeEditorWidget';
|
|
20
20
|
import { IInstantiationService } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiation';
|
|
21
21
|
import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
22
22
|
import { ServiceCollection } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/serviceCollection';
|
|
@@ -27,6 +27,7 @@ import * as monaco from '@theia/monaco-editor-core';
|
|
|
27
27
|
import { ElementExt } from '@theia/core/shared/@phosphor/domutils';
|
|
28
28
|
import { Selection } from '@theia/editor/lib/browser/editor';
|
|
29
29
|
import { SelectionDirection } from '@theia/monaco-editor-core/esm/vs/editor/common/core/selection';
|
|
30
|
+
import { ShowLightbulbIconMode } from '@theia/monaco-editor-core/esm/vs/editor/common/config/editorOptions';
|
|
30
31
|
|
|
31
32
|
export class SimpleMonacoEditor extends MonacoEditorServices implements Disposable {
|
|
32
33
|
|
|
@@ -87,7 +88,7 @@ export class SimpleMonacoEditor extends MonacoEditorServices implements Disposab
|
|
|
87
88
|
protected create(options?: MonacoEditor.IOptions, override?: EditorServiceOverrides, widgetOptions?: ICodeEditorWidgetOptions): Disposable {
|
|
88
89
|
const combinedOptions = {
|
|
89
90
|
...options,
|
|
90
|
-
lightbulb: { enabled:
|
|
91
|
+
lightbulb: { enabled: ShowLightbulbIconMode.On },
|
|
91
92
|
fixedOverflowWidgets: true,
|
|
92
93
|
automaticLayout: true,
|
|
93
94
|
scrollbar: {
|