Skip to content

Commit a579bb3

Browse files
committed
Use same code path in accept for trying to update
1 parent 9bd21e3 commit a579bb3

1 file changed

Lines changed: 24 additions & 43 deletions

File tree

src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -350,54 +350,34 @@ export class RemoteFileDialog {
350350
}
351351

352352
private async onDidAccept(): Promise<URI | undefined> {
353-
this.filePickBox.busy = true;
354-
let resolveValue: URI | undefined;
355-
let navigateValue: URI | undefined;
356-
let inputUri: URI | undefined;
357-
let inputUriDirname: URI | undefined;
358-
let stat: IFileStat | undefined;
359-
let statDirname: IFileStat | undefined;
360-
try {
361-
inputUri = resources.removeTrailingPathSeparator(this.filePickBoxValue());
362-
inputUriDirname = resources.dirname(inputUri);
363-
statDirname = await this.fileService.resolve(inputUriDirname);
364-
stat = await this.fileService.resolve(inputUri);
365-
} catch (e) {
366-
// do nothing
353+
let updateString: string;
354+
let updateUri: URI;
355+
if (this.filePickBox.activeItems.length === 1) {
356+
updateUri = this.filePickBox.selectedItems[0].uri;
357+
updateString = this.pathFromUri(updateUri);
358+
} else {
359+
updateString = this.filePickBox.value;
360+
updateUri = this.filePickBoxValue();
361+
}
362+
// If the items have updated, don't try to resolve
363+
if ((await this.tryUpdateItems(updateString, updateUri)) !== UpdateResult.NotUpdated) {
364+
return;
367365
}
368366

367+
this.filePickBox.busy = true;
368+
let resolveValue: URI | undefined;
369369
// Find resolve value
370370
if (this.filePickBox.activeItems.length === 0) {
371-
if (!this.requiresTrailing && resources.isEqual(this.currentFolder, inputUri, true)) {
372-
resolveValue = inputUri;
373-
} else if (statDirname && statDirname.isDirectory) {
374-
resolveValue = inputUri;
375-
} else if (stat && stat.isDirectory) {
376-
navigateValue = inputUri;
377-
}
371+
resolveValue = this.filePickBoxValue();
378372
} else if (this.filePickBox.activeItems.length === 1) {
379-
const item = this.filePickBox.selectedItems[0];
380-
if (item) {
381-
if (!item.isFolder) {
382-
resolveValue = item.uri;
383-
} else {
384-
navigateValue = item.uri;
385-
}
386-
}
373+
resolveValue = this.filePickBox.selectedItems[0].uri;
387374
}
388-
389-
390-
if (navigateValue) {
391-
// Try to navigate into the folder.
392-
await this.updateItems(navigateValue, true, this.trailing);
393-
} else {
394-
if (resolveValue) {
395-
resolveValue = this.addPostfix(resolveValue);
396-
}
397-
if (await this.validate(resolveValue)) {
398-
this.filePickBox.busy = false;
399-
return resolveValue;
400-
}
375+
if (resolveValue) {
376+
resolveValue = this.addPostfix(resolveValue);
377+
}
378+
if (await this.validate(resolveValue)) {
379+
this.filePickBox.busy = false;
380+
return resolveValue;
401381
}
402382
this.filePickBox.busy = false;
403383
return undefined;
@@ -771,7 +751,7 @@ export class RemoteFileDialog {
771751
private createBackItem(currFolder: URI): FileQuickPickItem | null {
772752
const parentFolder = resources.dirname(currFolder)!;
773753
if (!resources.isEqual(currFolder, parentFolder, true)) {
774-
return { label: '..', uri: resources.dirname(currFolder), isFolder: true };
754+
return { label: '..', uri: this.ensureTrailingSeparator(parentFolder), isFolder: true };
775755
}
776756
return null;
777757
}
@@ -829,6 +809,7 @@ export class RemoteFileDialog {
829809
const stat = await this.fileService.resolve(fullPath);
830810
if (stat.isDirectory) {
831811
filename = this.basenameWithTrailingSlash(fullPath);
812+
fullPath = this.ensureTrailingSeparator(fullPath);
832813
return { label: filename, uri: fullPath, isFolder: true, iconClasses: getIconClasses(this.modelService, this.modeService, fullPath || undefined, FileKind.FOLDER) };
833814
} else if (!stat.isDirectory && this.allowFileSelection && this.filterFile(fullPath)) {
834815
return { label: filename, uri: fullPath, isFolder: false, iconClasses: getIconClasses(this.modelService, this.modeService, fullPath || undefined) };

0 commit comments

Comments
 (0)