mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Save sql plan no longer uses the exact same name as the default (#21563)
* Save sql plan no longer uses the same name * Minor clean up
This commit is contained in:
@@ -446,24 +446,31 @@ export class SavePlanFile extends Action {
|
|||||||
public override async run(context: ExecutionPlanView): Promise<void> {
|
public override async run(context: ExecutionPlanView): Promise<void> {
|
||||||
const workspaceFolders = context.workspaceContextService.getWorkspace().folders;
|
const workspaceFolders = context.workspaceContextService.getWorkspace().folders;
|
||||||
const defaultFileName = 'plan';
|
const defaultFileName = 'plan';
|
||||||
|
const fileExtension = 'sqlplan'; //TODO: Get this extension from provider
|
||||||
let defaultUri: URI;
|
let defaultUri: URI;
|
||||||
|
|
||||||
const lastUsedSavePath = this.storageService.get(SavePlanFile.LAST_USED_EXECUTION_PLAN_SAVE_PATH_STORAGE_KEY, StorageScope.GLOBAL);
|
const lastUsedSavePath = this.storageService.get(SavePlanFile.LAST_USED_EXECUTION_PLAN_SAVE_PATH_STORAGE_KEY, StorageScope.GLOBAL);
|
||||||
|
|
||||||
if (lastUsedSavePath) {
|
if (lastUsedSavePath) {
|
||||||
defaultUri = joinPath(URI.file(lastUsedSavePath), defaultFileName);
|
defaultUri = joinPath(URI.file(lastUsedSavePath), `${defaultFileName}.${fileExtension}`);
|
||||||
} else {
|
} else {
|
||||||
if (workspaceFolders.length !== 0) {
|
if (workspaceFolders.length !== 0) {
|
||||||
defaultUri = URI.joinPath(workspaceFolders[0].uri, defaultFileName); // appending default file name to workspace uri
|
defaultUri = URI.joinPath(workspaceFolders[0].uri, `${defaultFileName}.${fileExtension}`); // appending default file name to workspace uri
|
||||||
} else {
|
} else {
|
||||||
defaultUri = URI.joinPath(await this.fileDialogService.defaultFolderPath(Schemas.file), defaultFileName);
|
defaultUri = URI.joinPath(await this.fileDialogService.defaultFolderPath(Schemas.file), `${defaultFileName}.${fileExtension}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let planNumber = 1;
|
||||||
|
while (await context.fileService.exists(defaultUri)) {
|
||||||
|
defaultUri = joinPath(URI.file(lastUsedSavePath), `${defaultFileName}${planNumber}.${fileExtension}`);
|
||||||
|
planNumber++;
|
||||||
|
}
|
||||||
|
|
||||||
const destination = await this.fileDialogService.showSaveDialog({
|
const destination = await this.fileDialogService.showSaveDialog({
|
||||||
filters: [
|
filters: [
|
||||||
{
|
{
|
||||||
extensions: ['sqlplan'], //TODO: Get this extension from provider
|
extensions: [fileExtension],
|
||||||
name: localize('executionPlan.SaveFileDescription', 'Execution Plan Files') //TODO: Get the names from providers.
|
name: localize('executionPlan.SaveFileDescription', 'Execution Plan Files') //TODO: Get the names from providers.
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user