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

[filesystem] Fixed file dialog opening folder #4868

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -45,7 +45,7 @@ export class DefaultFileDialogService {
async showOpenDialog(props: OpenFileDialogProps, folder?: FileStat): Promise<URI | undefined>;
async showOpenDialog(props: OpenFileDialogProps, folder?: FileStat): Promise<MaybeArray<URI> | undefined> {
const title = props.title || 'Open';
const rootNode = await this.getRootNode(folder);
const rootNode = await this.getDirNode(folder);
if (rootNode) {
const dialog = this.openFileDialogFactory(Object.assign(props, { title }));
await dialog.model.navigateTo(rootNode);
Expand All @@ -62,7 +62,7 @@ export class DefaultFileDialogService {

async showSaveDialog(props: SaveFileDialogProps, folder?: FileStat): Promise<URI | undefined> {
const title = props.title || 'Save';
const rootNode = await this.getRootNode(folder);
const rootNode = await this.getDirNode(folder);
if (rootNode) {
const dialog = this.saveFileDialogFactory(Object.assign(props, { title }));
await dialog.model.navigateTo(rootNode);
Expand All @@ -71,10 +71,10 @@ export class DefaultFileDialogService {
return undefined;
}

protected async getRootNode(folderToOpen?: FileStat): Promise<DirNode | undefined> {
federicobozzini marked this conversation as resolved.
Show resolved Hide resolved
protected async getDirNode(folderToOpen?: FileStat): Promise<DirNode | undefined> {
const folder = folderToOpen || await this.fileSystem.getCurrentUserHome();
if (folder) {
const rootUri = new URI(folder.uri).parent;
federicobozzini marked this conversation as resolved.
Show resolved Hide resolved
const rootUri = new URI(folder.uri);
const name = this.labelProvider.getName(rootUri);
const [rootStat, label] = await Promise.all([
this.fileSystem.getFileStat(rootUri.toString()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class ElectronFileDialogService extends DefaultFileDialogService {
async showOpenDialog(props: OpenFileDialogProps & { canSelectMany: true }, folder?: FileStat): Promise<MaybeArray<URI> | undefined>;
async showOpenDialog(props: OpenFileDialogProps, folder?: FileStat): Promise<URI | undefined>;
async showOpenDialog(props: OpenFileDialogProps, folder?: FileStat): Promise<MaybeArray<URI> | undefined> {
const rootNode = await this.getRootNode(folder);
const rootNode = await this.getDirNode(folder);
if (rootNode) {
return new Promise<MaybeArray<URI> | undefined>(resolve => {
remote.dialog.showOpenDialog(this.toOpenDialogOptions(rootNode.uri, props), (filePaths: string[] | undefined) => {
Expand All @@ -61,7 +61,7 @@ export class ElectronFileDialogService extends DefaultFileDialogService {
}

async showSaveDialog(props: SaveFileDialogProps, folder?: FileStat): Promise<URI | undefined> {
const rootNode = await this.getRootNode(folder);
const rootNode = await this.getDirNode(folder);
if (rootNode) {
return new Promise<URI | undefined>(resolve => {
remote.dialog.showSaveDialog(this.toSaveDialogOptions(rootNode.uri, props), (filename: string | undefined) => {
Expand Down