Closed DanTup closed 6 years ago
(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:
Can I tell @vscodebot when it's response is bad so it can learn? :-)
@DanTup May I know if you contributed the view in package.json
?
@sandy081 Yep, I did (as dartFlutterOutline
, which is the ID in the registerTreeDataProvider
registration, not the createTreeView
one) - it's an existing tree I already have that I was trying to add Reveal support for. I wasn't really sure if I was using it correctly; what's the expected way to convert code that already works with registerTreeDataProvider
to get access to reveal?
what's the expected way to convert code that already works with registerTreeDataProvider to get access to reveal
You just move away from registerTreeDataProvider
to createTreeView
. In any case, you need to register the view in the package.json
.
@sandy081 Aha, got it.
How can I tell the difference between when a user clicks on the tree and when I selected an item programmatically? (to avoid the tree trying to navigate my editor when it selected an item as a result of the editor position changing)
@DanTup Currently there is no differentiation. Selecting by user or programatically triggers the command. Please file an issue to not to execute command when selection is done programatically.
Closing this issue as there is nothing to be do done here
@sandy081 Done! https://github.com/Microsoft/vscode/issues/46857
Btw, is this shipping in the next release? (You removed the milestone and I'm not sure what that means)
There is no fix attached to this issue and hence closed this and removed the milestone. So there is nothing to ship for this issue.
@sandy081 Whoops, sorry, I confused this with the other case. Makes perfect sense, thanks/sorry! :)
I ran into the same issue as @DanTup. Unless I am missing something, using createTreeView
in place of registerTreeViewDataProvider
isn't documented anywhere outside of this issue and the sample code. The 1.21 Release Notes even shows using registerTreeViewDataProvider
and the 1.22 Release Notes just refers to the former. I also had to explicitly assign an ID to the TreeItem nodes before reveal
would work. The 1.22 Release Notes should probably should state this information for extension authors to make use of it.
@pltrant Can you please confirm if you have done the following
package.json
by providing an id
createTreeView
to create the view by providing the dataProvider
And you see the issue mentioned in the description even after following above?
Unless I am missing something, using createTreeView in place of registerTreeViewDataProvider isn't documented anywhere outside of this issue and the sample code
createTreeView
api will be available from 1.22
release. It is documented in the vs code api (vscode.d.ts
) when to use createTreeView
and when to use registerTreeViewDataProvider
. This is already mentioned in our 1.22 release notes and will be updated in our docs soon. The 1.21 Release Notes even shows using registerTreeViewDataProvider and the 1.22 Release Notes just refers to the former
In 1.21, I exposed TreeView
in the proposed api and can be accessed while calling registerTreeViewDataProvider
. But after further discussions, we thought it is not good idea to return a view while registering a data provider. Hence I provided a new api to get access to TreeView
. Note: Proposed apis are subjected to change.
I also had to explicitly assign an ID to the TreeItem nodes before reveal would work. The 1.22 Release Notes should probably should state this information for extension authors to make use of it.
Not sure if I get it completely. Why do you have to assign an ID for reveal to work?
And you see the issue mentioned in the description even after following above?
Sorry, if I wasn't clear. I did get it to finally work. I was just commenting on the difficulty in doing so since createTreeView
wasn't documented in any issue or release notes. Being a proposed API, it's understandable that it can change.
Not sure if I get it completely. Why do you have to assign an ID for reveal to work?
I don't know. The following javascript code is how I make the call:
myView.reveal({label: stringVariable});
And in my getTreeItem code, I have:
getTreeItem(element) {
element.id = element.label;
Until I added the line to explicitly set the ID, reveal
would not work. Without, it would result in the following error:
Error: Cannot resolve tree item for element 0/0:
createTreeView
will be available in the stable API from 1.22 and is self documented. It is also documented in the release notes and documentation.
ID
is not mandatory for the reveal to work. I could reproduce the bug with the sample FTP Explorer here. Opened a new issue for this - #47147
@sandy081 Not sure if I'm using this correctly as the FTP example seems slightly different (it's creating a FileSystemProvider?).
I tried calling createTreeView around my tree provider (since this seemed to be the only way to get a
TreeView
which is where thereveal
method is?):However I get this error (using latest Insiders):
Let me know if I'm doing something wrong or if there's another sample I can use as a reference.