-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Conversation
52d79e9
to
e22c55d
Compare
There was a problem hiding this 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; | |||
|
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
}) | ||
]); | ||
} | ||
|
There was a problem hiding this comment.
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.
@@ -66,7 +66,9 @@ export class WorkspaceService implements FrontendApplicationContribution { | |||
protected readonly schemaProvider: PreferenceSchemaProvider; | |||
|
|||
protected applicationName: string; | |||
|
|||
protected readonly onDidCreateFileFolderEmitter = new Emitter<string>(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
e22c55d
to
a9dcfbf
Compare
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>
a9dcfbf
to
e32250e
Compare
I created a small POC of how we can support the changes without the need for new methods in the In this way, we create a new command |
@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 :) |
copy/paste have for example |
I was unable to identify the alternative handlers for |
@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 |
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