Default to current dir for move to file select (#183875)

Fixes #183870

`showOpenDialog` seems to ignore `defaultUri` if the file doesn't exist
This commit is contained in:
Matt Bierner 2023-05-30 16:58:03 -07:00 committed by GitHub
parent 3370908fd1
commit f4175f4a13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -175,7 +175,6 @@ class MoveToFileRefactorCommand implements Command {
if (response.type !== 'response' || !response.body) {
return;
}
const defaultUri = this.client.toResource(response.body.newFileName);
const selectExistingFileItem: vscode.QuickPickItem = {
label: vscode.l10n.t("Select existing file..."),
@ -226,14 +225,14 @@ class MoveToFileRefactorCommand implements Command {
const picked = await vscode.window.showOpenDialog({
title: vscode.l10n.t("Select move destination"),
openLabel: vscode.l10n.t("Move to File"),
defaultUri
defaultUri: Utils.dirname(document.uri),
});
return picked?.length ? this.client.toTsFilePath(picked[0]) : undefined;
} else if (picked === selectNewFileItem) {
const picked = await vscode.window.showSaveDialog({
title: vscode.l10n.t("Select move destination"),
saveLabel: vscode.l10n.t("Move to File"),
defaultUri,
defaultUri: this.client.toResource(response.body.newFileName),
});
return picked ? this.client.toTsFilePath(picked) : undefined;
} else {