@codingame/monaco-vscode-host-service-override 4.1.0 → 4.1.2
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.
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function __decorate(decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
}
|
|
7
|
+
function __param(paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { __decorate, __param };
|
package/host.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
2
2
|
import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host';
|
|
3
3
|
import { IHostColorSchemeService } from 'vscode/vscode/vs/workbench/services/themes/common/hostColorSchemeService';
|
|
4
|
-
import { BrowserHostService } from 'vscode/
|
|
4
|
+
import { BrowserHostService } from './vscode/src/vs/workbench/services/host/browser/browserHostService.js';
|
|
5
5
|
import { BrowserHostColorSchemeService } from './vscode/src/vs/workbench/services/themes/browser/browserHostColorSchemeService.js';
|
|
6
6
|
|
|
7
7
|
function getServiceOverride() {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { AbstractDialogHandler, IDialogService, IFileDialogService, getFileNamesMessage } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
2
|
+
|
|
3
|
+
var ConfirmResult;
|
|
4
|
+
( (function(ConfirmResult) {
|
|
5
|
+
ConfirmResult[ConfirmResult["SAVE"] = 0] = "SAVE";
|
|
6
|
+
ConfirmResult[ConfirmResult["DONT_SAVE"] = 1] = "DONT_SAVE";
|
|
7
|
+
ConfirmResult[ConfirmResult["CANCEL"] = 2] = "CANCEL";
|
|
8
|
+
})(ConfirmResult || (ConfirmResult = {})));
|
|
9
|
+
|
|
10
|
+
export { ConfirmResult };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-host-service-override",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.2",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
"module": "index.js",
|
|
19
19
|
"types": "index.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"vscode": "npm:@codingame/monaco-vscode-api@4.1.
|
|
21
|
+
"vscode": "npm:@codingame/monaco-vscode-api@4.1.2"
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
|
|
3
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
4
|
+
import { ILayoutService } from 'vscode/vscode/vs/platform/layout/browser/layoutService';
|
|
5
|
+
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
6
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
7
|
+
import { isFolderToOpen, isWorkspaceToOpen, isFileToOpen } from 'vscode/vscode/vs/platform/window/common/window';
|
|
8
|
+
import { pathsToEditors, isResourceEditorInput } from 'vscode/vscode/vs/workbench/common/editor';
|
|
9
|
+
import { whenEditorClosed } from 'vscode/vscode/vs/workbench/browser/editor';
|
|
10
|
+
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
|
|
11
|
+
import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label';
|
|
12
|
+
import { ModifierKeyEmitter, onDidRegisterWindow, trackFocus, getActiveDocument, getWindowId, disposableWindowInterval, EventType, addDisposableListener, addDisposableThrottledListener, detectFullscreen } from 'vscode/vscode/vs/base/browser/dom';
|
|
13
|
+
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
14
|
+
import { IBrowserWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/browser/environmentService';
|
|
15
|
+
import { memoize } from 'vscode/vscode/vs/base/common/decorators';
|
|
16
|
+
import { parseLineAndColumnAware } from 'vscode/vscode/vs/base/common/extpath';
|
|
17
|
+
import { IWorkspaceEditingService } from 'vscode/vscode/vs/workbench/services/workspaces/common/workspaceEditing';
|
|
18
|
+
import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
|
|
19
|
+
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
|
|
20
|
+
import { getWorkspaceIdentifier } from 'vscode/vscode/vs/workbench/services/workspaces/browser/workspaces';
|
|
21
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
22
|
+
import Severity$1 from 'vscode/vscode/vs/base/common/severity';
|
|
23
|
+
import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
24
|
+
import { DomEmitter } from 'vscode/vscode/vs/base/browser/event';
|
|
25
|
+
import { isUndefined } from 'vscode/vscode/vs/base/common/types';
|
|
26
|
+
import { isTemporaryWorkspace, IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
|
|
27
|
+
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
28
|
+
import { IUserDataProfileService } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile';
|
|
29
|
+
import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
|
|
30
|
+
import { mainWindow, isAuxiliaryWindow } from 'vscode/vscode/vs/base/browser/window';
|
|
31
|
+
import { isIOS, isMacintosh } from 'vscode/vscode/vs/base/common/platform';
|
|
32
|
+
import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
33
|
+
|
|
34
|
+
var HostShutdownReason;
|
|
35
|
+
( (function(HostShutdownReason) {
|
|
36
|
+
HostShutdownReason[HostShutdownReason["Unknown"] = 1] = "Unknown";
|
|
37
|
+
HostShutdownReason[HostShutdownReason["Keyboard"] = 2] = "Keyboard";
|
|
38
|
+
HostShutdownReason[HostShutdownReason["Api"] = 3] = "Api";
|
|
39
|
+
})(HostShutdownReason || (HostShutdownReason = {})));
|
|
40
|
+
let BrowserHostService = class BrowserHostService extends Disposable {
|
|
41
|
+
constructor(layoutService, configurationService, fileService, labelService, environmentService, instantiationService, lifecycleService, logService, dialogService, contextService, userDataProfileService) {
|
|
42
|
+
super();
|
|
43
|
+
this.layoutService = layoutService;
|
|
44
|
+
this.configurationService = configurationService;
|
|
45
|
+
this.fileService = fileService;
|
|
46
|
+
this.labelService = labelService;
|
|
47
|
+
this.environmentService = environmentService;
|
|
48
|
+
this.instantiationService = instantiationService;
|
|
49
|
+
this.lifecycleService = lifecycleService;
|
|
50
|
+
this.logService = logService;
|
|
51
|
+
this.dialogService = dialogService;
|
|
52
|
+
this.contextService = contextService;
|
|
53
|
+
this.userDataProfileService = userDataProfileService;
|
|
54
|
+
this.shutdownReason = HostShutdownReason.Unknown;
|
|
55
|
+
if (environmentService.options?.workspaceProvider) {
|
|
56
|
+
this.workspaceProvider = environmentService.options.workspaceProvider;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this.workspaceProvider = new class {
|
|
60
|
+
constructor() {
|
|
61
|
+
this.workspace = undefined;
|
|
62
|
+
this.trusted = undefined;
|
|
63
|
+
}
|
|
64
|
+
async open() { return true; }
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
this.registerListeners();
|
|
68
|
+
}
|
|
69
|
+
registerListeners() {
|
|
70
|
+
this._register(this.lifecycleService.onBeforeShutdown(e => this.onBeforeShutdown(e)));
|
|
71
|
+
this._register(ModifierKeyEmitter.getInstance().event(() => this.updateShutdownReasonFromEvent()));
|
|
72
|
+
}
|
|
73
|
+
onBeforeShutdown(e) {
|
|
74
|
+
switch (this.shutdownReason) {
|
|
75
|
+
case HostShutdownReason.Unknown:
|
|
76
|
+
case HostShutdownReason.Keyboard: {
|
|
77
|
+
const confirmBeforeClose = this.configurationService.getValue('window.confirmBeforeClose');
|
|
78
|
+
if (confirmBeforeClose === 'always' || (confirmBeforeClose === 'keyboardOnly' && this.shutdownReason === HostShutdownReason.Keyboard)) {
|
|
79
|
+
e.veto(true, 'veto.confirmBeforeClose');
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
this.shutdownReason = HostShutdownReason.Unknown;
|
|
85
|
+
}
|
|
86
|
+
updateShutdownReasonFromEvent() {
|
|
87
|
+
if (this.shutdownReason === HostShutdownReason.Api) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (ModifierKeyEmitter.getInstance().isModifierPressed) {
|
|
91
|
+
this.shutdownReason = HostShutdownReason.Keyboard;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
this.shutdownReason = HostShutdownReason.Unknown;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
get onDidChangeFocus() {
|
|
98
|
+
const emitter = this._register(( new Emitter()));
|
|
99
|
+
this._register(Event.runAndSubscribe(onDidRegisterWindow, ({ window, disposables }) => {
|
|
100
|
+
const focusTracker = disposables.add(trackFocus(window));
|
|
101
|
+
const visibilityTracker = disposables.add(( new DomEmitter(window.document, 'visibilitychange')));
|
|
102
|
+
Event.any(( Event.map(focusTracker.onDidFocus, () => this.hasFocus, disposables)), ( Event.map(focusTracker.onDidBlur, () => this.hasFocus, disposables)), ( Event.map(visibilityTracker.event, () => this.hasFocus, disposables)), ( Event.map(this.onDidChangeActiveWindow, () => this.hasFocus, disposables)))(focus => emitter.fire(focus));
|
|
103
|
+
}, { window: mainWindow, disposables: this._store }));
|
|
104
|
+
return Event.latch(emitter.event, undefined, this._store);
|
|
105
|
+
}
|
|
106
|
+
get hasFocus() {
|
|
107
|
+
return getActiveDocument().hasFocus();
|
|
108
|
+
}
|
|
109
|
+
async hadLastFocus() {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
async focus(targetWindow) {
|
|
113
|
+
targetWindow.focus();
|
|
114
|
+
}
|
|
115
|
+
get onDidChangeActiveWindow() {
|
|
116
|
+
const emitter = this._register(( new Emitter()));
|
|
117
|
+
this._register(Event.runAndSubscribe(onDidRegisterWindow, ({ window, disposables }) => {
|
|
118
|
+
const windowId = getWindowId(window);
|
|
119
|
+
const focusTracker = disposables.add(trackFocus(window));
|
|
120
|
+
disposables.add(focusTracker.onDidFocus(() => emitter.fire(windowId)));
|
|
121
|
+
if (isAuxiliaryWindow(window)) {
|
|
122
|
+
disposables.add(disposableWindowInterval(window, () => {
|
|
123
|
+
const hasFocus = window.document.hasFocus();
|
|
124
|
+
if (hasFocus) {
|
|
125
|
+
emitter.fire(windowId);
|
|
126
|
+
}
|
|
127
|
+
return hasFocus;
|
|
128
|
+
}, 100, 20));
|
|
129
|
+
}
|
|
130
|
+
}, { window: mainWindow, disposables: this._store }));
|
|
131
|
+
return Event.latch(emitter.event, undefined, this._store);
|
|
132
|
+
}
|
|
133
|
+
get onDidChangeFullScreen() {
|
|
134
|
+
const emitter = this._register(( new Emitter()));
|
|
135
|
+
this._register(Event.runAndSubscribe(onDidRegisterWindow, ({ window, disposables }) => {
|
|
136
|
+
const windowId = getWindowId(window);
|
|
137
|
+
const viewport = isIOS && window.visualViewport ? window.visualViewport : window ;
|
|
138
|
+
const isFullScreen = () => {
|
|
139
|
+
const fullScreen = detectFullscreen(window);
|
|
140
|
+
return fullScreen !== null && !fullScreen.guess;
|
|
141
|
+
};
|
|
142
|
+
for (const event of [EventType.FULLSCREEN_CHANGE, EventType.WK_FULLSCREEN_CHANGE]) {
|
|
143
|
+
disposables.add(addDisposableListener(window.document, event, () => emitter.fire({ windowId, fullscreen: isFullScreen() })));
|
|
144
|
+
}
|
|
145
|
+
disposables.add(addDisposableThrottledListener(viewport, EventType.RESIZE, () => emitter.fire({ windowId, fullscreen: isFullScreen() }), undefined, isMacintosh ? 2000 : 800 ));
|
|
146
|
+
}, { window: mainWindow, disposables: this._store }));
|
|
147
|
+
return emitter.event;
|
|
148
|
+
}
|
|
149
|
+
openWindow(arg1, arg2) {
|
|
150
|
+
if (Array.isArray(arg1)) {
|
|
151
|
+
return this.doOpenWindow(arg1, arg2);
|
|
152
|
+
}
|
|
153
|
+
return this.doOpenEmptyWindow(arg1);
|
|
154
|
+
}
|
|
155
|
+
async doOpenWindow(toOpen, options) {
|
|
156
|
+
const payload = this.preservePayload(false );
|
|
157
|
+
const fileOpenables = [];
|
|
158
|
+
const foldersToAdd = [];
|
|
159
|
+
for (const openable of toOpen) {
|
|
160
|
+
openable.label = openable.label || this.getRecentLabel(openable);
|
|
161
|
+
if (isFolderToOpen(openable)) {
|
|
162
|
+
if (options?.addMode) {
|
|
163
|
+
foldersToAdd.push(({ uri: openable.folderUri }));
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
this.doOpen({ folderUri: openable.folderUri }, { reuse: this.shouldReuse(options, false ), payload });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else if (isWorkspaceToOpen(openable)) {
|
|
170
|
+
this.doOpen({ workspaceUri: openable.workspaceUri }, { reuse: this.shouldReuse(options, false ), payload });
|
|
171
|
+
}
|
|
172
|
+
else if (isFileToOpen(openable)) {
|
|
173
|
+
fileOpenables.push(openable);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (foldersToAdd.length > 0) {
|
|
177
|
+
this.withServices(accessor => {
|
|
178
|
+
const workspaceEditingService = accessor.get(IWorkspaceEditingService);
|
|
179
|
+
workspaceEditingService.addFolders(foldersToAdd);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
if (fileOpenables.length > 0) {
|
|
183
|
+
this.withServices(async (accessor) => {
|
|
184
|
+
const editorService = accessor.get(IEditorService);
|
|
185
|
+
if (options?.mergeMode && fileOpenables.length === 4) {
|
|
186
|
+
const editors = coalesce(await pathsToEditors(fileOpenables, this.fileService, this.logService));
|
|
187
|
+
if (editors.length !== 4 || !isResourceEditorInput(editors[0]) || !isResourceEditorInput(editors[1]) || !isResourceEditorInput(editors[2]) || !isResourceEditorInput(editors[3])) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (this.shouldReuse(options, true )) {
|
|
191
|
+
editorService.openEditor({
|
|
192
|
+
input1: { resource: editors[0].resource },
|
|
193
|
+
input2: { resource: editors[1].resource },
|
|
194
|
+
base: { resource: editors[2].resource },
|
|
195
|
+
result: { resource: editors[3].resource },
|
|
196
|
+
options: { pinned: true }
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
const environment = ( new Map());
|
|
201
|
+
environment.set('mergeFile1', ( editors[0].resource.toString()));
|
|
202
|
+
environment.set('mergeFile2', ( editors[1].resource.toString()));
|
|
203
|
+
environment.set('mergeFileBase', ( editors[2].resource.toString()));
|
|
204
|
+
environment.set('mergeFileResult', ( editors[3].resource.toString()));
|
|
205
|
+
this.doOpen(undefined, { payload: Array.from(environment.entries()) });
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else if (options?.diffMode && fileOpenables.length === 2) {
|
|
209
|
+
const editors = coalesce(await pathsToEditors(fileOpenables, this.fileService, this.logService));
|
|
210
|
+
if (editors.length !== 2 || !isResourceEditorInput(editors[0]) || !isResourceEditorInput(editors[1])) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (this.shouldReuse(options, true )) {
|
|
214
|
+
editorService.openEditor({
|
|
215
|
+
original: { resource: editors[0].resource },
|
|
216
|
+
modified: { resource: editors[1].resource },
|
|
217
|
+
options: { pinned: true }
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
const environment = ( new Map());
|
|
222
|
+
environment.set('diffFileSecondary', ( editors[0].resource.toString()));
|
|
223
|
+
environment.set('diffFilePrimary', ( editors[1].resource.toString()));
|
|
224
|
+
this.doOpen(undefined, { payload: Array.from(environment.entries()) });
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
for (const openable of fileOpenables) {
|
|
229
|
+
if (this.shouldReuse(options, true )) {
|
|
230
|
+
let openables = [];
|
|
231
|
+
if (options?.gotoLineMode) {
|
|
232
|
+
const pathColumnAware = parseLineAndColumnAware(openable.fileUri.path);
|
|
233
|
+
openables = [{
|
|
234
|
+
fileUri: openable.fileUri.with({ path: pathColumnAware.path }),
|
|
235
|
+
options: {
|
|
236
|
+
selection: !isUndefined(pathColumnAware.line) ? { startLineNumber: pathColumnAware.line, startColumn: pathColumnAware.column || 1 } : undefined
|
|
237
|
+
}
|
|
238
|
+
}];
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
openables = [openable];
|
|
242
|
+
}
|
|
243
|
+
editorService.openEditors(coalesce(await pathsToEditors(openables, this.fileService, this.logService)), undefined, { validateTrust: true });
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
const environment = ( new Map());
|
|
247
|
+
environment.set('openFile', ( openable.fileUri.toString()));
|
|
248
|
+
if (options?.gotoLineMode) {
|
|
249
|
+
environment.set('gotoLineMode', 'true');
|
|
250
|
+
}
|
|
251
|
+
this.doOpen(undefined, { payload: Array.from(environment.entries()) });
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const waitMarkerFileURI = options?.waitMarkerFileURI;
|
|
256
|
+
if (waitMarkerFileURI) {
|
|
257
|
+
(async () => {
|
|
258
|
+
await this.instantiationService.invokeFunction(accessor => whenEditorClosed(accessor, ( fileOpenables.map(fileOpenable => fileOpenable.fileUri))));
|
|
259
|
+
await this.fileService.del(waitMarkerFileURI);
|
|
260
|
+
})();
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
withServices(fn) {
|
|
266
|
+
this.instantiationService.invokeFunction(accessor => fn(accessor));
|
|
267
|
+
}
|
|
268
|
+
preservePayload(isEmptyWindow) {
|
|
269
|
+
const newPayload = ( new Array());
|
|
270
|
+
if (!isEmptyWindow && this.environmentService.extensionDevelopmentLocationURI) {
|
|
271
|
+
newPayload.push(['extensionDevelopmentPath', ( this.environmentService.extensionDevelopmentLocationURI.toString())]);
|
|
272
|
+
if (this.environmentService.debugExtensionHost.debugId) {
|
|
273
|
+
newPayload.push(['debugId', this.environmentService.debugExtensionHost.debugId]);
|
|
274
|
+
}
|
|
275
|
+
if (this.environmentService.debugExtensionHost.port) {
|
|
276
|
+
newPayload.push(['inspect-brk-extensions', String(this.environmentService.debugExtensionHost.port)]);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (!this.userDataProfileService.currentProfile.isDefault) {
|
|
280
|
+
newPayload.push(['lastActiveProfile', this.userDataProfileService.currentProfile.id]);
|
|
281
|
+
}
|
|
282
|
+
return newPayload.length ? newPayload : undefined;
|
|
283
|
+
}
|
|
284
|
+
getRecentLabel(openable) {
|
|
285
|
+
if (isFolderToOpen(openable)) {
|
|
286
|
+
return this.labelService.getWorkspaceLabel(openable.folderUri, { verbose: 2 });
|
|
287
|
+
}
|
|
288
|
+
if (isWorkspaceToOpen(openable)) {
|
|
289
|
+
return this.labelService.getWorkspaceLabel(getWorkspaceIdentifier(openable.workspaceUri), { verbose: 2 });
|
|
290
|
+
}
|
|
291
|
+
return this.labelService.getUriLabel(openable.fileUri);
|
|
292
|
+
}
|
|
293
|
+
shouldReuse(options = Object.create(null), isFile) {
|
|
294
|
+
if (options.waitMarkerFileURI) {
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
const windowConfig = this.configurationService.getValue('window');
|
|
298
|
+
const openInNewWindowConfig = isFile ? ((windowConfig?.openFilesInNewWindow || 'off') ) : ((windowConfig?.openFoldersInNewWindow || 'default') );
|
|
299
|
+
let openInNewWindow = (options.preferNewWindow || !!options.forceNewWindow) && !options.forceReuseWindow;
|
|
300
|
+
if (!options.forceNewWindow && !options.forceReuseWindow && (openInNewWindowConfig === 'on' || openInNewWindowConfig === 'off')) {
|
|
301
|
+
openInNewWindow = (openInNewWindowConfig === 'on');
|
|
302
|
+
}
|
|
303
|
+
return !openInNewWindow;
|
|
304
|
+
}
|
|
305
|
+
async doOpenEmptyWindow(options) {
|
|
306
|
+
return this.doOpen(undefined, {
|
|
307
|
+
reuse: options?.forceReuseWindow,
|
|
308
|
+
payload: this.preservePayload(true )
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
async doOpen(workspace, options) {
|
|
312
|
+
if (workspace && isFolderToOpen(workspace) && workspace.folderUri.scheme === Schemas.file && isTemporaryWorkspace(this.contextService.getWorkspace())) {
|
|
313
|
+
this.withServices(async (accessor) => {
|
|
314
|
+
const workspaceEditingService = accessor.get(IWorkspaceEditingService);
|
|
315
|
+
await workspaceEditingService.updateFolders(0, this.contextService.getWorkspace().folders.length, [{ uri: workspace.folderUri }]);
|
|
316
|
+
});
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (options?.reuse) {
|
|
320
|
+
await this.handleExpectedShutdown(4 );
|
|
321
|
+
}
|
|
322
|
+
const opened = await this.workspaceProvider.open(workspace, options);
|
|
323
|
+
if (!opened) {
|
|
324
|
+
const { confirmed } = await this.dialogService.confirm({
|
|
325
|
+
type: Severity$1.Warning,
|
|
326
|
+
message: ( localizeWithPath(
|
|
327
|
+
'vs/workbench/services/host/browser/browserHostService',
|
|
328
|
+
'unableToOpenExternal',
|
|
329
|
+
"The browser interrupted the opening of a new tab or window. Press 'Open' to open it anyway."
|
|
330
|
+
)),
|
|
331
|
+
primaryButton: ( localizeWithPath(
|
|
332
|
+
'vs/workbench/services/host/browser/browserHostService',
|
|
333
|
+
{ key: 'open', comment: ['&& denotes a mnemonic'] },
|
|
334
|
+
"&&Open"
|
|
335
|
+
))
|
|
336
|
+
});
|
|
337
|
+
if (confirmed) {
|
|
338
|
+
await this.workspaceProvider.open(workspace, options);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
async toggleFullScreen(targetWindow) {
|
|
343
|
+
const target = this.layoutService.getContainer(targetWindow);
|
|
344
|
+
if (targetWindow.document.fullscreen !== undefined) {
|
|
345
|
+
if (!targetWindow.document.fullscreen) {
|
|
346
|
+
try {
|
|
347
|
+
return await target.requestFullscreen();
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
this.logService.warn('toggleFullScreen(): requestFullscreen failed');
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
try {
|
|
355
|
+
return await targetWindow.document.exitFullscreen();
|
|
356
|
+
}
|
|
357
|
+
catch (error) {
|
|
358
|
+
this.logService.warn('toggleFullScreen(): exitFullscreen failed');
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (targetWindow.document.webkitIsFullScreen !== undefined) {
|
|
363
|
+
try {
|
|
364
|
+
if (!targetWindow.document.webkitIsFullScreen) {
|
|
365
|
+
target.webkitRequestFullscreen();
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
targetWindow.document.webkitExitFullscreen();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
catch {
|
|
372
|
+
this.logService.warn('toggleFullScreen(): requestFullscreen/exitFullscreen failed');
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
async moveTop(targetWindow) {
|
|
377
|
+
}
|
|
378
|
+
async getCursorScreenPoint() {
|
|
379
|
+
return undefined;
|
|
380
|
+
}
|
|
381
|
+
async restart() {
|
|
382
|
+
this.reload();
|
|
383
|
+
}
|
|
384
|
+
async reload() {
|
|
385
|
+
await this.handleExpectedShutdown(3 );
|
|
386
|
+
mainWindow.location.reload();
|
|
387
|
+
}
|
|
388
|
+
async close() {
|
|
389
|
+
await this.handleExpectedShutdown(1 );
|
|
390
|
+
mainWindow.close();
|
|
391
|
+
}
|
|
392
|
+
async withExpectedShutdown(expectedShutdownTask) {
|
|
393
|
+
const previousShutdownReason = this.shutdownReason;
|
|
394
|
+
try {
|
|
395
|
+
this.shutdownReason = HostShutdownReason.Api;
|
|
396
|
+
return await expectedShutdownTask();
|
|
397
|
+
}
|
|
398
|
+
finally {
|
|
399
|
+
this.shutdownReason = previousShutdownReason;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
async handleExpectedShutdown(reason) {
|
|
403
|
+
this.shutdownReason = HostShutdownReason.Api;
|
|
404
|
+
return this.lifecycleService.withExpectedShutdown(reason);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
BrowserHostService.__decorator = ( __decorate([
|
|
408
|
+
memoize
|
|
409
|
+
], BrowserHostService.prototype, "onDidChangeFocus", null));
|
|
410
|
+
BrowserHostService.__decorator = ( __decorate([
|
|
411
|
+
memoize
|
|
412
|
+
], BrowserHostService.prototype, "onDidChangeActiveWindow", null));
|
|
413
|
+
BrowserHostService.__decorator = ( __decorate([
|
|
414
|
+
memoize
|
|
415
|
+
], BrowserHostService.prototype, "onDidChangeFullScreen", null));
|
|
416
|
+
BrowserHostService = ( __decorate([
|
|
417
|
+
( __param(0, ILayoutService)),
|
|
418
|
+
( __param(1, IConfigurationService)),
|
|
419
|
+
( __param(2, IFileService)),
|
|
420
|
+
( __param(3, ILabelService)),
|
|
421
|
+
( __param(4, IBrowserWorkbenchEnvironmentService)),
|
|
422
|
+
( __param(5, IInstantiationService)),
|
|
423
|
+
( __param(6, ILifecycleService)),
|
|
424
|
+
( __param(7, ILogService)),
|
|
425
|
+
( __param(8, IDialogService)),
|
|
426
|
+
( __param(9, IWorkspaceContextService)),
|
|
427
|
+
( __param(10, IUserDataProfileService))
|
|
428
|
+
], BrowserHostService));
|
|
429
|
+
|
|
430
|
+
export { BrowserHostService };
|