提交 0fffa26b 编写于 作者: A Alex Ross

Enable overwriting of file with simple picker

Part of #69445
上级 efe38fc1
......@@ -43,6 +43,7 @@ export class RemoteFileDialog {
private requiresTrailing: boolean;
private userValue: string;
private scheme: string = REMOTE_HOST_SCHEME;
private shouldOverwriteFile: boolean = false;
constructor(
@IFileService private readonly remoteFileService: RemoteFileService,
......@@ -218,6 +219,7 @@ export class RemoteFileDialog {
this.filePickBox.onDidChangeValue(async value => {
if (value !== this.userValue) {
this.filePickBox.validationMessage = undefined;
this.shouldOverwriteFile = false;
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;
const valueUri = this.remoteUriFrom(trimmedPickBoxValue);
if (!resources.isEqual(this.currentFolder, valueUri, true)) {
......@@ -356,9 +358,10 @@ export class RemoteFileDialog {
// Can't do this
this.filePickBox.validationMessage = nls.localize('remoteFileDialog.validateFolder', 'The folder already exists. Please use a new file name.');
return Promise.resolve(false);
} else if (stat) {
// This is replacing a file. Not supported yet.
this.filePickBox.validationMessage = nls.localize('remoteFileDialog.validateExisting', 'The file already exists. Please use a new file name.');
} else if (stat && !this.shouldOverwriteFile) {
// Replacing a file.
this.shouldOverwriteFile = true;
this.filePickBox.validationMessage = nls.localize('remoteFileDialog.validateExisting', '{0} already exists. Are you sure you want to overwrite it?', resources.basename(uri));
return Promise.resolve(false);
} else if (!this.isValidBaseName(resources.basename(uri))) {
// Filename not allowed
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册