-
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
Select created new files and folders in the navigator #7762
Conversation
I don't think it is a good idea, programatically new nodes can be added for all kind of reasons. It does not mean that they should be selected. I don't think we need to change anything in trees, but rather new file/folder commands that they select a node after |
@akosyakov We still need to wait for the new nodes to be added to the tree, so I've added a new event that fired when the new file/folder action is executed and check if the added node was caused by the action. |
It is similar to the initial implementation of #6927 (comment) |
My implementation is a little bit different: the workspace command events are fired directly from the new file/folder actions. |
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.
Please see the CI errors related to the test failures.
done |
I don't understand why need events, I imagine code like that: await FileSystem.createFile(uri);
await FileNavigatorWidget.model.refresh(uri.parent);
await FileNavigatorWidget.revealFile(uri); // maybe previous step is not necessary, if `revealFile` does refresh already |
I couldn't use |
But you can do it otherwise by injecting this.workspaceContribution.onDidCreateNewFolder(uri => {
const navigator = this.tryGetWidget();
if (navigator) {
const parent = await navigator.model.revealFile(uri.parent);
if (CompositeTreeNode.is(parent)) {
await navigator.model.refresh(parent);
const node = await navigator.model.revealFile(uri);
if (SelectableTreeNode.is(node)) {
navigator.model.selectNode(node);
}
}
}
}); |
2529b47
to
b432bdb
Compare
done |
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.
It worked nicely. I've tested:
- with and without navigator (from command palette)
- creating files and folders
- creates with simple name and nested structures (
foo/bar/baz
)
did a quick test, still looks good, squash and merge :) |
Signed-off-by: Igor Vinokur <ivinokur@redhat.com>
What it does
Add an event that fires when new nodes added to tree.
Select new created files and folders.
fixes #6190
closes #6927
How to test
Review checklist
Reminder for reviewers