@codingame/monaco-vscode-dialogs-service-override 25.1.2 → 26.0.0

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.
@@ -32,7 +32,25 @@ import { EditorOpenSource } from '@codingame/monaco-vscode-api/vscode/vs/platfor
32
32
  import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
33
33
 
34
34
  let AbstractFileDialogService = class AbstractFileDialogService {
35
- constructor(hostService, contextService, historyService, environmentService, instantiationService, configurationService, fileService, openerService, dialogService, languageService, workspacesService, labelService, pathService, commandService, editorService, codeEditorService, logService) {
35
+ constructor(
36
+ hostService,
37
+ contextService,
38
+ historyService,
39
+ environmentService,
40
+ instantiationService,
41
+ configurationService,
42
+ fileService,
43
+ openerService,
44
+ dialogService,
45
+ languageService,
46
+ workspacesService,
47
+ labelService,
48
+ pathService,
49
+ commandService,
50
+ editorService,
51
+ codeEditorService,
52
+ logService
53
+ ) {
36
54
  this.hostService = hostService;
37
55
  this.contextService = contextService;
38
56
  this.historyService = historyService;
@@ -51,44 +69,92 @@ let AbstractFileDialogService = class AbstractFileDialogService {
51
69
  this.codeEditorService = codeEditorService;
52
70
  this.logService = logService;
53
71
  }
54
- async defaultFilePath(schemeFilter = this.getSchemeFilterForWindow(), authorityFilter = this.getAuthorityFilterForWindow()) {
72
+ async defaultFilePath(
73
+ schemeFilter = this.getSchemeFilterForWindow(),
74
+ authorityFilter = this.getAuthorityFilterForWindow()
75
+ ) {
55
76
  let candidate = this.historyService.getLastActiveFile(schemeFilter, authorityFilter);
56
77
  if (!candidate) {
57
78
  candidate = this.historyService.getLastActiveWorkspaceRoot(schemeFilter, authorityFilter);
58
- }
59
- else {
79
+ if (candidate) {
80
+ this.logService.debug(
81
+ `[FileDialogService] Default file path using last active workspace root: ${candidate}`
82
+ );
83
+ }
84
+ } else {
85
+ this.logService.debug(
86
+ `[FileDialogService] Default file path using parent of last active file: ${candidate}`
87
+ );
60
88
  candidate = dirname(candidate);
61
89
  }
62
90
  if (!candidate) {
63
91
  candidate = await this.preferredHome(schemeFilter);
92
+ this.logService.debug(`[FileDialogService] Default file path using preferred home: ${candidate}`);
64
93
  }
65
94
  return candidate;
66
95
  }
67
- async defaultFolderPath(schemeFilter = this.getSchemeFilterForWindow(), authorityFilter = this.getAuthorityFilterForWindow()) {
96
+ async defaultFolderPath(
97
+ schemeFilter = this.getSchemeFilterForWindow(),
98
+ authorityFilter = this.getAuthorityFilterForWindow()
99
+ ) {
68
100
  let candidate = this.historyService.getLastActiveWorkspaceRoot(schemeFilter, authorityFilter);
69
101
  if (!candidate) {
70
102
  candidate = this.historyService.getLastActiveFile(schemeFilter, authorityFilter);
103
+ if (candidate) {
104
+ this.logService.debug(
105
+ `[FileDialogService] Default folder path using parent of last active file: ${candidate}`
106
+ );
107
+ }
108
+ } else {
109
+ this.logService.debug(
110
+ `[FileDialogService] Default folder path using last active workspace root: ${candidate}`
111
+ );
71
112
  }
72
113
  if (!candidate) {
73
- return this.preferredHome(schemeFilter);
114
+ const preferredHome = await this.preferredHome(schemeFilter);
115
+ this.logService.debug(
116
+ `[FileDialogService] Default folder path using preferred home: ${preferredHome}`
117
+ );
118
+ return preferredHome;
74
119
  }
75
120
  return dirname(candidate);
76
121
  }
77
122
  async preferredHome(schemeFilter = this.getSchemeFilterForWindow()) {
78
123
  const preferLocal = schemeFilter === Schemas.file;
79
- const preferredHomeConfig = this.configurationService.inspect('files.dialog.defaultPath');
124
+ const preferredHomeConfig = this.configurationService.inspect("files.dialog.defaultPath");
80
125
  const preferredHomeCandidate = preferLocal ? preferredHomeConfig.userLocalValue : preferredHomeConfig.userRemoteValue;
126
+ this.logService.debug(
127
+ `[FileDialogService] Preferred home: preferLocal=${preferLocal}, userLocalValue=${preferredHomeConfig.userLocalValue}, userRemoteValue=${preferredHomeConfig.userRemoteValue}`
128
+ );
81
129
  if (preferredHomeCandidate) {
82
130
  const isPreferredHomeCandidateAbsolute = preferLocal ? isAbsolute(preferredHomeCandidate) : (await this.pathService.path).isAbsolute(preferredHomeCandidate);
83
131
  if (isPreferredHomeCandidateAbsolute) {
84
132
  const preferredHomeNormalized = preferLocal ? normalize(preferredHomeCandidate) : (await this.pathService.path).normalize(preferredHomeCandidate);
85
- const preferredHome = toLocalResource(await this.pathService.fileURI(preferredHomeNormalized), this.environmentService.remoteAuthority, this.pathService.defaultUriScheme);
133
+ const preferredHome = toLocalResource(
134
+ await this.pathService.fileURI(preferredHomeNormalized),
135
+ this.environmentService.remoteAuthority,
136
+ this.pathService.defaultUriScheme
137
+ );
86
138
  if (await this.fileService.exists(preferredHome)) {
139
+ this.logService.debug(
140
+ `[FileDialogService] Preferred home using files.dialog.defaultPath setting: ${preferredHome}`
141
+ );
87
142
  return preferredHome;
88
143
  }
144
+ this.logService.debug(
145
+ `[FileDialogService] Preferred home files.dialog.defaultPath path does not exist: ${preferredHome}`
146
+ );
147
+ } else {
148
+ this.logService.debug(
149
+ `[FileDialogService] Preferred home files.dialog.defaultPath is not absolute: ${preferredHomeCandidate}`
150
+ );
89
151
  }
90
152
  }
91
- return this.pathService.userHome({ preferLocal });
153
+ const userHome = this.pathService.userHome({
154
+ preferLocal
155
+ });
156
+ this.logService.debug(`[FileDialogService] Preferred home using user home: ${userHome}`);
157
+ return userHome;
92
158
  }
93
159
  async defaultWorkspacePath(schemeFilter = this.getSchemeFilterForWindow()) {
94
160
  let defaultWorkspacePath;
@@ -105,14 +171,14 @@ let AbstractFileDialogService = class AbstractFileDialogService {
105
171
  }
106
172
  async showSaveConfirm(fileNamesOrResources) {
107
173
  if (this.skipDialogs()) {
108
- this.logService.trace('FileDialogService: refused to show save confirmation dialog in tests.');
174
+ this.logService.trace("FileDialogService: refused to show save confirmation dialog in tests.");
109
175
  return ConfirmResult.DONT_SAVE;
110
176
  }
111
177
  return this.doShowSaveConfirm(fileNamesOrResources);
112
178
  }
113
179
  skipDialogs() {
114
180
  if (this.environmentService.enableSmokeTestDriver) {
115
- this.logService.warn('DialogService: Dialog requested during smoke test.');
181
+ this.logService.warn("DialogService: Dialog requested during smoke test.");
116
182
  }
117
183
  return this.environmentService.isExtensionDevelopment && !!this.environmentService.extensionTestsLocationURI;
118
184
  }
@@ -121,38 +187,34 @@ let AbstractFileDialogService = class AbstractFileDialogService {
121
187
  return ConfirmResult.DONT_SAVE;
122
188
  }
123
189
  let message;
124
- let detail = ( localize(13840, "Your changes will be lost if you don't save them."));
190
+ let detail = ( localize(14227, "Your changes will be lost if you don't save them."));
125
191
  if (fileNamesOrResources.length === 1) {
126
192
  message = ( localize(
127
- 13841,
193
+ 14228,
128
194
  "Do you want to save the changes you made to {0}?",
129
- typeof fileNamesOrResources[0] === 'string' ? fileNamesOrResources[0] : basename(fileNamesOrResources[0])
195
+ typeof fileNamesOrResources[0] === "string" ? fileNamesOrResources[0] : basename(fileNamesOrResources[0])
130
196
  ));
131
- }
132
- else {
197
+ } else {
133
198
  message = ( localize(
134
- 13842,
199
+ 14229,
135
200
  "Do you want to save the changes to the following {0} files?",
136
201
  fileNamesOrResources.length
137
202
  ));
138
- detail = getFileNamesMessage(fileNamesOrResources) + '\n' + detail;
203
+ detail = getFileNamesMessage(fileNamesOrResources) + "\n" + detail;
139
204
  }
140
- const { result } = await this.dialogService.prompt({
205
+ const {
206
+ result
207
+ } = await this.dialogService.prompt({
141
208
  type: Severity.Warning,
142
209
  message,
143
210
  detail,
144
- buttons: [
145
- {
146
- label: fileNamesOrResources.length > 1 ?
147
- ( localize(13843, "&&Save All")) :
148
- ( localize(13844, "&&Save")),
149
- run: () => ConfirmResult.SAVE
150
- },
151
- {
152
- label: ( localize(13845, "Do&&n't Save")),
153
- run: () => ConfirmResult.DONT_SAVE
154
- }
155
- ],
211
+ buttons: [{
212
+ label: fileNamesOrResources.length > 1 ? ( localize(14230, "&&Save All")) : ( localize(14231, "&&Save")),
213
+ run: () => ConfirmResult.SAVE
214
+ }, {
215
+ label: ( localize(14232, "Do&&n't Save")),
216
+ run: () => ConfirmResult.DONT_SAVE
217
+ }],
156
218
  cancelButton: {
157
219
  run: () => ConfirmResult.CANCEL
158
220
  }
@@ -163,62 +225,135 @@ let AbstractFileDialogService = class AbstractFileDialogService {
163
225
  return schema === Schemas.untitled ? [Schemas.file] : (schema !== Schemas.file ? [schema, Schemas.file] : [schema]);
164
226
  }
165
227
  async pickFileFolderAndOpenSimplified(schema, options, preferNewWindow) {
166
- const title = ( localize(13846, 'Open File or Folder'));
228
+ const title = ( localize(14233, "Open File or Folder"));
167
229
  const availableFileSystems = this.addFileSchemaIfNeeded(schema);
168
- const uri = await this.pickResource({ canSelectFiles: true, canSelectFolders: true, canSelectMany: false, defaultUri: options.defaultUri, title, availableFileSystems });
230
+ const uri = await this.pickResource({
231
+ canSelectFiles: true,
232
+ canSelectFolders: true,
233
+ canSelectMany: false,
234
+ defaultUri: options.defaultUri,
235
+ title,
236
+ availableFileSystems
237
+ });
169
238
  if (uri) {
170
239
  const stat = await this.fileService.stat(uri);
171
- const toOpen = stat.isDirectory ? { folderUri: uri } : { fileUri: uri };
240
+ const toOpen = stat.isDirectory ? {
241
+ folderUri: uri
242
+ } : {
243
+ fileUri: uri
244
+ };
172
245
  if (!isWorkspaceToOpen(toOpen) && isFileToOpen(toOpen)) {
173
246
  this.addFileToRecentlyOpened(toOpen.fileUri);
174
247
  }
175
248
  if (stat.isDirectory || options.forceNewWindow || preferNewWindow) {
176
- await this.hostService.openWindow([toOpen], { forceNewWindow: options.forceNewWindow, remoteAuthority: options.remoteAuthority });
177
- }
178
- else {
179
- await this.editorService.openEditors([{ resource: uri, options: { source: EditorOpenSource.USER, pinned: true } }], undefined, { validateTrust: true });
249
+ await this.hostService.openWindow([toOpen], {
250
+ forceNewWindow: options.forceNewWindow,
251
+ remoteAuthority: options.remoteAuthority
252
+ });
253
+ } else {
254
+ await this.editorService.openEditors([{
255
+ resource: uri,
256
+ options: {
257
+ source: EditorOpenSource.USER,
258
+ pinned: true
259
+ }
260
+ }], undefined, {
261
+ validateTrust: true
262
+ });
180
263
  }
181
264
  }
182
265
  }
183
266
  async pickFileAndOpenSimplified(schema, options, preferNewWindow) {
184
- const title = ( localize(13847, 'Open File'));
267
+ const title = ( localize(14234, "Open File"));
185
268
  const availableFileSystems = this.addFileSchemaIfNeeded(schema);
186
- const uri = await this.pickResource({ canSelectFiles: true, canSelectFolders: false, canSelectMany: false, defaultUri: options.defaultUri, title, availableFileSystems });
269
+ const uri = await this.pickResource({
270
+ canSelectFiles: true,
271
+ canSelectFolders: false,
272
+ canSelectMany: false,
273
+ defaultUri: options.defaultUri,
274
+ title,
275
+ availableFileSystems
276
+ });
187
277
  if (uri) {
188
278
  this.addFileToRecentlyOpened(uri);
189
279
  if (options.forceNewWindow || preferNewWindow) {
190
- await this.hostService.openWindow([{ fileUri: uri }], { forceNewWindow: options.forceNewWindow, remoteAuthority: options.remoteAuthority });
191
- }
192
- else {
193
- await this.editorService.openEditors([{ resource: uri, options: { source: EditorOpenSource.USER, pinned: true } }], undefined, { validateTrust: true });
280
+ await this.hostService.openWindow([{
281
+ fileUri: uri
282
+ }], {
283
+ forceNewWindow: options.forceNewWindow,
284
+ remoteAuthority: options.remoteAuthority
285
+ });
286
+ } else {
287
+ await this.editorService.openEditors([{
288
+ resource: uri,
289
+ options: {
290
+ source: EditorOpenSource.USER,
291
+ pinned: true
292
+ }
293
+ }], undefined, {
294
+ validateTrust: true
295
+ });
194
296
  }
195
297
  }
196
298
  }
197
299
  addFileToRecentlyOpened(uri) {
198
- this.workspacesService.addRecentlyOpened([{ fileUri: uri, label: this.labelService.getUriLabel(uri, { appendWorkspaceSuffix: true }) }]);
300
+ this.workspacesService.addRecentlyOpened([{
301
+ fileUri: uri,
302
+ label: this.labelService.getUriLabel(uri, {
303
+ appendWorkspaceSuffix: true
304
+ })
305
+ }]);
199
306
  }
200
307
  async pickFolderAndOpenSimplified(schema, options) {
201
- const title = ( localize(13848, 'Open Folder'));
308
+ const title = ( localize(14235, "Open Folder"));
202
309
  const availableFileSystems = this.addFileSchemaIfNeeded(schema, true);
203
- const uri = await this.pickResource({ canSelectFiles: false, canSelectFolders: true, canSelectMany: false, defaultUri: options.defaultUri, title, availableFileSystems });
310
+ const uri = await this.pickResource({
311
+ canSelectFiles: false,
312
+ canSelectFolders: true,
313
+ canSelectMany: false,
314
+ defaultUri: options.defaultUri,
315
+ title,
316
+ availableFileSystems
317
+ });
204
318
  if (uri) {
205
- return this.hostService.openWindow([{ folderUri: uri }], { forceNewWindow: options.forceNewWindow, remoteAuthority: options.remoteAuthority });
319
+ return this.hostService.openWindow([{
320
+ folderUri: uri
321
+ }], {
322
+ forceNewWindow: options.forceNewWindow,
323
+ remoteAuthority: options.remoteAuthority
324
+ });
206
325
  }
207
326
  }
208
327
  async pickWorkspaceAndOpenSimplified(schema, options) {
209
- const title = ( localize(13849, 'Open Workspace from File'));
210
- const filters = [{ name: ( localize(13850, 'Workspace')), extensions: [WORKSPACE_EXTENSION] }];
328
+ const title = ( localize(14236, "Open Workspace from File"));
329
+ const filters = [{
330
+ name: ( localize(14237, "Workspace")),
331
+ extensions: [WORKSPACE_EXTENSION]
332
+ }];
211
333
  const availableFileSystems = this.addFileSchemaIfNeeded(schema, true);
212
- const uri = await this.pickResource({ canSelectFiles: true, canSelectFolders: false, canSelectMany: false, defaultUri: options.defaultUri, title, filters, availableFileSystems });
334
+ const uri = await this.pickResource({
335
+ canSelectFiles: true,
336
+ canSelectFolders: false,
337
+ canSelectMany: false,
338
+ defaultUri: options.defaultUri,
339
+ title,
340
+ filters,
341
+ availableFileSystems
342
+ });
213
343
  if (uri) {
214
- return this.hostService.openWindow([{ workspaceUri: uri }], { forceNewWindow: options.forceNewWindow, remoteAuthority: options.remoteAuthority });
344
+ return this.hostService.openWindow([{
345
+ workspaceUri: uri
346
+ }], {
347
+ forceNewWindow: options.forceNewWindow,
348
+ remoteAuthority: options.remoteAuthority
349
+ });
215
350
  }
216
351
  }
217
352
  async pickFileToSaveSimplified(schema, options) {
218
353
  if (!options.availableFileSystems) {
219
354
  options.availableFileSystems = this.addFileSchemaIfNeeded(schema);
220
355
  }
221
- options.title = ( localize(13851, 'Save As'));
356
+ options.title = ( localize(14238, "Save As"));
222
357
  const uri = await this.saveRemoteResource(options);
223
358
  if (uri) {
224
359
  this.addFileToRecentlyOpened(uri);
@@ -269,22 +404,30 @@ let AbstractFileDialogService = class AbstractFileDialogService {
269
404
  getPickFileToSaveDialogOptions(defaultUri, availableFileSystems) {
270
405
  const options = {
271
406
  defaultUri,
272
- title: ( localize(13852, "Save As")),
407
+ title: ( localize(14239, "Save As")),
273
408
  availableFileSystems
274
409
  };
275
410
  const ext = defaultUri ? extname(defaultUri) : undefined;
276
411
  let matchingFilter;
277
412
  const registeredLanguageNames = this.languageService.getSortedRegisteredLanguageNames();
278
- const registeredLanguageFilters = coalesce(( registeredLanguageNames.map(({ languageName, languageId }) => {
413
+ const registeredLanguageFilters = coalesce(( registeredLanguageNames.map((
414
+ {
415
+ languageName,
416
+ languageId
417
+ }
418
+ ) => {
279
419
  const extensions = this.languageService.getExtensions(languageId);
280
420
  if (!extensions.length) {
281
421
  return null;
282
422
  }
283
- const filter = { name: languageName, extensions: ( distinct(extensions).slice(0, 10).map(e => trim(e, '.'))) };
423
+ const filter = {
424
+ name: languageName,
425
+ extensions: ( distinct(extensions).slice(0, 10).map(e => trim(e, ".")))
426
+ };
284
427
  const extOrPlaintext = ext || PLAINTEXT_EXTENSION;
285
428
  if (!matchingFilter && extensions.includes(extOrPlaintext)) {
286
429
  matchingFilter = filter;
287
- const trimmedExt = trim(extOrPlaintext, '.');
430
+ const trimmedExt = trim(extOrPlaintext, ".");
288
431
  if (!filter.extensions.includes(trimmedExt)) {
289
432
  filter.extensions.unshift(trimmedExt);
290
433
  }
@@ -293,35 +436,21 @@ let AbstractFileDialogService = class AbstractFileDialogService {
293
436
  return filter;
294
437
  })));
295
438
  if (!matchingFilter && ext) {
296
- matchingFilter = { name: trim(ext, '.').toUpperCase(), extensions: [trim(ext, '.')] };
439
+ matchingFilter = {
440
+ name: trim(ext, ".").toUpperCase(),
441
+ extensions: [trim(ext, ".")]
442
+ };
297
443
  }
298
- options.filters = coalesce([
299
- { name: ( localize(13853, "All Files")), extensions: ['*'] },
300
- matchingFilter,
301
- ...registeredLanguageFilters,
302
- { name: ( localize(13854, "No Extension")), extensions: [''] }
303
- ]);
444
+ options.filters = coalesce([{
445
+ name: ( localize(14240, "All Files")),
446
+ extensions: ["*"]
447
+ }, matchingFilter, ...registeredLanguageFilters, {
448
+ name: ( localize(14241, "No Extension")),
449
+ extensions: [""]
450
+ }]);
304
451
  return options;
305
452
  }
306
453
  };
307
- AbstractFileDialogService = ( __decorate([
308
- ( __param(0, IHostService)),
309
- ( __param(1, IWorkspaceContextService)),
310
- ( __param(2, IHistoryService)),
311
- ( __param(3, IWorkbenchEnvironmentService)),
312
- ( __param(4, IInstantiationService)),
313
- ( __param(5, IConfigurationService)),
314
- ( __param(6, IFileService)),
315
- ( __param(7, IOpenerService)),
316
- ( __param(8, IDialogService)),
317
- ( __param(9, ILanguageService)),
318
- ( __param(10, IWorkspacesService)),
319
- ( __param(11, ILabelService)),
320
- ( __param(12, IPathService)),
321
- ( __param(13, ICommandService)),
322
- ( __param(14, IEditorService)),
323
- ( __param(15, ICodeEditorService)),
324
- ( __param(16, ILogService))
325
- ], AbstractFileDialogService));
454
+ AbstractFileDialogService = ( __decorate([( __param(0, IHostService)), ( __param(1, IWorkspaceContextService)), ( __param(2, IHistoryService)), ( __param(3, IWorkbenchEnvironmentService)), ( __param(4, IInstantiationService)), ( __param(5, IConfigurationService)), ( __param(6, IFileService)), ( __param(7, IOpenerService)), ( __param(8, IDialogService)), ( __param(9, ILanguageService)), ( __param(10, IWorkspacesService)), ( __param(11, ILabelService)), ( __param(12, IPathService)), ( __param(13, ICommandService)), ( __param(14, IEditorService)), ( __param(15, ICodeEditorService)), ( __param(16, ILogService))], AbstractFileDialogService));
326
455
 
327
456
  export { AbstractFileDialogService };