Skip to content

Commit

Permalink
electron: fix 'save as...' cwd
Browse files Browse the repository at this point in the history
The following commit fixes the `defaultPath` when performing a `save
as...` in `electron`. Previously, the `defaultPath` was incorrect
leading the dialog to always open where the application started. With
these changes, the dialog will open at the current location where the
`save as...` is performed.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Mar 2, 2021
1 parent 48944a1 commit cb561d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,12 @@ export class DefaultFileDialogService implements FileDialogService {
resource: new URI(await this.environments.getHomeDirUri()),
isDirectory: true
};
if (folder) {
const folderUri = folder.resource;
const rootUri = folder.isDirectory ? folderUri : folderUri.parent;
try {
const rootStat = await this.fileService.resolve(rootUri);
return DirNode.createRoot(rootStat);
} catch { }
}
const folderUri = folder.resource;
const rootUri = folder.isDirectory ? folderUri : folderUri.parent;
try {
const rootStat = await this.fileService.resolve(rootUri);
return DirNode.createRoot(rootStat);
} catch { }
return undefined;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ export class ElectronFileDialogService extends DefaultFileDialogService {

protected toSaveDialogOptions(uri: URI, props: SaveFileDialogProps): SaveDialogOptions {
const buttonLabel = props.saveLabel;
const defaultPath = props.inputValue;
if (props.inputValue) {
uri = uri.resolve(props.inputValue);
}
const defaultPath = FileUri.fsPath(uri);
return { ...this.toDialogOptions(uri, props, 'Save'), buttonLabel, defaultPath };
}

Expand Down

0 comments on commit cb561d3

Please sign in to comment.