Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set home as save path for unsaved query results #4742

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { JsonMap } from '@salesforce/ts-types';
import * as fs from 'fs';
import { QueryResult } from 'jsforce';
import { homedir } from 'os';
import * as path from 'path';
import * as vscode from 'vscode';
import { getDocumentName, getRootWorkspacePath } from '../commonUtils';
Expand Down Expand Up @@ -55,15 +56,17 @@ export class QueryDataFileService {
this.queryData.records
);
const defaultFileName = this.dataProvider.getFileName();
/* queryDataDefaultFilePath will be used as the default options in the save dialog
fileName: The name of the soqlFile viewed in the builder
path: the same directory as the .soql file text doc.
note: directory must exist to show up in save dialog.
/*
queryDataDefaultFilePath will be used as the default options in the save dialog
fileName: The name of the soqlFile viewed in the builder
path: the same directory as the .soql file text doc
or the home directory if .soql file does not exist yet
*/
const queryDataDefaultFilePath = path.join(
path.parse(this.document.uri.path).dir,
defaultFileName
);
let saveDir = path.parse(this.document.uri.path).dir;
if (!saveDir) {
saveDir = homedir();
}
const queryDataDefaultFilePath = path.join(saveDir, defaultFileName);

const fileInfo: vscode.Uri | undefined = await vscode.window.showSaveDialog(
{
Expand Down