@codingame/monaco-vscode-dialogs-service-override 28.4.1 → 29.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.
- package/package.json +2 -2
- package/vscode/src/vs/workbench/browser/parts/dialogs/dialogHandler.js +1 -1
- package/vscode/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.js +23 -20
- package/vscode/src/vs/workbench/services/dialogs/browser/fileDialogService.js +8 -8
- package/vscode/src/vs/workbench/services/dialogs/browser/simpleFileDialog.d.ts +19 -2
- package/vscode/src/vs/workbench/services/dialogs/browser/simpleFileDialog.js +79 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-dialogs-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "29.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - dialogs service-override",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-api": "
|
|
18
|
+
"@codingame/monaco-vscode-api": "29.0.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"module": "index.js",
|
|
@@ -118,7 +118,7 @@ let BrowserDialogHandler = class BrowserDialogHandler extends AbstractDialogHand
|
|
|
118
118
|
async about(title, details, detailsToCopy) {
|
|
119
119
|
const {
|
|
120
120
|
button
|
|
121
|
-
} = await this.doShow(Severity.Info, title, [( localize(
|
|
121
|
+
} = await this.doShow(Severity.Info, title, [( localize(3107, "&&Copy")), ( localize(3108, "OK"))], details, 1);
|
|
122
122
|
if (button === 0) {
|
|
123
123
|
this.clipboardService.writeText(detailsToCopy);
|
|
124
124
|
}
|
|
@@ -202,16 +202,16 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
202
202
|
return ConfirmResult.DONT_SAVE;
|
|
203
203
|
}
|
|
204
204
|
let message;
|
|
205
|
-
let detail = ( localize(
|
|
205
|
+
let detail = ( localize(15840, "Your changes will be lost if you don't save them."));
|
|
206
206
|
if (fileNamesOrResources.length === 1) {
|
|
207
207
|
message = ( localize(
|
|
208
|
-
|
|
208
|
+
15841,
|
|
209
209
|
"Do you want to save the changes you made to {0}?",
|
|
210
210
|
typeof fileNamesOrResources[0] === "string" ? fileNamesOrResources[0] : basename(fileNamesOrResources[0])
|
|
211
211
|
));
|
|
212
212
|
} else {
|
|
213
213
|
message = ( localize(
|
|
214
|
-
|
|
214
|
+
15842,
|
|
215
215
|
"Do you want to save the changes to the following {0} files?",
|
|
216
216
|
fileNamesOrResources.length
|
|
217
217
|
));
|
|
@@ -224,10 +224,10 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
224
224
|
message,
|
|
225
225
|
detail,
|
|
226
226
|
buttons: [{
|
|
227
|
-
label: fileNamesOrResources.length > 1 ? ( localize(
|
|
227
|
+
label: fileNamesOrResources.length > 1 ? ( localize(15843, "&&Save All")) : ( localize(15844, "&&Save")),
|
|
228
228
|
run: () => ConfirmResult.SAVE
|
|
229
229
|
}, {
|
|
230
|
-
label: ( localize(
|
|
230
|
+
label: ( localize(15845, "Do&&n't Save")),
|
|
231
231
|
run: () => ConfirmResult.DONT_SAVE
|
|
232
232
|
}],
|
|
233
233
|
cancelButton: {
|
|
@@ -240,9 +240,9 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
240
240
|
return schema === Schemas.untitled ? [Schemas.file] : (schema !== Schemas.file ? [schema, Schemas.file] : [schema]);
|
|
241
241
|
}
|
|
242
242
|
async pickFileFolderAndOpenSimplified(schema, options, preferNewWindow) {
|
|
243
|
-
const title = ( localize(
|
|
243
|
+
const title = ( localize(15846, "Open File or Folder"));
|
|
244
244
|
const availableFileSystems = this.addFileSchemaIfNeeded(schema);
|
|
245
|
-
const
|
|
245
|
+
const uris = await this.pickResource({
|
|
246
246
|
canSelectFiles: true,
|
|
247
247
|
canSelectFolders: true,
|
|
248
248
|
canSelectMany: false,
|
|
@@ -250,6 +250,7 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
250
250
|
title,
|
|
251
251
|
availableFileSystems
|
|
252
252
|
});
|
|
253
|
+
const uri = uris?.[0];
|
|
253
254
|
if (uri) {
|
|
254
255
|
const stat = await this.fileService.stat(uri);
|
|
255
256
|
const toOpen = stat.isDirectory ? {
|
|
@@ -279,9 +280,9 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
279
280
|
}
|
|
280
281
|
}
|
|
281
282
|
async pickFileAndOpenSimplified(schema, options, preferNewWindow) {
|
|
282
|
-
const title = ( localize(
|
|
283
|
+
const title = ( localize(15847, "Open File"));
|
|
283
284
|
const availableFileSystems = this.addFileSchemaIfNeeded(schema);
|
|
284
|
-
const
|
|
285
|
+
const uris = await this.pickResource({
|
|
285
286
|
canSelectFiles: true,
|
|
286
287
|
canSelectFolders: false,
|
|
287
288
|
canSelectMany: false,
|
|
@@ -289,6 +290,7 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
289
290
|
title,
|
|
290
291
|
availableFileSystems
|
|
291
292
|
});
|
|
293
|
+
const uri = uris?.[0];
|
|
292
294
|
if (uri) {
|
|
293
295
|
this.addFileToRecentlyOpened(uri);
|
|
294
296
|
if (options.forceNewWindow || preferNewWindow) {
|
|
@@ -320,9 +322,9 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
320
322
|
}]);
|
|
321
323
|
}
|
|
322
324
|
async pickFolderAndOpenSimplified(schema, options) {
|
|
323
|
-
const title = ( localize(
|
|
325
|
+
const title = ( localize(15848, "Open Folder"));
|
|
324
326
|
const availableFileSystems = this.addFileSchemaIfNeeded(schema, true);
|
|
325
|
-
const
|
|
327
|
+
const uris = await this.pickResource({
|
|
326
328
|
canSelectFiles: false,
|
|
327
329
|
canSelectFolders: true,
|
|
328
330
|
canSelectMany: false,
|
|
@@ -330,6 +332,7 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
330
332
|
title,
|
|
331
333
|
availableFileSystems
|
|
332
334
|
});
|
|
335
|
+
const uri = uris?.[0];
|
|
333
336
|
if (uri) {
|
|
334
337
|
return this.hostService.openWindow([{
|
|
335
338
|
folderUri: uri
|
|
@@ -340,13 +343,13 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
340
343
|
}
|
|
341
344
|
}
|
|
342
345
|
async pickWorkspaceAndOpenSimplified(schema, options) {
|
|
343
|
-
const title = ( localize(
|
|
346
|
+
const title = ( localize(15849, "Open Workspace from File"));
|
|
344
347
|
const filters = [{
|
|
345
|
-
name: ( localize(
|
|
348
|
+
name: ( localize(15850, "Workspace")),
|
|
346
349
|
extensions: [WORKSPACE_EXTENSION]
|
|
347
350
|
}];
|
|
348
351
|
const availableFileSystems = this.addFileSchemaIfNeeded(schema, true);
|
|
349
|
-
const
|
|
352
|
+
const uris = await this.pickResource({
|
|
350
353
|
canSelectFiles: true,
|
|
351
354
|
canSelectFolders: false,
|
|
352
355
|
canSelectMany: false,
|
|
@@ -355,6 +358,7 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
355
358
|
filters,
|
|
356
359
|
availableFileSystems
|
|
357
360
|
});
|
|
361
|
+
const uri = uris?.[0];
|
|
358
362
|
if (uri) {
|
|
359
363
|
return this.hostService.openWindow([{
|
|
360
364
|
workspaceUri: uri
|
|
@@ -368,7 +372,7 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
368
372
|
if (!options.availableFileSystems) {
|
|
369
373
|
options.availableFileSystems = this.addFileSchemaIfNeeded(schema);
|
|
370
374
|
}
|
|
371
|
-
options.title = ( localize(
|
|
375
|
+
options.title = ( localize(15851, "Save As"));
|
|
372
376
|
const uri = await this.saveRemoteResource(options);
|
|
373
377
|
if (uri) {
|
|
374
378
|
this.addFileToRecentlyOpened(uri);
|
|
@@ -385,8 +389,7 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
385
389
|
if (!options.availableFileSystems) {
|
|
386
390
|
options.availableFileSystems = this.addFileSchemaIfNeeded(schema, options.canSelectFolders);
|
|
387
391
|
}
|
|
388
|
-
|
|
389
|
-
return uri ? [uri] : undefined;
|
|
392
|
+
return this.pickResource(options);
|
|
390
393
|
}
|
|
391
394
|
getSimpleFileDialog() {
|
|
392
395
|
return this.instantiationService.createInstance(SimpleFileDialog);
|
|
@@ -434,7 +437,7 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
434
437
|
getPickFileToSaveDialogOptions(defaultUri, availableFileSystems) {
|
|
435
438
|
const options = {
|
|
436
439
|
defaultUri,
|
|
437
|
-
title: ( localize(
|
|
440
|
+
title: ( localize(15852, "Save As")),
|
|
438
441
|
availableFileSystems
|
|
439
442
|
};
|
|
440
443
|
const ext = defaultUri ? extname(defaultUri) : undefined;
|
|
@@ -472,10 +475,10 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
472
475
|
};
|
|
473
476
|
}
|
|
474
477
|
options.filters = coalesce([{
|
|
475
|
-
name: ( localize(
|
|
478
|
+
name: ( localize(15853, "All Files")),
|
|
476
479
|
extensions: ["*"]
|
|
477
480
|
}, matchingFilter, ...registeredLanguageFilters, {
|
|
478
|
-
name: ( localize(
|
|
481
|
+
name: ( localize(15854, "No Extension")),
|
|
479
482
|
extensions: [""]
|
|
480
483
|
}]);
|
|
481
484
|
return options;
|
|
@@ -28,7 +28,7 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
28
28
|
if (this.shouldUseSimplified(schema)) {
|
|
29
29
|
return super.pickFileFolderAndOpenSimplified(schema, options, false);
|
|
30
30
|
}
|
|
31
|
-
throw ( new Error(( localize(
|
|
31
|
+
throw ( new Error(( localize(15855, "Can't open folders, try adding a folder to the workspace instead."))));
|
|
32
32
|
}
|
|
33
33
|
addFileSchemaIfNeeded(schema, isFolder) {
|
|
34
34
|
return (schema === Schemas.untitled) ? [Schemas.file] : (((schema !== Schemas.file) && (!isFolder || (schema !== Schemas.vscodeRemote))) ? [schema, Schemas.file] : [schema]);
|
|
@@ -73,7 +73,7 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
73
73
|
if (this.shouldUseSimplified(schema)) {
|
|
74
74
|
return super.pickFolderAndOpenSimplified(schema, options);
|
|
75
75
|
}
|
|
76
|
-
throw ( new Error(( localize(
|
|
76
|
+
throw ( new Error(( localize(15855, "Can't open folders, try adding a folder to the workspace instead."))));
|
|
77
77
|
}
|
|
78
78
|
async pickWorkspaceAndOpen(options) {
|
|
79
79
|
options.availableFileSystems = this.getWorkspaceAvailableFileSystems(options);
|
|
@@ -85,7 +85,7 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
85
85
|
return super.pickWorkspaceAndOpenSimplified(schema, options);
|
|
86
86
|
}
|
|
87
87
|
throw ( new Error(( localize(
|
|
88
|
-
|
|
88
|
+
15856,
|
|
89
89
|
"Can't open workspaces, try adding a folder to the workspace instead."
|
|
90
90
|
))));
|
|
91
91
|
}
|
|
@@ -213,19 +213,19 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
const buttons = [{
|
|
216
|
-
label: ( localize(
|
|
216
|
+
label: ( localize(15857, "&&Open Remote...")),
|
|
217
217
|
run: async () => {
|
|
218
218
|
await this.commandService.executeCommand("workbench.action.remote.showMenu");
|
|
219
219
|
}
|
|
220
220
|
}, {
|
|
221
|
-
label: ( localize(
|
|
221
|
+
label: ( localize(15858, "&&Learn More")),
|
|
222
222
|
run: async () => {
|
|
223
223
|
await this.openerService.open("https://aka.ms/VSCodeWebLocalFileSystemAccess");
|
|
224
224
|
}
|
|
225
225
|
}];
|
|
226
226
|
if (context === "open") {
|
|
227
227
|
buttons.push({
|
|
228
|
-
label: ( localize(
|
|
228
|
+
label: ( localize(15859, "Open &&Files...")),
|
|
229
229
|
run: async () => {
|
|
230
230
|
const files = await triggerUpload();
|
|
231
231
|
if (files) {
|
|
@@ -247,9 +247,9 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
247
247
|
}
|
|
248
248
|
await this.dialogService.prompt({
|
|
249
249
|
type: Severity.Warning,
|
|
250
|
-
message: ( localize(
|
|
250
|
+
message: ( localize(15860, "Opening Local Folders is Unsupported")),
|
|
251
251
|
detail: ( localize(
|
|
252
|
-
|
|
252
|
+
15861,
|
|
253
253
|
"Your browser doesn't support opening local folders.\nYou can either open single files or open a remote repository."
|
|
254
254
|
)),
|
|
255
255
|
buttons
|
|
@@ -40,7 +40,7 @@ export declare namespace OpenLocalFileFolderCommand {
|
|
|
40
40
|
}
|
|
41
41
|
export declare const RemoteFileDialogContext: RawContextKey<boolean>;
|
|
42
42
|
export interface ISimpleFileDialog extends IDisposable {
|
|
43
|
-
showOpenDialog(options: IOpenDialogOptions): Promise<URI | undefined>;
|
|
43
|
+
showOpenDialog(options: IOpenDialogOptions): Promise<URI[] | undefined>;
|
|
44
44
|
showSaveDialog(options: ISaveDialogOptions): Promise<URI | undefined>;
|
|
45
45
|
}
|
|
46
46
|
export declare class SimpleFileDialog extends Disposable implements ISimpleFileDialog {
|
|
@@ -78,6 +78,13 @@ export declare class SimpleFileDialog extends Disposable implements ISimpleFileD
|
|
|
78
78
|
private badPath;
|
|
79
79
|
private remoteAgentEnvironment;
|
|
80
80
|
private separator;
|
|
81
|
+
/**
|
|
82
|
+
* When set, the dialog is scoped to a specific URI authority (e.g.
|
|
83
|
+
* for browsing an `agenthost://{authority}/...` filesystem that
|
|
84
|
+
* uses per-connection authorities rather than the global
|
|
85
|
+
* {@link remoteAuthority}).
|
|
86
|
+
*/
|
|
87
|
+
private scopedAuthority;
|
|
81
88
|
private readonly onBusyChangeEmitter;
|
|
82
89
|
private updatingPromise;
|
|
83
90
|
private _showDotFiles;
|
|
@@ -86,13 +93,23 @@ export declare class SimpleFileDialog extends Disposable implements ISimpleFileD
|
|
|
86
93
|
private getShowDotFiles;
|
|
87
94
|
set busy(busy: boolean);
|
|
88
95
|
get busy(): boolean;
|
|
89
|
-
showOpenDialog(options?: IOpenDialogOptions): Promise<URI | undefined>;
|
|
96
|
+
showOpenDialog(options?: IOpenDialogOptions): Promise<URI[] | undefined>;
|
|
90
97
|
showSaveDialog(options: ISaveDialogOptions): Promise<URI | undefined>;
|
|
91
98
|
private getOptions;
|
|
92
99
|
private remoteUriFrom;
|
|
93
100
|
private getScheme;
|
|
101
|
+
/**
|
|
102
|
+
* Returns the per-URI authority from {@link defaultUri} if the dialog
|
|
103
|
+
* should be scoped to a specific authority (e.g. `agenthost://host/...`).
|
|
104
|
+
*
|
|
105
|
+
* Returns `undefined` when the authority matches the global
|
|
106
|
+
* {@link remoteAuthority} (standard SSH remotes), since that path is
|
|
107
|
+
* already handled by the existing logic.
|
|
108
|
+
*/
|
|
109
|
+
private getScopedAuthority;
|
|
94
110
|
private getRemoteAgentEnvironment;
|
|
95
111
|
protected getUserHome(trueHome?: boolean): Promise<URI>;
|
|
112
|
+
private normalizeUri;
|
|
96
113
|
private pickResource;
|
|
97
114
|
dispose(): void;
|
|
98
115
|
private handleValueChange;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
3
|
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
4
|
-
import { basename, joinPath, toLocalResource,
|
|
4
|
+
import { basename, joinPath, toLocalResource, addTrailingPathSeparator, removeTrailingPathSeparator, extname, dirname, extUriIgnorePathCase, relativePath, hasTrailingPathSeparator, isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
5
5
|
import { deepClone } from '@codingame/monaco-vscode-api/vscode/vs/base/common/objects';
|
|
6
6
|
import { FileKind } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
|
|
7
7
|
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
@@ -41,7 +41,7 @@ import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform
|
|
|
41
41
|
var OpenLocalFileCommand;
|
|
42
42
|
(function(OpenLocalFileCommand) {
|
|
43
43
|
OpenLocalFileCommand.ID = "workbench.action.files.openLocalFile";
|
|
44
|
-
OpenLocalFileCommand.LABEL = ( localize(
|
|
44
|
+
OpenLocalFileCommand.LABEL = ( localize(15862, "Open Local File..."));
|
|
45
45
|
function handler() {
|
|
46
46
|
return accessor => {
|
|
47
47
|
const dialogService = accessor.get(IFileDialogService);
|
|
@@ -56,7 +56,7 @@ var OpenLocalFileCommand;
|
|
|
56
56
|
var SaveLocalFileCommand;
|
|
57
57
|
(function(SaveLocalFileCommand) {
|
|
58
58
|
SaveLocalFileCommand.ID = "workbench.action.files.saveLocalFile";
|
|
59
|
-
SaveLocalFileCommand.LABEL = ( localize(
|
|
59
|
+
SaveLocalFileCommand.LABEL = ( localize(15863, "Save Local File..."));
|
|
60
60
|
function handler() {
|
|
61
61
|
return accessor => {
|
|
62
62
|
const editorService = accessor.get(IEditorService);
|
|
@@ -79,7 +79,7 @@ var SaveLocalFileCommand;
|
|
|
79
79
|
var OpenLocalFolderCommand;
|
|
80
80
|
(function(OpenLocalFolderCommand) {
|
|
81
81
|
OpenLocalFolderCommand.ID = "workbench.action.files.openLocalFolder";
|
|
82
|
-
OpenLocalFolderCommand.LABEL = ( localize(
|
|
82
|
+
OpenLocalFolderCommand.LABEL = ( localize(15864, "Open Local Folder..."));
|
|
83
83
|
function handler() {
|
|
84
84
|
return accessor => {
|
|
85
85
|
const dialogService = accessor.get(IFileDialogService);
|
|
@@ -94,7 +94,7 @@ var OpenLocalFolderCommand;
|
|
|
94
94
|
var OpenLocalFileFolderCommand;
|
|
95
95
|
(function(OpenLocalFileFolderCommand) {
|
|
96
96
|
OpenLocalFileFolderCommand.ID = "workbench.action.files.openLocalFileFolder";
|
|
97
|
-
OpenLocalFileFolderCommand.LABEL = ( localize(
|
|
97
|
+
OpenLocalFileFolderCommand.LABEL = ( localize(15865, "Open Local..."));
|
|
98
98
|
function handler() {
|
|
99
99
|
return accessor => {
|
|
100
100
|
const dialogService = accessor.get(IFileDialogService);
|
|
@@ -197,6 +197,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
197
197
|
}
|
|
198
198
|
async showOpenDialog(options = {}) {
|
|
199
199
|
this.scheme = this.getScheme(options.availableFileSystems, options.defaultUri);
|
|
200
|
+
this.scopedAuthority = this.getScopedAuthority(options.defaultUri);
|
|
200
201
|
this.userHome = await this.getUserHome();
|
|
201
202
|
this.trueHome = await this.getUserHome(true);
|
|
202
203
|
const newOptions = this.getOptions(options);
|
|
@@ -204,10 +205,15 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
204
205
|
return Promise.resolve(undefined);
|
|
205
206
|
}
|
|
206
207
|
this.options = newOptions;
|
|
207
|
-
|
|
208
|
+
const result = await this.pickResource();
|
|
209
|
+
if (Array.isArray(result)) {
|
|
210
|
+
return result;
|
|
211
|
+
}
|
|
212
|
+
return result ? [result] : undefined;
|
|
208
213
|
}
|
|
209
214
|
async showSaveDialog(options) {
|
|
210
215
|
this.scheme = this.getScheme(options.availableFileSystems, options.defaultUri);
|
|
216
|
+
this.scopedAuthority = this.getScopedAuthority(options.defaultUri);
|
|
211
217
|
this.userHome = await this.getUserHome();
|
|
212
218
|
this.trueHome = await this.getUserHome(true);
|
|
213
219
|
this.requiresTrailing = true;
|
|
@@ -219,8 +225,8 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
219
225
|
this.options.canSelectFolders = true;
|
|
220
226
|
this.options.canSelectFiles = true;
|
|
221
227
|
return ( new Promise(resolve => {
|
|
222
|
-
this.pickResource(true).then(
|
|
223
|
-
resolve(
|
|
228
|
+
this.pickResource(true).then(result => {
|
|
229
|
+
resolve(Array.isArray(result) ? result[0] : result);
|
|
224
230
|
});
|
|
225
231
|
}));
|
|
226
232
|
}
|
|
@@ -239,7 +245,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
239
245
|
}
|
|
240
246
|
if ((this.scheme !== Schemas.file) && !this.fileService.hasProvider(defaultUri)) {
|
|
241
247
|
this.notificationService.info(( localize(
|
|
242
|
-
|
|
248
|
+
15866,
|
|
243
249
|
"File system provider for {0} is not available.",
|
|
244
250
|
(defaultUri.toString())
|
|
245
251
|
)));
|
|
@@ -253,6 +259,15 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
253
259
|
if (!path.startsWith("\\\\")) {
|
|
254
260
|
path = path.replace(/\\/g, "/");
|
|
255
261
|
}
|
|
262
|
+
if (this.scopedAuthority) {
|
|
263
|
+
return ( URI.from({
|
|
264
|
+
scheme: this.scheme,
|
|
265
|
+
authority: this.scopedAuthority,
|
|
266
|
+
path,
|
|
267
|
+
query: hintUri?.query,
|
|
268
|
+
fragment: hintUri?.fragment
|
|
269
|
+
}));
|
|
270
|
+
}
|
|
256
271
|
const uri = this.scheme === Schemas.file ? URI.file(path) : ( URI.from({
|
|
257
272
|
scheme: this.scheme,
|
|
258
273
|
path,
|
|
@@ -277,6 +292,12 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
277
292
|
}
|
|
278
293
|
return Schemas.file;
|
|
279
294
|
}
|
|
295
|
+
getScopedAuthority(defaultUri) {
|
|
296
|
+
if (defaultUri && defaultUri.scheme === this.scheme && defaultUri.authority && defaultUri.authority !== this.remoteAuthority) {
|
|
297
|
+
return defaultUri.authority;
|
|
298
|
+
}
|
|
299
|
+
return undefined;
|
|
300
|
+
}
|
|
280
301
|
async getRemoteAgentEnvironment() {
|
|
281
302
|
if (this.remoteAgentEnvironment === undefined) {
|
|
282
303
|
this.remoteAgentEnvironment = await this.remoteAgentService.getEnvironment();
|
|
@@ -284,16 +305,28 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
284
305
|
return this.remoteAgentEnvironment;
|
|
285
306
|
}
|
|
286
307
|
getUserHome(trueHome = false) {
|
|
308
|
+
if (this.scopedAuthority) {
|
|
309
|
+
return Promise.resolve(( URI.from({
|
|
310
|
+
scheme: this.scheme,
|
|
311
|
+
authority: this.scopedAuthority,
|
|
312
|
+
path: "/"
|
|
313
|
+
})));
|
|
314
|
+
}
|
|
287
315
|
return trueHome ? this.pathService.userHome({
|
|
288
316
|
preferLocal: this.scheme === Schemas.file
|
|
289
317
|
}) : this.fileDialogService.preferredHome(this.scheme);
|
|
290
318
|
}
|
|
319
|
+
normalizeUri(uri) {
|
|
320
|
+
uri = addTrailingPathSeparator(uri, this.separator);
|
|
321
|
+
uri = removeTrailingPathSeparator(uri);
|
|
322
|
+
return uri;
|
|
323
|
+
}
|
|
291
324
|
async pickResource(isSave = false) {
|
|
292
325
|
this.allowFolderSelection = !!this.options.canSelectFolders;
|
|
293
326
|
this.allowFileSelection = !!this.options.canSelectFiles;
|
|
294
|
-
this.separator = this.labelService.getSeparator(this.scheme, this.remoteAuthority);
|
|
327
|
+
this.separator = this.scopedAuthority ? "/" : this.labelService.getSeparator(this.scheme, this.remoteAuthority);
|
|
295
328
|
this.hidden = false;
|
|
296
|
-
this.isWindows = await this.checkIsWindowsOS();
|
|
329
|
+
this.isWindows = this.scopedAuthority ? false : await this.checkIsWindowsOS();
|
|
297
330
|
let homedir = this.options.defaultUri ? this.options.defaultUri : this.workspaceContextService.getWorkspace().folders[0].uri;
|
|
298
331
|
let stat;
|
|
299
332
|
const ext = extname(homedir);
|
|
@@ -312,12 +345,12 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
312
345
|
this.filePickBox.matchOnLabel = false;
|
|
313
346
|
this.filePickBox.sortByLabel = false;
|
|
314
347
|
this.filePickBox.ignoreFocusOut = true;
|
|
315
|
-
this.filePickBox.placeholder = ( localize(
|
|
348
|
+
this.filePickBox.placeholder = ( localize(15867, "Folder path"));
|
|
316
349
|
this.filePickBox.ok = true;
|
|
317
350
|
this.filePickBox.okLabel = typeof this.options.openLabel === "string" ? this.options.openLabel : this.options.openLabel?.withoutMnemonic;
|
|
318
351
|
if ((this.scheme !== Schemas.file) && this.options && this.options.availableFileSystems && (this.options.availableFileSystems.length > 1) && (this.options.availableFileSystems.indexOf(Schemas.file) > -1)) {
|
|
319
352
|
this.filePickBox.customButton = true;
|
|
320
|
-
this.filePickBox.customLabel = ( localize(
|
|
353
|
+
this.filePickBox.customLabel = ( localize(15868, "Show Local"));
|
|
321
354
|
this.filePickBox.customButtonSecondary = true;
|
|
322
355
|
let action;
|
|
323
356
|
if (isSave) {
|
|
@@ -345,12 +378,15 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
345
378
|
this.filePickBox.title = this.options.title;
|
|
346
379
|
this.filePickBox.value = this.pathFromUri(this.currentFolder, true);
|
|
347
380
|
this.filePickBox.valueSelection = [this.filePickBox.value.length, this.filePickBox.value.length];
|
|
348
|
-
const doResolve =
|
|
349
|
-
if (
|
|
350
|
-
|
|
351
|
-
|
|
381
|
+
const doResolve = uriOrUris => {
|
|
382
|
+
if (uriOrUris) {
|
|
383
|
+
if (Array.isArray(uriOrUris)) {
|
|
384
|
+
uriOrUris = ( uriOrUris.map(uri => this.normalizeUri(uri)));
|
|
385
|
+
} else {
|
|
386
|
+
uriOrUris = this.normalizeUri(uriOrUris);
|
|
387
|
+
}
|
|
352
388
|
}
|
|
353
|
-
resolve(
|
|
389
|
+
resolve(uriOrUris);
|
|
354
390
|
this.contextKey.set(false);
|
|
355
391
|
this.dispose();
|
|
356
392
|
};
|
|
@@ -370,7 +406,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
370
406
|
});
|
|
371
407
|
} else {
|
|
372
408
|
return this.fileDialogService.showOpenDialog(this.options).then(result => {
|
|
373
|
-
doResolve(result
|
|
409
|
+
doResolve(result);
|
|
374
410
|
});
|
|
375
411
|
}
|
|
376
412
|
}));
|
|
@@ -465,7 +501,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
465
501
|
setButtons() {
|
|
466
502
|
this.filePickBox.buttons = [{
|
|
467
503
|
iconClass: this._showDotFiles ? ThemeIcon.asClassName(Codicon.eye) : ThemeIcon.asClassName(Codicon.eyeClosed),
|
|
468
|
-
tooltip: this._showDotFiles ? ( localize(
|
|
504
|
+
tooltip: this._showDotFiles ? ( localize(15869, "Hide dot files")) : ( localize(15870, "Show dot files")),
|
|
469
505
|
alwaysVisible: true
|
|
470
506
|
}];
|
|
471
507
|
}
|
|
@@ -620,7 +656,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
620
656
|
valueUri = this.tryAddTrailingSeparatorToDirectory(valueUri, stat);
|
|
621
657
|
return (await this.updateItems(valueUri)) ? UpdateResult.UpdatedWithTrailing : UpdateResult.Updated;
|
|
622
658
|
} else if (this.endsWithSlash(value)) {
|
|
623
|
-
this.filePickBox.validationMessage = ( localize(
|
|
659
|
+
this.filePickBox.validationMessage = ( localize(15871, "The path does not exist. Use ~ to go to your home directory."));
|
|
624
660
|
this.badPath = value;
|
|
625
661
|
return UpdateResult.InvalidPath;
|
|
626
662
|
} else {
|
|
@@ -784,7 +820,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
784
820
|
prompt.ignoreFocusOut = true;
|
|
785
821
|
prompt.ok = true;
|
|
786
822
|
prompt.customButton = true;
|
|
787
|
-
prompt.customLabel = ( localize(
|
|
823
|
+
prompt.customLabel = ( localize(15872, "Cancel"));
|
|
788
824
|
prompt.customButtonSecondary = true;
|
|
789
825
|
prompt.value = this.pathFromUri(uri);
|
|
790
826
|
let isResolving = false;
|
|
@@ -813,7 +849,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
813
849
|
}
|
|
814
850
|
async validate(uri) {
|
|
815
851
|
if (uri === undefined) {
|
|
816
|
-
this.filePickBox.validationMessage = ( localize(
|
|
852
|
+
this.filePickBox.validationMessage = ( localize(15873, "Please enter a valid path."));
|
|
817
853
|
return Promise.resolve(false);
|
|
818
854
|
}
|
|
819
855
|
let stat;
|
|
@@ -824,47 +860,47 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
824
860
|
} catch (e) {}
|
|
825
861
|
if (this.requiresTrailing) {
|
|
826
862
|
if (stat?.isDirectory) {
|
|
827
|
-
this.filePickBox.validationMessage = ( localize(
|
|
863
|
+
this.filePickBox.validationMessage = ( localize(15874, "The folder already exists. Please use a new file name."));
|
|
828
864
|
return Promise.resolve(false);
|
|
829
865
|
} else if (stat) {
|
|
830
866
|
const message = ( localize(
|
|
831
|
-
|
|
867
|
+
15875,
|
|
832
868
|
"{0} already exists. Are you sure you want to overwrite it?",
|
|
833
869
|
basename(uri)
|
|
834
870
|
));
|
|
835
871
|
return this.yesNoPrompt(uri, message);
|
|
836
872
|
} else if (!(isValidBasename(basename(uri), this.isWindows))) {
|
|
837
|
-
this.filePickBox.validationMessage = ( localize(
|
|
873
|
+
this.filePickBox.validationMessage = ( localize(15876, "Please enter a valid file name."));
|
|
838
874
|
return Promise.resolve(false);
|
|
839
875
|
} else if (!statDirname) {
|
|
840
876
|
const message = ( localize(
|
|
841
|
-
|
|
877
|
+
15877,
|
|
842
878
|
"The folder {0} does not exist. Would you like to create it?",
|
|
843
879
|
basename(dirname(uri))
|
|
844
880
|
));
|
|
845
881
|
return this.yesNoPrompt(uri, message);
|
|
846
882
|
} else if (!statDirname.isDirectory) {
|
|
847
|
-
this.filePickBox.validationMessage = ( localize(
|
|
883
|
+
this.filePickBox.validationMessage = ( localize(15878, "Please enter a path that exists."));
|
|
848
884
|
return Promise.resolve(false);
|
|
849
885
|
} else if (statDirname.readonly) {
|
|
850
886
|
this.filePickBox.validationMessage = ( localize(
|
|
851
|
-
|
|
887
|
+
15879,
|
|
852
888
|
"This folder cannot be used as a save destination. Please choose another folder"
|
|
853
889
|
));
|
|
854
890
|
return Promise.resolve(false);
|
|
855
891
|
}
|
|
856
892
|
} else {
|
|
857
893
|
if (!stat) {
|
|
858
|
-
this.filePickBox.validationMessage = ( localize(
|
|
894
|
+
this.filePickBox.validationMessage = ( localize(15878, "Please enter a path that exists."));
|
|
859
895
|
return Promise.resolve(false);
|
|
860
896
|
} else if (uri.path === "/" && this.isWindows) {
|
|
861
|
-
this.filePickBox.validationMessage = ( localize(
|
|
897
|
+
this.filePickBox.validationMessage = ( localize(15880, "Please start the path with a drive letter."));
|
|
862
898
|
return Promise.resolve(false);
|
|
863
899
|
} else if (stat.isDirectory && !this.allowFolderSelection) {
|
|
864
|
-
this.filePickBox.validationMessage = ( localize(
|
|
900
|
+
this.filePickBox.validationMessage = ( localize(15881, "Please select a file."));
|
|
865
901
|
return Promise.resolve(false);
|
|
866
902
|
} else if (!stat.isDirectory && !this.allowFileSelection) {
|
|
867
|
-
this.filePickBox.validationMessage = ( localize(
|
|
903
|
+
this.filePickBox.validationMessage = ( localize(15882, "Please select a folder."));
|
|
868
904
|
return Promise.resolve(false);
|
|
869
905
|
}
|
|
870
906
|
}
|
|
@@ -922,7 +958,12 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
922
958
|
return updatingPromise;
|
|
923
959
|
}
|
|
924
960
|
pathFromUri(uri, endWithSeparator = false) {
|
|
925
|
-
let result
|
|
961
|
+
let result;
|
|
962
|
+
if (this.scopedAuthority) {
|
|
963
|
+
result = uri.path.replace(/\n/g, "");
|
|
964
|
+
} else {
|
|
965
|
+
result = normalizeDriveLetter(uri.fsPath, this.isWindows).replace(/\n/g, "");
|
|
966
|
+
}
|
|
926
967
|
if (this.separator === "/") {
|
|
927
968
|
result = result.replace(/\\/g, this.separator);
|
|
928
969
|
} else {
|
|
@@ -958,9 +999,11 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
958
999
|
return child.substring(parent.length);
|
|
959
1000
|
}
|
|
960
1001
|
async createBackItem(currFolder) {
|
|
1002
|
+
const compareScheme = this.scopedAuthority ? this.scheme : Schemas.file;
|
|
1003
|
+
const compareAuthority = this.scopedAuthority ?? "";
|
|
961
1004
|
const fileRepresentationCurr = this.currentFolder.with({
|
|
962
|
-
scheme:
|
|
963
|
-
authority:
|
|
1005
|
+
scheme: compareScheme,
|
|
1006
|
+
authority: compareAuthority
|
|
964
1007
|
});
|
|
965
1008
|
const fileRepresentationParent = dirname(fileRepresentationCurr);
|
|
966
1009
|
if (!isEqual(fileRepresentationCurr, fileRepresentationParent)) {
|