Skip to content

Commit 0acf9ad

Browse files
#146 reworked file path construction for saving remote data and configs
1 parent 6f42395 commit 0acf9ad

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/data.preview.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -720,14 +720,22 @@ export class DataPreview {
720720
* @param fileType Data file type.
721721
*/
722722
private async saveData(fileData: any, fileType: string): Promise<void> {
723-
let dataFilePath: string = this._uri.fsPath.replace(this._fileExtension, '');
723+
let dataFileName: string = this._fileName.replace(this._fileExtension, '');
724724
if (this._dataTable.length > 0) {
725725
// append data table name to new config or data export file name
726-
dataFilePath += `-${this._dataTable}`;
726+
dataFileName += `-${this._dataTable}`;
727727
}
728-
729728
// add requested data file extension
730-
dataFilePath += fileType;
729+
dataFileName += fileType;
730+
731+
// create full data file path for saving data
732+
let dataFilePath: string = path.dirname(this._uri.fsPath);
733+
const workspaceFolders: Array<WorkspaceFolder> = workspace.workspaceFolders;
734+
if (this._isRemoteData && workspaceFolders && workspaceFolders.length > 0) {
735+
// use 'rootPath' workspace folder for saving remote data file
736+
dataFilePath = workspace.workspaceFolders[0].uri.fsPath;
737+
}
738+
dataFilePath = path.join(dataFilePath, dataFileName);
731739
this._logger.debug('saveData(): saving data file:', dataFilePath);
732740

733741
// display save file dialog

0 commit comments

Comments
 (0)