Skip to content

Commit 0fffa26

Browse files
committed
Enable overwriting of file with simple picker
Part of microsoft#69445
1 parent efe38fc commit 0fffa26

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export class RemoteFileDialog {
4343
private requiresTrailing: boolean;
4444
private userValue: string;
4545
private scheme: string = REMOTE_HOST_SCHEME;
46+
private shouldOverwriteFile: boolean = false;
4647

4748
constructor(
4849
@IFileService private readonly remoteFileService: RemoteFileService,
@@ -218,6 +219,7 @@ export class RemoteFileDialog {
218219
this.filePickBox.onDidChangeValue(async value => {
219220
if (value !== this.userValue) {
220221
this.filePickBox.validationMessage = undefined;
222+
this.shouldOverwriteFile = false;
221223
const trimmedPickBoxValue = ((this.filePickBox.value.length > 1) && this.endsWithSlash(this.filePickBox.value)) ? this.filePickBox.value.substr(0, this.filePickBox.value.length - 1) : this.filePickBox.value;
222224
const valueUri = this.remoteUriFrom(trimmedPickBoxValue);
223225
if (!resources.isEqual(this.currentFolder, valueUri, true)) {
@@ -356,9 +358,10 @@ export class RemoteFileDialog {
356358
// Can't do this
357359
this.filePickBox.validationMessage = nls.localize('remoteFileDialog.validateFolder', 'The folder already exists. Please use a new file name.');
358360
return Promise.resolve(false);
359-
} else if (stat) {
360-
// This is replacing a file. Not supported yet.
361-
this.filePickBox.validationMessage = nls.localize('remoteFileDialog.validateExisting', 'The file already exists. Please use a new file name.');
361+
} else if (stat && !this.shouldOverwriteFile) {
362+
// Replacing a file.
363+
this.shouldOverwriteFile = true;
364+
this.filePickBox.validationMessage = nls.localize('remoteFileDialog.validateExisting', '{0} already exists. Are you sure you want to overwrite it?', resources.basename(uri));
362365
return Promise.resolve(false);
363366
} else if (!this.isValidBaseName(resources.basename(uri))) {
364367
// Filename not allowed

0 commit comments

Comments
 (0)