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

Navigator:Select Folder when user creates one. #6927

Closed
wants to merge 1 commit into from

Conversation

Anasshahidd21
Copy link
Contributor

@Anasshahidd21 Anasshahidd21 commented Jan 20, 2020

What it does

Problem Before: When you create a new folder, the folder is not selected. However, in VSCode it is.
Solution: Updated the Workspace service to contain the createFile and createFolder methods, which would call the filesystem to create it for us, then an event is fired so that the navigator-widget would know about it, once the file receives the uri. It will then create a URI, get the nodes by that URI, and then select that specific node.

Issue ID: 6190

Signed-off-by: Muhammad Anas Shahid

How to test

Create a new folder, checks to see if the folder is highlighted.
Create a new file, check to see if the file is highlighted and opened up as well.

Review checklist

Reminder for reviewers

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your first contribution 👍

Please be sure to properly sign the Eclipse ECA so that the project can accept your changes (it is the reason for the failed CI check).

In the future, you can use a keyword to automatically closed referenced issues when a pull-request is merged (ex: Fixes #6190))

@@ -25,7 +25,6 @@ import { FileNavigatorFilter } from './navigator-filter';
export class FileNavigatorTree extends FileTree {

@inject(FileNavigatorFilter) protected readonly filter: FileNavigatorFilter;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Anasshahidd21 can you revert changes made to the following file? (they are unnecessary)


protected readonly onDidCreateFileFolderEmitter = new Emitter<string>();
readonly onDidCreateFileFolder = this.onDidCreateFileFolderEmitter.event;
readonly onDidReveal = new Emitter<void>().event;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • [minor] include a newline so it's easy to read.
  • [minor] it'd be nice to include documentation describing the events


protected readonly onDidCreateFileFolderEmitter = new Emitter<string>();
readonly onDidCreateFileFolder = this.onDidCreateFileFolderEmitter.event;
readonly onDidReveal = new Emitter<void>().event;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onDidReveal looks to be a leftover as it is not used.

})
]);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] preserve the newline, as it makes methods easier to read.

@vince-fugnitto vince-fugnitto added enhancement issues that are enhancements to current functionality - nice to haves navigator issues related to the navigator/explorer ui/ux issues related to user interface / user experience labels Jan 20, 2020
@@ -66,7 +66,9 @@ export class WorkspaceService implements FrontendApplicationContribution {
protected readonly schemaProvider: PreferenceSchemaProvider;

protected applicationName: string;

protected readonly onDidCreateFileFolderEmitter = new Emitter<string>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that the workspace service should have such APIs.

So if someone call create a folder programatically, this file will be always revealed in the navigator? Is it desirable? I think the scope of the change should be bound to the navigator.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are already APIs btw to listen when something is created: FileSystemWatcher. And it should be used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we don't want to highlight any folder that gets created. Right now creating a folder in the navigator tree triggers a command from the workspace extension. How would you fix #6190 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we don't want to highlight any folder that gets created.

Changing WorkspaceService does not help, anyone can trigger programmatically these methods now and it would lead to the same issues.

How would you fix #6190 ?

If it should be triggered only by user actions then it should be implemented there, like await then create finished (without listening to events), if a result is positive then reveal. WorkspaceService should not be changed.

Problem Before: When you create a new folder, the folder is not selected. However, in VSCode it is.
Solution: Updated the Workspace service to contain the createFile and createFolder methods, which would call the filesystem to create it for us, then an event is fired so that the navigator-widget would know about it, once the file receives the uri. It will then create a URI, get the nodes by that URI, and then select that specific node.

Issue ID: 6190

Signed-off-by: Muhammad Anas Shahid <muhammad.shahid@ericsson.com>
@vince-fugnitto
Copy link
Member

I created a small POC of how we can support the changes without the need for new methods in the workspace-service an the new event.

In this way, we create a new command CREATE_FILE_AND_REVEAL which internally calls the WorkspaceCommands.NEW_FILE (for the dialog and file creation) and also adds extra handling to reveal the file in the explorer. I assume this would be a straightforward way to work around the issues we were initially having with our approaches.

@akosyakov
Copy link
Member

In this way, we create a new command CREATE_FILE_AND_REVEAL which internally calls the WorkspaceCommands.NEW_FILE (for the dialog and file creation) and also adds extra handling to reveal the file in the explorer. I assume this would be a straightforward way to work around the issues we were initially having with our approaches.

@vince-fugnitto Maybe the navigator could provide an alternative handler for the same command when it is a current widget, in such case it would delegate to the original handler and then reveal. So it works from any context given that the navigator was last focused widget.

@vince-fugnitto
Copy link
Member

In this way, we create a new command CREATE_FILE_AND_REVEAL which internally calls the WorkspaceCommands.NEW_FILE (for the dialog and file creation) and also adds extra handling to reveal the file in the explorer. I assume this would be a straightforward way to work around the issues we were initially having with our approaches.

@vince-fugnitto Maybe the navigator could provide an alternative handler for the same command when it is a current widget, in such case it would delegate to the original handler and then reveal. So it works from any context given that the navigator was last focused widget.

I wasn't aware we could register multiple alternative handlers for a given command (I haven't seen an example yet of such). If so, I think it'd be a good approach :)

@akosyakov
Copy link
Member

I wasn't aware we could register multiple alternative handlers for a given command (I haven't seen an example yet of such). If so, I think it'd be a good approach :)

copy/paste have for example

@vince-fugnitto
Copy link
Member

I wasn't aware we could register multiple alternative handlers for a given command (I haven't seen an example yet of such). If so, I think it'd be a good approach :)

copy/paste have for example

I was unable to identify the alternative handlers for copy/paste :(

@akosyakov
Copy link
Member

@vince-fugnitto try to register another handler for the same command but with different isEnabled implementation, it could be that we should reverse evaluation of command handlers that added later have a chance. In this case they should be more specific. Maybe we have to add such docs to registerHandler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement issues that are enhancements to current functionality - nice to haves navigator issues related to the navigator/explorer ui/ux issues related to user interface / user experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants