@codingame/monaco-vscode-dialogs-service-override 25.1.1 → 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.
- package/package.json +2 -2
- package/vscode/src/vs/workbench/browser/parts/dialogs/dialog.web.contribution.js +28 -23
- package/vscode/src/vs/workbench/browser/parts/dialogs/dialogHandler.js +89 -35
- package/vscode/src/vs/workbench/common/dialogs.js +1 -2
- package/vscode/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.js +212 -83
- package/vscode/src/vs/workbench/services/dialogs/browser/fileDialogService.js +84 -51
- package/vscode/src/vs/workbench/services/dialogs/browser/simpleFileDialog.js +270 -242
- package/vscode/src/vs/workbench/services/dialogs/common/dialogService.js +38 -15
|
@@ -39,27 +39,37 @@ import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode
|
|
|
39
39
|
import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
|
|
40
40
|
|
|
41
41
|
var OpenLocalFileCommand;
|
|
42
|
-
(function
|
|
43
|
-
OpenLocalFileCommand.ID =
|
|
44
|
-
OpenLocalFileCommand.LABEL = ( localize(
|
|
42
|
+
(function(OpenLocalFileCommand) {
|
|
43
|
+
OpenLocalFileCommand.ID = "workbench.action.files.openLocalFile";
|
|
44
|
+
OpenLocalFileCommand.LABEL = ( localize(14249, "Open Local File..."));
|
|
45
45
|
function handler() {
|
|
46
46
|
return accessor => {
|
|
47
47
|
const dialogService = accessor.get(IFileDialogService);
|
|
48
|
-
return dialogService.pickFileAndOpen({
|
|
48
|
+
return dialogService.pickFileAndOpen({
|
|
49
|
+
forceNewWindow: false,
|
|
50
|
+
availableFileSystems: [Schemas.file]
|
|
51
|
+
});
|
|
49
52
|
};
|
|
50
53
|
}
|
|
51
54
|
OpenLocalFileCommand.handler = handler;
|
|
52
55
|
})(OpenLocalFileCommand || (OpenLocalFileCommand = {}));
|
|
53
56
|
var SaveLocalFileCommand;
|
|
54
|
-
(function
|
|
55
|
-
SaveLocalFileCommand.ID =
|
|
56
|
-
SaveLocalFileCommand.LABEL = ( localize(
|
|
57
|
+
(function(SaveLocalFileCommand) {
|
|
58
|
+
SaveLocalFileCommand.ID = "workbench.action.files.saveLocalFile";
|
|
59
|
+
SaveLocalFileCommand.LABEL = ( localize(14250, "Save Local File..."));
|
|
57
60
|
function handler() {
|
|
58
61
|
return accessor => {
|
|
59
62
|
const editorService = accessor.get(IEditorService);
|
|
60
63
|
const activeEditorPane = editorService.activeEditorPane;
|
|
61
64
|
if (activeEditorPane) {
|
|
62
|
-
return editorService.save({
|
|
65
|
+
return editorService.save({
|
|
66
|
+
groupId: activeEditorPane.group.id,
|
|
67
|
+
editor: activeEditorPane.input
|
|
68
|
+
}, {
|
|
69
|
+
saveAs: true,
|
|
70
|
+
availableFileSystems: [Schemas.file],
|
|
71
|
+
reason: SaveReason.EXPLICIT
|
|
72
|
+
});
|
|
63
73
|
}
|
|
64
74
|
return Promise.resolve(undefined);
|
|
65
75
|
};
|
|
@@ -67,40 +77,62 @@ var SaveLocalFileCommand;
|
|
|
67
77
|
SaveLocalFileCommand.handler = handler;
|
|
68
78
|
})(SaveLocalFileCommand || (SaveLocalFileCommand = {}));
|
|
69
79
|
var OpenLocalFolderCommand;
|
|
70
|
-
(function
|
|
71
|
-
OpenLocalFolderCommand.ID =
|
|
72
|
-
OpenLocalFolderCommand.LABEL = ( localize(
|
|
80
|
+
(function(OpenLocalFolderCommand) {
|
|
81
|
+
OpenLocalFolderCommand.ID = "workbench.action.files.openLocalFolder";
|
|
82
|
+
OpenLocalFolderCommand.LABEL = ( localize(14251, "Open Local Folder..."));
|
|
73
83
|
function handler() {
|
|
74
84
|
return accessor => {
|
|
75
85
|
const dialogService = accessor.get(IFileDialogService);
|
|
76
|
-
return dialogService.pickFolderAndOpen({
|
|
86
|
+
return dialogService.pickFolderAndOpen({
|
|
87
|
+
forceNewWindow: false,
|
|
88
|
+
availableFileSystems: [Schemas.file]
|
|
89
|
+
});
|
|
77
90
|
};
|
|
78
91
|
}
|
|
79
92
|
OpenLocalFolderCommand.handler = handler;
|
|
80
93
|
})(OpenLocalFolderCommand || (OpenLocalFolderCommand = {}));
|
|
81
94
|
var OpenLocalFileFolderCommand;
|
|
82
|
-
(function
|
|
83
|
-
OpenLocalFileFolderCommand.ID =
|
|
84
|
-
OpenLocalFileFolderCommand.LABEL = ( localize(
|
|
95
|
+
(function(OpenLocalFileFolderCommand) {
|
|
96
|
+
OpenLocalFileFolderCommand.ID = "workbench.action.files.openLocalFileFolder";
|
|
97
|
+
OpenLocalFileFolderCommand.LABEL = ( localize(14252, "Open Local..."));
|
|
85
98
|
function handler() {
|
|
86
99
|
return accessor => {
|
|
87
100
|
const dialogService = accessor.get(IFileDialogService);
|
|
88
|
-
return dialogService.pickFileFolderAndOpen({
|
|
101
|
+
return dialogService.pickFileFolderAndOpen({
|
|
102
|
+
forceNewWindow: false,
|
|
103
|
+
availableFileSystems: [Schemas.file]
|
|
104
|
+
});
|
|
89
105
|
};
|
|
90
106
|
}
|
|
91
107
|
OpenLocalFileFolderCommand.handler = handler;
|
|
92
108
|
})(OpenLocalFileFolderCommand || (OpenLocalFileFolderCommand = {}));
|
|
93
109
|
var UpdateResult;
|
|
94
|
-
(function
|
|
110
|
+
(function(UpdateResult) {
|
|
95
111
|
UpdateResult[UpdateResult["Updated"] = 0] = "Updated";
|
|
96
112
|
UpdateResult[UpdateResult["UpdatedWithTrailing"] = 1] = "UpdatedWithTrailing";
|
|
97
113
|
UpdateResult[UpdateResult["Updating"] = 2] = "Updating";
|
|
98
114
|
UpdateResult[UpdateResult["NotUpdated"] = 3] = "NotUpdated";
|
|
99
115
|
UpdateResult[UpdateResult["InvalidPath"] = 4] = "InvalidPath";
|
|
100
116
|
})(UpdateResult || (UpdateResult = {}));
|
|
101
|
-
const RemoteFileDialogContext = ( new RawContextKey(
|
|
117
|
+
const RemoteFileDialogContext = ( new RawContextKey("remoteFileDialogVisible", false));
|
|
102
118
|
let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
103
|
-
constructor(
|
|
119
|
+
constructor(
|
|
120
|
+
fileService,
|
|
121
|
+
quickInputService,
|
|
122
|
+
labelService,
|
|
123
|
+
workspaceContextService,
|
|
124
|
+
notificationService,
|
|
125
|
+
fileDialogService,
|
|
126
|
+
modelService,
|
|
127
|
+
languageService,
|
|
128
|
+
environmentService,
|
|
129
|
+
remoteAgentService,
|
|
130
|
+
pathService,
|
|
131
|
+
keybindingService,
|
|
132
|
+
contextKeyService,
|
|
133
|
+
accessibilityService,
|
|
134
|
+
storageService
|
|
135
|
+
) {
|
|
104
136
|
super();
|
|
105
137
|
this.fileService = fileService;
|
|
106
138
|
this.quickInputService = quickInputService;
|
|
@@ -120,10 +152,10 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
120
152
|
this.allowFileSelection = true;
|
|
121
153
|
this.allowFolderSelection = false;
|
|
122
154
|
this.requiresTrailing = false;
|
|
123
|
-
this.userEnteredPathSegment =
|
|
124
|
-
this.autoCompletePathSegment =
|
|
155
|
+
this.userEnteredPathSegment = "";
|
|
156
|
+
this.autoCompletePathSegment = "";
|
|
125
157
|
this.isWindows = false;
|
|
126
|
-
this.separator =
|
|
158
|
+
this.separator = "/";
|
|
127
159
|
this.onBusyChangeEmitter = this._register(( new Emitter()));
|
|
128
160
|
this._showDotFiles = true;
|
|
129
161
|
this.remoteAuthority = this.environmentService.remoteAuthority;
|
|
@@ -131,21 +163,28 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
131
163
|
this.scheme = this.pathService.defaultUriScheme;
|
|
132
164
|
this.getShowDotFiles();
|
|
133
165
|
const disposableStore = this._register(( new DisposableStore()));
|
|
134
|
-
disposableStore.add(
|
|
135
|
-
this.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
166
|
+
disposableStore.add(
|
|
167
|
+
this.storageService.onDidChangeValue(StorageScope.WORKSPACE, "remoteFileDialog.showDotFiles", disposableStore)(async _ => {
|
|
168
|
+
this.getShowDotFiles();
|
|
169
|
+
this.setButtons();
|
|
170
|
+
const startingValue = this.filePickBox.value;
|
|
171
|
+
const folderValue = this.pathFromUri(this.currentFolder, true);
|
|
172
|
+
this.filePickBox.value = folderValue;
|
|
173
|
+
await this.tryUpdateItems(folderValue, this.currentFolder, true);
|
|
174
|
+
this.filePickBox.value = startingValue;
|
|
175
|
+
})
|
|
176
|
+
);
|
|
143
177
|
}
|
|
144
178
|
setShowDotFiles(showDotFiles) {
|
|
145
|
-
this.storageService.store(
|
|
179
|
+
this.storageService.store(
|
|
180
|
+
"remoteFileDialog.showDotFiles",
|
|
181
|
+
showDotFiles,
|
|
182
|
+
StorageScope.WORKSPACE,
|
|
183
|
+
StorageTarget.USER
|
|
184
|
+
);
|
|
146
185
|
}
|
|
147
186
|
getShowDotFiles() {
|
|
148
|
-
this._showDotFiles = this.storageService.getBoolean(
|
|
187
|
+
this._showDotFiles = this.storageService.getBoolean("remoteFileDialog.showDotFiles", StorageScope.WORKSPACE, true);
|
|
149
188
|
}
|
|
150
189
|
set busy(busy) {
|
|
151
190
|
if (this.filePickBox.busy !== busy) {
|
|
@@ -179,7 +218,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
179
218
|
this.options = newOptions;
|
|
180
219
|
this.options.canSelectFolders = true;
|
|
181
220
|
this.options.canSelectFiles = true;
|
|
182
|
-
return ( new Promise(
|
|
221
|
+
return ( new Promise(resolve => {
|
|
183
222
|
this.pickResource(true).then(folderUri => {
|
|
184
223
|
resolve(folderUri);
|
|
185
224
|
});
|
|
@@ -200,8 +239,8 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
200
239
|
}
|
|
201
240
|
if ((this.scheme !== Schemas.file) && !this.fileService.hasProvider(defaultUri)) {
|
|
202
241
|
this.notificationService.info(( localize(
|
|
203
|
-
|
|
204
|
-
|
|
242
|
+
14253,
|
|
243
|
+
"File system provider for {0} is not available.",
|
|
205
244
|
(defaultUri.toString())
|
|
206
245
|
)));
|
|
207
246
|
return undefined;
|
|
@@ -211,15 +250,21 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
211
250
|
return newOptions;
|
|
212
251
|
}
|
|
213
252
|
remoteUriFrom(path, hintUri) {
|
|
214
|
-
if (!path.startsWith(
|
|
215
|
-
path = path.replace(/\\/g,
|
|
216
|
-
}
|
|
217
|
-
const uri = this.scheme === Schemas.file ? URI.file(path) : ( URI.from(
|
|
218
|
-
|
|
219
|
-
|
|
253
|
+
if (!path.startsWith("\\\\")) {
|
|
254
|
+
path = path.replace(/\\/g, "/");
|
|
255
|
+
}
|
|
256
|
+
const uri = this.scheme === Schemas.file ? URI.file(path) : ( URI.from({
|
|
257
|
+
scheme: this.scheme,
|
|
258
|
+
path,
|
|
259
|
+
query: hintUri?.query,
|
|
260
|
+
fragment: hintUri?.fragment
|
|
261
|
+
}));
|
|
220
262
|
const authority = (uri.scheme === Schemas.file) ? undefined : (this.remoteAuthority ?? hintUri?.authority);
|
|
221
|
-
return toLocalResource(
|
|
222
|
-
|
|
263
|
+
return toLocalResource(
|
|
264
|
+
uri,
|
|
265
|
+
authority,
|
|
266
|
+
authority ? this.pathService.defaultUriScheme : uri.scheme
|
|
267
|
+
);
|
|
223
268
|
}
|
|
224
269
|
getScheme(available, defaultUri) {
|
|
225
270
|
if (available && available.length > 0) {
|
|
@@ -227,8 +272,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
227
272
|
return defaultUri.scheme;
|
|
228
273
|
}
|
|
229
274
|
return available[0];
|
|
230
|
-
}
|
|
231
|
-
else if (defaultUri) {
|
|
275
|
+
} else if (defaultUri) {
|
|
232
276
|
return defaultUri.scheme;
|
|
233
277
|
}
|
|
234
278
|
return Schemas.file;
|
|
@@ -240,9 +284,9 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
240
284
|
return this.remoteAgentEnvironment;
|
|
241
285
|
}
|
|
242
286
|
getUserHome(trueHome = false) {
|
|
243
|
-
return trueHome
|
|
244
|
-
|
|
245
|
-
|
|
287
|
+
return trueHome ? this.pathService.userHome({
|
|
288
|
+
preferLocal: this.scheme === Schemas.file
|
|
289
|
+
}) : this.fileDialogService.preferredHome(this.scheme);
|
|
246
290
|
}
|
|
247
291
|
async pickResource(isSave = false) {
|
|
248
292
|
this.allowFolderSelection = !!this.options.canSelectFolders;
|
|
@@ -256,39 +300,36 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
256
300
|
if (this.options.defaultUri) {
|
|
257
301
|
try {
|
|
258
302
|
stat = await this.fileService.stat(this.options.defaultUri);
|
|
259
|
-
}
|
|
260
|
-
catch (e) {
|
|
261
|
-
}
|
|
303
|
+
} catch (e) {}
|
|
262
304
|
if (!stat || !stat.isDirectory) {
|
|
263
305
|
homedir = dirname(this.options.defaultUri);
|
|
264
306
|
this.trailing = basename(this.options.defaultUri);
|
|
265
307
|
}
|
|
266
308
|
}
|
|
267
|
-
return (new Promise(
|
|
309
|
+
return (new Promise(resolve => {
|
|
268
310
|
this.filePickBox = this._register(this.quickInputService.createQuickPick());
|
|
269
311
|
this.busy = true;
|
|
270
312
|
this.filePickBox.matchOnLabel = false;
|
|
271
313
|
this.filePickBox.sortByLabel = false;
|
|
272
314
|
this.filePickBox.ignoreFocusOut = true;
|
|
273
|
-
this.filePickBox.placeholder = ( localize(
|
|
315
|
+
this.filePickBox.placeholder = ( localize(14254, "Folder path"));
|
|
274
316
|
this.filePickBox.ok = true;
|
|
275
|
-
this.filePickBox.okLabel = typeof this.options.openLabel ===
|
|
317
|
+
this.filePickBox.okLabel = typeof this.options.openLabel === "string" ? this.options.openLabel : this.options.openLabel?.withoutMnemonic;
|
|
276
318
|
if ((this.scheme !== Schemas.file) && this.options && this.options.availableFileSystems && (this.options.availableFileSystems.length > 1) && (this.options.availableFileSystems.indexOf(Schemas.file) > -1)) {
|
|
277
319
|
this.filePickBox.customButton = true;
|
|
278
|
-
this.filePickBox.customLabel = ( localize(
|
|
320
|
+
this.filePickBox.customLabel = ( localize(14255, "Show Local"));
|
|
279
321
|
this.filePickBox.customButtonSecondary = true;
|
|
280
322
|
let action;
|
|
281
323
|
if (isSave) {
|
|
282
324
|
action = SaveLocalFileCommand;
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
325
|
+
} else {
|
|
285
326
|
action = this.allowFileSelection ? (this.allowFolderSelection ? OpenLocalFileFolderCommand : OpenLocalFileCommand) : OpenLocalFolderCommand;
|
|
286
327
|
}
|
|
287
328
|
const keybinding = this.keybindingService.lookupKeybinding(action.ID);
|
|
288
329
|
if (keybinding) {
|
|
289
330
|
const label = keybinding.getLabel();
|
|
290
331
|
if (label) {
|
|
291
|
-
this.filePickBox.customHover = format(
|
|
332
|
+
this.filePickBox.customHover = format("{0} ({1})", action.LABEL, label);
|
|
292
333
|
}
|
|
293
334
|
}
|
|
294
335
|
}
|
|
@@ -299,12 +340,12 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
299
340
|
let isResolving = 0;
|
|
300
341
|
let isAcceptHandled = false;
|
|
301
342
|
this.currentFolder = dirname(homedir);
|
|
302
|
-
this.userEnteredPathSegment =
|
|
303
|
-
this.autoCompletePathSegment =
|
|
343
|
+
this.userEnteredPathSegment = "";
|
|
344
|
+
this.autoCompletePathSegment = "";
|
|
304
345
|
this.filePickBox.title = this.options.title;
|
|
305
346
|
this.filePickBox.value = this.pathFromUri(this.currentFolder, true);
|
|
306
347
|
this.filePickBox.valueSelection = [this.filePickBox.value.length, this.filePickBox.value.length];
|
|
307
|
-
const doResolve =
|
|
348
|
+
const doResolve = uri => {
|
|
308
349
|
if (uri) {
|
|
309
350
|
uri = addTrailingPathSeparator(uri, this.separator);
|
|
310
351
|
uri = removeTrailingPathSeparator(uri);
|
|
@@ -327,8 +368,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
327
368
|
return this.fileDialogService.showSaveDialog(this.options).then(result => {
|
|
328
369
|
doResolve(result);
|
|
329
370
|
});
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
371
|
+
} else {
|
|
332
372
|
return this.fileDialogService.showOpenDialog(this.options).then(result => {
|
|
333
373
|
doResolve(result ? result[0] : undefined);
|
|
334
374
|
});
|
|
@@ -336,14 +376,13 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
336
376
|
}));
|
|
337
377
|
const handleAccept = () => {
|
|
338
378
|
if (this.busy) {
|
|
339
|
-
this.onBusyChangeEmitter.event(
|
|
379
|
+
this.onBusyChangeEmitter.event(busy => {
|
|
340
380
|
if (!busy) {
|
|
341
381
|
handleAccept();
|
|
342
382
|
}
|
|
343
383
|
});
|
|
344
384
|
return;
|
|
345
|
-
}
|
|
346
|
-
else if (isAcceptHandled) {
|
|
385
|
+
} else if (isAcceptHandled) {
|
|
347
386
|
return;
|
|
348
387
|
}
|
|
349
388
|
isAcceptHandled = true;
|
|
@@ -352,11 +391,9 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
352
391
|
if (resolveValue) {
|
|
353
392
|
this.filePickBox.hide();
|
|
354
393
|
doResolve(resolveValue);
|
|
355
|
-
}
|
|
356
|
-
else if (this.hidden) {
|
|
394
|
+
} else if (this.hidden) {
|
|
357
395
|
doResolve(undefined);
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
396
|
+
} else {
|
|
360
397
|
isResolving--;
|
|
361
398
|
isAcceptHandled = false;
|
|
362
399
|
}
|
|
@@ -377,7 +414,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
377
414
|
this.setAutoComplete(userPath, this.userEnteredPathSegment, i[0], true);
|
|
378
415
|
}
|
|
379
416
|
}));
|
|
380
|
-
this._register(this.filePickBox.onDidChangeValue(async
|
|
417
|
+
this._register(this.filePickBox.onDidChangeValue(async value => {
|
|
381
418
|
return this.handleValueChange(value);
|
|
382
419
|
}));
|
|
383
420
|
this._register(this.filePickBox.onDidHide(() => {
|
|
@@ -390,9 +427,11 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
390
427
|
this.contextKey.set(true);
|
|
391
428
|
this.updateItems(homedir, true, this.trailing).then(() => {
|
|
392
429
|
if (this.trailing) {
|
|
393
|
-
this.filePickBox.valueSelection = [
|
|
394
|
-
|
|
395
|
-
|
|
430
|
+
this.filePickBox.valueSelection = [
|
|
431
|
+
this.filePickBox.value.length - this.trailing.length,
|
|
432
|
+
this.filePickBox.value.length - ext.length
|
|
433
|
+
];
|
|
434
|
+
} else {
|
|
396
435
|
this.filePickBox.valueSelection = [this.filePickBox.value.length, this.filePickBox.value.length];
|
|
397
436
|
}
|
|
398
437
|
this.busy = false;
|
|
@@ -415,28 +454,28 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
415
454
|
if ((updated === UpdateResult.NotUpdated) || (updated === UpdateResult.UpdatedWithTrailing)) {
|
|
416
455
|
this.setActiveItems(value);
|
|
417
456
|
}
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
457
|
+
} else {
|
|
420
458
|
this.filePickBox.activeItems = [];
|
|
421
|
-
this.userEnteredPathSegment =
|
|
459
|
+
this.userEnteredPathSegment = "";
|
|
422
460
|
}
|
|
423
461
|
}
|
|
424
|
-
}
|
|
425
|
-
catch {
|
|
426
|
-
}
|
|
462
|
+
} catch {}
|
|
427
463
|
}
|
|
428
464
|
setButtons() {
|
|
429
465
|
this.filePickBox.buttons = [{
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
466
|
+
iconClass: this._showDotFiles ? ThemeIcon.asClassName(Codicon.eye) : ThemeIcon.asClassName(Codicon.eyeClosed),
|
|
467
|
+
tooltip: this._showDotFiles ? ( localize(14256, "Hide dot files")) : ( localize(14257, "Show dot files")),
|
|
468
|
+
alwaysVisible: true
|
|
469
|
+
}];
|
|
434
470
|
}
|
|
435
471
|
isBadSubpath(value) {
|
|
436
472
|
return this.badPath && (value.length > this.badPath.length) && equalsIgnoreCase(value.substring(0, this.badPath.length), this.badPath);
|
|
437
473
|
}
|
|
438
474
|
isValueChangeFromUser() {
|
|
439
|
-
if (equalsIgnoreCase(this.filePickBox.value, this.pathAppend(
|
|
475
|
+
if (equalsIgnoreCase(this.filePickBox.value, this.pathAppend(
|
|
476
|
+
this.currentFolder,
|
|
477
|
+
this.userEnteredPathSegment + this.autoCompletePathSegment
|
|
478
|
+
))) {
|
|
440
479
|
return false;
|
|
441
480
|
}
|
|
442
481
|
return true;
|
|
@@ -449,15 +488,19 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
449
488
|
}
|
|
450
489
|
constructFullUserPath() {
|
|
451
490
|
const currentFolderPath = this.pathFromUri(this.currentFolder);
|
|
452
|
-
if (equalsIgnoreCase(
|
|
453
|
-
|
|
491
|
+
if (equalsIgnoreCase(
|
|
492
|
+
this.filePickBox.value.substr(0, this.userEnteredPathSegment.length),
|
|
493
|
+
this.userEnteredPathSegment
|
|
494
|
+
)) {
|
|
495
|
+
if (equalsIgnoreCase(
|
|
496
|
+
this.filePickBox.value.substr(0, currentFolderPath.length),
|
|
497
|
+
currentFolderPath
|
|
498
|
+
)) {
|
|
454
499
|
return currentFolderPath;
|
|
455
|
-
}
|
|
456
|
-
else {
|
|
500
|
+
} else {
|
|
457
501
|
return this.userEnteredPathSegment;
|
|
458
502
|
}
|
|
459
|
-
}
|
|
460
|
-
else {
|
|
503
|
+
} else {
|
|
461
504
|
return this.pathAppend(this.currentFolder, this.userEnteredPathSegment);
|
|
462
505
|
}
|
|
463
506
|
}
|
|
@@ -473,12 +516,11 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
473
516
|
if (relativePath$1 && isSameRoot) {
|
|
474
517
|
let path = joinPath(this.currentFolder, relativePath$1);
|
|
475
518
|
const directBasename = basename(directUri);
|
|
476
|
-
if ((directBasename ===
|
|
519
|
+
if ((directBasename === ".") || (directBasename === "..")) {
|
|
477
520
|
path = this.remoteUriFrom(this.pathAppend(path, directBasename), this.currentFolder);
|
|
478
521
|
}
|
|
479
522
|
return hasTrailingPathSeparator(directUri) ? addTrailingPathSeparator(path) : path;
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
523
|
+
} else {
|
|
482
524
|
return directUri;
|
|
483
525
|
}
|
|
484
526
|
}
|
|
@@ -489,26 +531,22 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
489
531
|
if (item.isFolder) {
|
|
490
532
|
if (this.trailing) {
|
|
491
533
|
await this.updateItems(item.uri, true, this.trailing);
|
|
492
|
-
}
|
|
493
|
-
else {
|
|
534
|
+
} else {
|
|
494
535
|
const newPath = this.pathFromUri(item.uri);
|
|
495
536
|
if (startsWithIgnoreCase(newPath, this.filePickBox.value) && (equalsIgnoreCase(item.label, basename(item.uri)))) {
|
|
496
537
|
this.filePickBox.valueSelection = [this.pathFromUri(this.currentFolder).length, this.filePickBox.value.length];
|
|
497
538
|
this.insertText(newPath, this.basenameWithTrailingSlash(item.uri));
|
|
498
|
-
}
|
|
499
|
-
else if ((item.label === '..') && startsWithIgnoreCase(this.filePickBox.value, newPath)) {
|
|
539
|
+
} else if ((item.label === "..") && startsWithIgnoreCase(this.filePickBox.value, newPath)) {
|
|
500
540
|
this.filePickBox.valueSelection = [newPath.length, this.filePickBox.value.length];
|
|
501
|
-
this.insertText(newPath,
|
|
502
|
-
}
|
|
503
|
-
else {
|
|
541
|
+
this.insertText(newPath, "");
|
|
542
|
+
} else {
|
|
504
543
|
await this.updateItems(item.uri, true);
|
|
505
544
|
}
|
|
506
545
|
}
|
|
507
546
|
this.filePickBox.busy = false;
|
|
508
547
|
return;
|
|
509
548
|
}
|
|
510
|
-
}
|
|
511
|
-
else if (!this.updatingPromise) {
|
|
549
|
+
} else if (!this.updatingPromise) {
|
|
512
550
|
if ((await this.tryUpdateItems(this.filePickBox.value, this.filePickBoxValue())) !== UpdateResult.NotUpdated) {
|
|
513
551
|
this.filePickBox.busy = false;
|
|
514
552
|
return;
|
|
@@ -517,8 +555,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
517
555
|
let resolveValue;
|
|
518
556
|
if (this.filePickBox.activeItems.length === 0) {
|
|
519
557
|
resolveValue = this.filePickBoxValue();
|
|
520
|
-
}
|
|
521
|
-
else if (this.filePickBox.activeItems.length === 1) {
|
|
558
|
+
} else if (this.filePickBox.activeItems.length === 1) {
|
|
522
559
|
resolveValue = this.filePickBox.selectedItems[0].uri;
|
|
523
560
|
}
|
|
524
561
|
if (resolveValue) {
|
|
@@ -541,14 +578,13 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
541
578
|
return dir;
|
|
542
579
|
}
|
|
543
580
|
canTildaEscapeHatch(value) {
|
|
544
|
-
return !!(value.endsWith(
|
|
581
|
+
return !!(value.endsWith("~") && this.isBadSubpath(value));
|
|
545
582
|
}
|
|
546
583
|
tildaReplace(value) {
|
|
547
584
|
const home = this.trueHome;
|
|
548
|
-
if ((value.length > 0) && (value[0] ===
|
|
585
|
+
if ((value.length > 0) && (value[0] === "~")) {
|
|
549
586
|
return joinPath(home, value.substring(1));
|
|
550
|
-
}
|
|
551
|
-
else if (this.canTildaEscapeHatch(value)) {
|
|
587
|
+
} else if (this.canTildaEscapeHatch(value)) {
|
|
552
588
|
return home;
|
|
553
589
|
}
|
|
554
590
|
return this.remoteUriFrom(value);
|
|
@@ -562,16 +598,14 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
562
598
|
return uri;
|
|
563
599
|
}
|
|
564
600
|
async tryUpdateItems(value, valueUri, reset = false) {
|
|
565
|
-
if ((value.length > 0) && ((value[0] ===
|
|
601
|
+
if ((value.length > 0) && ((value[0] === "~") || this.canTildaEscapeHatch(value))) {
|
|
566
602
|
const newDir = this.tildaReplace(value);
|
|
567
603
|
return (await this.updateItems(newDir, true)) ? UpdateResult.UpdatedWithTrailing : UpdateResult.Updated;
|
|
568
|
-
}
|
|
569
|
-
else if (value === '\\') {
|
|
604
|
+
} else if (value === "\\") {
|
|
570
605
|
valueUri = this.root(this.currentFolder);
|
|
571
606
|
value = this.pathFromUri(valueUri);
|
|
572
607
|
return (await this.updateItems(valueUri, true)) ? UpdateResult.UpdatedWithTrailing : UpdateResult.Updated;
|
|
573
|
-
}
|
|
574
|
-
else {
|
|
608
|
+
} else {
|
|
575
609
|
const newFolderIsOldFolder = extUriIgnorePathCase.isEqual(this.currentFolder, valueUri);
|
|
576
610
|
const newFolderIsSubFolder = extUriIgnorePathCase.isEqual(this.currentFolder, dirname(valueUri));
|
|
577
611
|
const newFolderIsParent = extUriIgnorePathCase.isEqualOrParent(this.currentFolder, dirname(valueUri));
|
|
@@ -580,31 +614,26 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
580
614
|
let stat;
|
|
581
615
|
try {
|
|
582
616
|
stat = await this.fileService.stat(valueUri);
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
}
|
|
586
|
-
if (stat?.isDirectory && (basename(valueUri) !== '.') && this.endsWithSlash(value)) {
|
|
617
|
+
} catch (e) {}
|
|
618
|
+
if (stat?.isDirectory && (basename(valueUri) !== ".") && this.endsWithSlash(value)) {
|
|
587
619
|
valueUri = this.tryAddTrailingSeparatorToDirectory(valueUri, stat);
|
|
588
620
|
return (await this.updateItems(valueUri)) ? UpdateResult.UpdatedWithTrailing : UpdateResult.Updated;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
this.filePickBox.validationMessage = ( localize(13871, 'The path does not exist. Use ~ to go to your home directory.'));
|
|
621
|
+
} else if (this.endsWithSlash(value)) {
|
|
622
|
+
this.filePickBox.validationMessage = ( localize(14258, "The path does not exist. Use ~ to go to your home directory."));
|
|
592
623
|
this.badPath = value;
|
|
593
624
|
return UpdateResult.InvalidPath;
|
|
594
|
-
}
|
|
595
|
-
else {
|
|
625
|
+
} else {
|
|
596
626
|
let inputUriDirname = dirname(valueUri);
|
|
597
627
|
const currentFolderWithoutSep = removeTrailingPathSeparator(addTrailingPathSeparator(this.currentFolder));
|
|
598
628
|
const inputUriDirnameWithoutSep = removeTrailingPathSeparator(addTrailingPathSeparator(inputUriDirname));
|
|
599
|
-
if (!extUriIgnorePathCase.isEqual(currentFolderWithoutSep, inputUriDirnameWithoutSep)
|
|
600
|
-
|
|
601
|
-
|
|
629
|
+
if (!extUriIgnorePathCase.isEqual(currentFolderWithoutSep, inputUriDirnameWithoutSep) && (!/^[a-zA-Z]:$/.test(this.filePickBox.value) || !equalsIgnoreCase(
|
|
630
|
+
this.pathFromUri(this.currentFolder).substring(0, this.filePickBox.value.length),
|
|
631
|
+
this.filePickBox.value
|
|
632
|
+
))) {
|
|
602
633
|
let statWithoutTrailing;
|
|
603
634
|
try {
|
|
604
635
|
statWithoutTrailing = await this.fileService.stat(inputUriDirname);
|
|
605
|
-
}
|
|
606
|
-
catch (e) {
|
|
607
|
-
}
|
|
636
|
+
} catch (e) {}
|
|
608
637
|
if (statWithoutTrailing?.isDirectory) {
|
|
609
638
|
this.badPath = undefined;
|
|
610
639
|
inputUriDirname = this.tryAddTrailingSeparatorToDirectory(inputUriDirname, statWithoutTrailing);
|
|
@@ -628,8 +657,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
628
657
|
const asUri = this.remoteUriFrom(value);
|
|
629
658
|
const inputBasename = basename(asUri);
|
|
630
659
|
const userPath = this.constructFullUserPath();
|
|
631
|
-
const pathsEqual = equalsIgnoreCase(userPath, value.substring(0, userPath.length)) ||
|
|
632
|
-
equalsIgnoreCase(value, userPath.substring(0, value.length));
|
|
660
|
+
const pathsEqual = equalsIgnoreCase(userPath, value.substring(0, userPath.length)) || equalsIgnoreCase(value, userPath.substring(0, value.length));
|
|
633
661
|
if (pathsEqual) {
|
|
634
662
|
let hasMatch = false;
|
|
635
663
|
for (let i = 0; i < this.filePickBox.items.length; i++) {
|
|
@@ -640,16 +668,15 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
640
668
|
}
|
|
641
669
|
}
|
|
642
670
|
if (!hasMatch) {
|
|
643
|
-
const userBasename = inputBasename.length >= 2 ? userPath.substring(userPath.length - inputBasename.length + 2) :
|
|
644
|
-
this.userEnteredPathSegment = (userBasename === inputBasename) ? inputBasename :
|
|
645
|
-
this.autoCompletePathSegment =
|
|
671
|
+
const userBasename = inputBasename.length >= 2 ? userPath.substring(userPath.length - inputBasename.length + 2) : "";
|
|
672
|
+
this.userEnteredPathSegment = (userBasename === inputBasename) ? inputBasename : "";
|
|
673
|
+
this.autoCompletePathSegment = "";
|
|
646
674
|
this.filePickBox.activeItems = [];
|
|
647
675
|
this.tryUpdateTrailing(asUri);
|
|
648
676
|
}
|
|
649
|
-
}
|
|
650
|
-
else {
|
|
677
|
+
} else {
|
|
651
678
|
this.userEnteredPathSegment = inputBasename;
|
|
652
|
-
this.autoCompletePathSegment =
|
|
679
|
+
this.autoCompletePathSegment = "";
|
|
653
680
|
this.filePickBox.activeItems = [];
|
|
654
681
|
this.tryUpdateTrailing(asUri);
|
|
655
682
|
}
|
|
@@ -657,59 +684,66 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
657
684
|
setAutoComplete(startingValue, startingBasename, quickPickItem, force = false) {
|
|
658
685
|
if (this.busy) {
|
|
659
686
|
this.userEnteredPathSegment = startingBasename;
|
|
660
|
-
this.autoCompletePathSegment =
|
|
687
|
+
this.autoCompletePathSegment = "";
|
|
661
688
|
return false;
|
|
662
689
|
}
|
|
663
690
|
const itemBasename = quickPickItem.label;
|
|
664
|
-
if (itemBasename ===
|
|
665
|
-
this.userEnteredPathSegment =
|
|
666
|
-
this.autoCompletePathSegment =
|
|
691
|
+
if (itemBasename === "..") {
|
|
692
|
+
this.userEnteredPathSegment = "";
|
|
693
|
+
this.autoCompletePathSegment = "";
|
|
667
694
|
this.activeItem = quickPickItem;
|
|
668
695
|
if (force) {
|
|
669
|
-
getActiveDocument().execCommand(
|
|
696
|
+
getActiveDocument().execCommand("insertText", false, "");
|
|
670
697
|
}
|
|
671
698
|
return false;
|
|
672
|
-
}
|
|
673
|
-
else if (!force && (itemBasename.length >= startingBasename.length) && equalsIgnoreCase(itemBasename.substr(0, startingBasename.length), startingBasename)) {
|
|
699
|
+
} else if (!force && (itemBasename.length >= startingBasename.length) && equalsIgnoreCase(itemBasename.substr(0, startingBasename.length), startingBasename)) {
|
|
674
700
|
this.userEnteredPathSegment = startingBasename;
|
|
675
701
|
this.activeItem = quickPickItem;
|
|
676
|
-
this.autoCompletePathSegment =
|
|
702
|
+
this.autoCompletePathSegment = "";
|
|
677
703
|
if (quickPickItem.isFolder || !this.trailing) {
|
|
678
704
|
this.filePickBox.activeItems = [quickPickItem];
|
|
679
|
-
}
|
|
680
|
-
else {
|
|
705
|
+
} else {
|
|
681
706
|
this.filePickBox.activeItems = [];
|
|
682
707
|
}
|
|
683
708
|
return true;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
this.userEnteredPathSegment
|
|
709
|
+
} else if (force && (!equalsIgnoreCase(
|
|
710
|
+
this.basenameWithTrailingSlash(quickPickItem.uri),
|
|
711
|
+
(this.userEnteredPathSegment + this.autoCompletePathSegment)
|
|
712
|
+
))) {
|
|
713
|
+
this.userEnteredPathSegment = "";
|
|
687
714
|
if (!this.accessibilityService.isScreenReaderOptimized()) {
|
|
688
715
|
this.autoCompletePathSegment = this.trimTrailingSlash(itemBasename);
|
|
689
716
|
}
|
|
690
717
|
this.activeItem = quickPickItem;
|
|
691
718
|
if (!this.accessibilityService.isScreenReaderOptimized()) {
|
|
692
|
-
this.filePickBox.valueSelection = [
|
|
693
|
-
|
|
694
|
-
|
|
719
|
+
this.filePickBox.valueSelection = [
|
|
720
|
+
this.pathFromUri(this.currentFolder, true).length,
|
|
721
|
+
this.filePickBox.value.length
|
|
722
|
+
];
|
|
723
|
+
this.insertText(
|
|
724
|
+
this.pathAppend(this.currentFolder, this.autoCompletePathSegment),
|
|
725
|
+
this.autoCompletePathSegment
|
|
726
|
+
);
|
|
727
|
+
this.filePickBox.valueSelection = [
|
|
728
|
+
this.filePickBox.value.length - this.autoCompletePathSegment.length,
|
|
729
|
+
this.filePickBox.value.length
|
|
730
|
+
];
|
|
695
731
|
}
|
|
696
732
|
return true;
|
|
697
|
-
}
|
|
698
|
-
else {
|
|
733
|
+
} else {
|
|
699
734
|
this.userEnteredPathSegment = startingBasename;
|
|
700
|
-
this.autoCompletePathSegment =
|
|
735
|
+
this.autoCompletePathSegment = "";
|
|
701
736
|
return false;
|
|
702
737
|
}
|
|
703
738
|
}
|
|
704
739
|
insertText(wholeValue, insertText) {
|
|
705
740
|
if (this.filePickBox.inputHasFocus()) {
|
|
706
|
-
getActiveDocument().execCommand(
|
|
741
|
+
getActiveDocument().execCommand("insertText", false, insertText);
|
|
707
742
|
if (this.filePickBox.value !== wholeValue) {
|
|
708
743
|
this.filePickBox.value = wholeValue;
|
|
709
744
|
this.handleValueChange(wholeValue);
|
|
710
745
|
}
|
|
711
|
-
}
|
|
712
|
-
else {
|
|
746
|
+
} else {
|
|
713
747
|
this.filePickBox.value = wholeValue;
|
|
714
748
|
this.handleValueChange(wholeValue);
|
|
715
749
|
}
|
|
@@ -721,7 +755,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
721
755
|
const currentExt = extname(uri).substr(1);
|
|
722
756
|
for (let i = 0; i < this.options.filters.length; i++) {
|
|
723
757
|
for (let j = 0; j < this.options.filters[i].extensions.length; j++) {
|
|
724
|
-
if ((this.options.filters[i].extensions[j] ===
|
|
758
|
+
if ((this.options.filters[i].extensions[j] === "*") || (this.options.filters[i].extensions[j] === currentExt)) {
|
|
725
759
|
hasExt = true;
|
|
726
760
|
break;
|
|
727
761
|
}
|
|
@@ -731,7 +765,10 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
731
765
|
}
|
|
732
766
|
}
|
|
733
767
|
if (!hasExt) {
|
|
734
|
-
result = joinPath(
|
|
768
|
+
result = joinPath(
|
|
769
|
+
dirname(uri),
|
|
770
|
+
basename(uri) + "." + this.options.filters[0].extensions[0]
|
|
771
|
+
);
|
|
735
772
|
}
|
|
736
773
|
}
|
|
737
774
|
return result;
|
|
@@ -746,7 +783,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
746
783
|
prompt.ignoreFocusOut = true;
|
|
747
784
|
prompt.ok = true;
|
|
748
785
|
prompt.customButton = true;
|
|
749
|
-
prompt.customLabel = ( localize(
|
|
786
|
+
prompt.customLabel = ( localize(14259, "Cancel"));
|
|
750
787
|
prompt.customButtonSecondary = true;
|
|
751
788
|
prompt.value = this.pathFromUri(uri);
|
|
752
789
|
let isResolving = false;
|
|
@@ -775,7 +812,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
775
812
|
}
|
|
776
813
|
async validate(uri) {
|
|
777
814
|
if (uri === undefined) {
|
|
778
|
-
this.filePickBox.validationMessage = ( localize(
|
|
815
|
+
this.filePickBox.validationMessage = ( localize(14260, "Please enter a valid path."));
|
|
779
816
|
return Promise.resolve(false);
|
|
780
817
|
}
|
|
781
818
|
let stat;
|
|
@@ -783,61 +820,50 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
783
820
|
try {
|
|
784
821
|
statDirname = await this.fileService.stat(dirname(uri));
|
|
785
822
|
stat = await this.fileService.stat(uri);
|
|
786
|
-
}
|
|
787
|
-
catch (e) {
|
|
788
|
-
}
|
|
823
|
+
} catch (e) {}
|
|
789
824
|
if (this.requiresTrailing) {
|
|
790
825
|
if (stat?.isDirectory) {
|
|
791
|
-
this.filePickBox.validationMessage = ( localize(
|
|
826
|
+
this.filePickBox.validationMessage = ( localize(14261, "The folder already exists. Please use a new file name."));
|
|
792
827
|
return Promise.resolve(false);
|
|
793
|
-
}
|
|
794
|
-
else if (stat) {
|
|
828
|
+
} else if (stat) {
|
|
795
829
|
const message = ( localize(
|
|
796
|
-
|
|
797
|
-
|
|
830
|
+
14262,
|
|
831
|
+
"{0} already exists. Are you sure you want to overwrite it?",
|
|
798
832
|
basename(uri)
|
|
799
833
|
));
|
|
800
834
|
return this.yesNoPrompt(uri, message);
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
this.filePickBox.validationMessage = ( localize(13876, 'Please enter a valid file name.'));
|
|
835
|
+
} else if (!(isValidBasename(basename(uri), this.isWindows))) {
|
|
836
|
+
this.filePickBox.validationMessage = ( localize(14263, "Please enter a valid file name."));
|
|
804
837
|
return Promise.resolve(false);
|
|
805
|
-
}
|
|
806
|
-
else if (!statDirname) {
|
|
838
|
+
} else if (!statDirname) {
|
|
807
839
|
const message = ( localize(
|
|
808
|
-
|
|
809
|
-
|
|
840
|
+
14264,
|
|
841
|
+
"The folder {0} does not exist. Would you like to create it?",
|
|
810
842
|
basename(dirname(uri))
|
|
811
843
|
));
|
|
812
844
|
return this.yesNoPrompt(uri, message);
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
this.filePickBox.validationMessage = ( localize(13878, 'Please enter a path that exists.'));
|
|
845
|
+
} else if (!statDirname.isDirectory) {
|
|
846
|
+
this.filePickBox.validationMessage = ( localize(14265, "Please enter a path that exists."));
|
|
816
847
|
return Promise.resolve(false);
|
|
817
|
-
}
|
|
818
|
-
else if (statDirname.readonly) {
|
|
848
|
+
} else if (statDirname.readonly) {
|
|
819
849
|
this.filePickBox.validationMessage = ( localize(
|
|
820
|
-
|
|
821
|
-
|
|
850
|
+
14266,
|
|
851
|
+
"This folder cannot be used as a save destination. Please choose another folder"
|
|
822
852
|
));
|
|
823
853
|
return Promise.resolve(false);
|
|
824
854
|
}
|
|
825
|
-
}
|
|
826
|
-
else {
|
|
855
|
+
} else {
|
|
827
856
|
if (!stat) {
|
|
828
|
-
this.filePickBox.validationMessage = ( localize(
|
|
857
|
+
this.filePickBox.validationMessage = ( localize(14265, "Please enter a path that exists."));
|
|
829
858
|
return Promise.resolve(false);
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
this.filePickBox.validationMessage = ( localize(13880, 'Please start the path with a drive letter.'));
|
|
859
|
+
} else if (uri.path === "/" && this.isWindows) {
|
|
860
|
+
this.filePickBox.validationMessage = ( localize(14267, "Please start the path with a drive letter."));
|
|
833
861
|
return Promise.resolve(false);
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
this.filePickBox.validationMessage = ( localize(13881, 'Please select a file.'));
|
|
862
|
+
} else if (stat.isDirectory && !this.allowFolderSelection) {
|
|
863
|
+
this.filePickBox.validationMessage = ( localize(14268, "Please select a file."));
|
|
837
864
|
return Promise.resolve(false);
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
this.filePickBox.validationMessage = ( localize(13882, 'Please select a folder.'));
|
|
865
|
+
} else if (!stat.isDirectory && !this.allowFileSelection) {
|
|
866
|
+
this.filePickBox.validationMessage = ( localize(14269, "Please select a folder."));
|
|
841
867
|
return Promise.resolve(false);
|
|
842
868
|
}
|
|
843
869
|
}
|
|
@@ -845,12 +871,12 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
845
871
|
}
|
|
846
872
|
async updateItems(newFolder, force = false, trailing) {
|
|
847
873
|
this.busy = true;
|
|
848
|
-
this.autoCompletePathSegment =
|
|
849
|
-
const wasDotDot = trailing ===
|
|
874
|
+
this.autoCompletePathSegment = "";
|
|
875
|
+
const wasDotDot = trailing === "..";
|
|
850
876
|
trailing = wasDotDot ? undefined : trailing;
|
|
851
877
|
const isSave = !!trailing;
|
|
852
878
|
let result = false;
|
|
853
|
-
const updatingPromise = createCancelablePromise(async
|
|
879
|
+
const updatingPromise = createCancelablePromise(async token => {
|
|
854
880
|
let folderStat;
|
|
855
881
|
try {
|
|
856
882
|
folderStat = await this.fileService.resolve(newFolder);
|
|
@@ -860,12 +886,10 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
860
886
|
folderStat = undefined;
|
|
861
887
|
result = true;
|
|
862
888
|
}
|
|
863
|
-
}
|
|
864
|
-
catch (e) {
|
|
865
|
-
}
|
|
889
|
+
} catch (e) {}
|
|
866
890
|
const newValue = trailing ? this.pathAppend(newFolder, trailing) : this.pathFromUri(newFolder, true);
|
|
867
891
|
this.currentFolder = this.endsWithSlash(newFolder.path) ? newFolder : addTrailingPathSeparator(newFolder, this.separator);
|
|
868
|
-
this.userEnteredPathSegment = trailing ? trailing :
|
|
892
|
+
this.userEnteredPathSegment = trailing ? trailing : "";
|
|
869
893
|
return this.createItems(folderStat, this.currentFolder, token).then(items => {
|
|
870
894
|
if (token.isCancellationRequested) {
|
|
871
895
|
this.busy = false;
|
|
@@ -878,9 +902,11 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
878
902
|
this.insertText(newValue, newValue);
|
|
879
903
|
}
|
|
880
904
|
if (force && trailing && isSave) {
|
|
881
|
-
this.filePickBox.valueSelection = [
|
|
882
|
-
|
|
883
|
-
|
|
905
|
+
this.filePickBox.valueSelection = [
|
|
906
|
+
this.filePickBox.value.length - trailing.length,
|
|
907
|
+
this.filePickBox.value.length - trailing.length
|
|
908
|
+
];
|
|
909
|
+
} else if (!trailing) {
|
|
884
910
|
this.filePickBox.valueSelection = [this.filePickBox.value.length, this.filePickBox.value.length];
|
|
885
911
|
}
|
|
886
912
|
this.busy = false;
|
|
@@ -895,11 +921,10 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
895
921
|
return updatingPromise;
|
|
896
922
|
}
|
|
897
923
|
pathFromUri(uri, endWithSeparator = false) {
|
|
898
|
-
let result = normalizeDriveLetter(uri.fsPath, this.isWindows).replace(/\n/g,
|
|
899
|
-
if (this.separator ===
|
|
924
|
+
let result = normalizeDriveLetter(uri.fsPath, this.isWindows).replace(/\n/g, "");
|
|
925
|
+
if (this.separator === "/") {
|
|
900
926
|
result = result.replace(/\\/g, this.separator);
|
|
901
|
-
}
|
|
902
|
-
else {
|
|
927
|
+
} else {
|
|
903
928
|
result = result.replace(/\//g, this.separator);
|
|
904
929
|
}
|
|
905
930
|
if (endWithSeparator && !this.endsWithSlash(result)) {
|
|
@@ -908,11 +933,10 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
908
933
|
return result;
|
|
909
934
|
}
|
|
910
935
|
pathAppend(uri, additional) {
|
|
911
|
-
if ((additional ===
|
|
936
|
+
if ((additional === "..") || (additional === ".")) {
|
|
912
937
|
const basePath = this.pathFromUri(uri, true);
|
|
913
938
|
return basePath + additional;
|
|
914
|
-
}
|
|
915
|
-
else {
|
|
939
|
+
} else {
|
|
916
940
|
return this.pathFromUri(joinPath(uri, additional));
|
|
917
941
|
}
|
|
918
942
|
}
|
|
@@ -933,12 +957,19 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
933
957
|
return child.substring(parent.length);
|
|
934
958
|
}
|
|
935
959
|
async createBackItem(currFolder) {
|
|
936
|
-
const fileRepresentationCurr = this.currentFolder.with({
|
|
960
|
+
const fileRepresentationCurr = this.currentFolder.with({
|
|
961
|
+
scheme: Schemas.file,
|
|
962
|
+
authority: ""
|
|
963
|
+
});
|
|
937
964
|
const fileRepresentationParent = dirname(fileRepresentationCurr);
|
|
938
965
|
if (!isEqual(fileRepresentationCurr, fileRepresentationParent)) {
|
|
939
966
|
const parentFolder = dirname(currFolder);
|
|
940
967
|
if (await this.fileService.exists(parentFolder)) {
|
|
941
|
-
return {
|
|
968
|
+
return {
|
|
969
|
+
label: "..",
|
|
970
|
+
uri: addTrailingPathSeparator(parentFolder, this.separator),
|
|
971
|
+
isFolder: true
|
|
972
|
+
};
|
|
942
973
|
}
|
|
943
974
|
}
|
|
944
975
|
return undefined;
|
|
@@ -950,15 +981,14 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
950
981
|
if (!folder) {
|
|
951
982
|
folder = await this.fileService.resolve(currentFolder);
|
|
952
983
|
}
|
|
953
|
-
const filteredChildren = this._showDotFiles ? folder.children : folder.children?.filter(child => !child.name.startsWith(
|
|
984
|
+
const filteredChildren = this._showDotFiles ? folder.children : folder.children?.filter(child => !child.name.startsWith("."));
|
|
954
985
|
const items = filteredChildren ? await Promise.all(( filteredChildren.map(child => this.createItem(child, currentFolder, token)))) : [];
|
|
955
986
|
for (const item of items) {
|
|
956
987
|
if (item) {
|
|
957
988
|
result.push(item);
|
|
958
989
|
}
|
|
959
990
|
}
|
|
960
|
-
}
|
|
961
|
-
catch (e) {
|
|
991
|
+
} catch (e) {
|
|
962
992
|
console.log(e);
|
|
963
993
|
}
|
|
964
994
|
if (token.isCancellationRequested) {
|
|
@@ -982,7 +1012,7 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
982
1012
|
for (let i = 0; i < this.options.filters.length; i++) {
|
|
983
1013
|
for (let j = 0; j < this.options.filters[i].extensions.length; j++) {
|
|
984
1014
|
const testExt = this.options.filters[i].extensions[j];
|
|
985
|
-
if ((testExt ===
|
|
1015
|
+
if ((testExt === "*") || (file.path.endsWith("." + testExt))) {
|
|
986
1016
|
return true;
|
|
987
1017
|
}
|
|
988
1018
|
}
|
|
@@ -999,30 +1029,28 @@ let SimpleFileDialog = class SimpleFileDialog extends Disposable {
|
|
|
999
1029
|
if (stat.isDirectory) {
|
|
1000
1030
|
const filename = basename(fullPath);
|
|
1001
1031
|
fullPath = addTrailingPathSeparator(fullPath, this.separator);
|
|
1002
|
-
return {
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1032
|
+
return {
|
|
1033
|
+
label: filename,
|
|
1034
|
+
uri: fullPath,
|
|
1035
|
+
isFolder: true,
|
|
1036
|
+
iconClasses: getIconClasses(
|
|
1037
|
+
this.modelService,
|
|
1038
|
+
this.languageService,
|
|
1039
|
+
fullPath || undefined,
|
|
1040
|
+
FileKind.FOLDER
|
|
1041
|
+
)
|
|
1042
|
+
};
|
|
1043
|
+
} else if (!stat.isDirectory && this.allowFileSelection && this.filterFile(fullPath)) {
|
|
1044
|
+
return {
|
|
1045
|
+
label: stat.name,
|
|
1046
|
+
uri: fullPath,
|
|
1047
|
+
isFolder: false,
|
|
1048
|
+
iconClasses: getIconClasses(this.modelService, this.languageService, fullPath || undefined)
|
|
1049
|
+
};
|
|
1006
1050
|
}
|
|
1007
1051
|
return undefined;
|
|
1008
1052
|
}
|
|
1009
1053
|
};
|
|
1010
|
-
SimpleFileDialog = ( __decorate([
|
|
1011
|
-
( __param(0, IFileService)),
|
|
1012
|
-
( __param(1, IQuickInputService)),
|
|
1013
|
-
( __param(2, ILabelService)),
|
|
1014
|
-
( __param(3, IWorkspaceContextService)),
|
|
1015
|
-
( __param(4, INotificationService)),
|
|
1016
|
-
( __param(5, IFileDialogService)),
|
|
1017
|
-
( __param(6, IModelService)),
|
|
1018
|
-
( __param(7, ILanguageService)),
|
|
1019
|
-
( __param(8, IWorkbenchEnvironmentService)),
|
|
1020
|
-
( __param(9, IRemoteAgentService)),
|
|
1021
|
-
( __param(10, IPathService)),
|
|
1022
|
-
( __param(11, IKeybindingService)),
|
|
1023
|
-
( __param(12, IContextKeyService)),
|
|
1024
|
-
( __param(13, IAccessibilityService)),
|
|
1025
|
-
( __param(14, IStorageService))
|
|
1026
|
-
], SimpleFileDialog));
|
|
1054
|
+
SimpleFileDialog = ( __decorate([( __param(0, IFileService)), ( __param(1, IQuickInputService)), ( __param(2, ILabelService)), ( __param(3, IWorkspaceContextService)), ( __param(4, INotificationService)), ( __param(5, IFileDialogService)), ( __param(6, IModelService)), ( __param(7, ILanguageService)), ( __param(8, IWorkbenchEnvironmentService)), ( __param(9, IRemoteAgentService)), ( __param(10, IPathService)), ( __param(11, IKeybindingService)), ( __param(12, IContextKeyService)), ( __param(13, IAccessibilityService)), ( __param(14, IStorageService))], SimpleFileDialog));
|
|
1027
1055
|
|
|
1028
1056
|
export { OpenLocalFileCommand, OpenLocalFileFolderCommand, OpenLocalFolderCommand, RemoteFileDialogContext, SaveLocalFileCommand, SimpleFileDialog };
|