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

Icons for TreeViewItems fallbacking to default folder item if file uri is used. #43216

Closed
Krzysztof-Cieslak opened this issue Feb 8, 2018 · 5 comments · Fixed by #43261
Closed
Assignees
Labels
api bug Issue identified by VS Code Team member as probable bug tree-views Extension tree view issues verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@Krzysztof-Cieslak
Copy link
Contributor

Example:
image 1

As far as I understand this line is a problem - https://github.com/Microsoft/vscode/blob/5755810a58ac76ffedb037647f1cd6fec406efe9/src/vs/workbench/browser/parts/views/treeView.ts#L334

If an item has Expended or Collapsed state (which basically means it's an item with childs) then we expect folder icon.

In general, I don't think we should have such convention at all, and consumers should be able to set any icon they want - in case of my extension, tree view shows some information from the file, so it makes sense for me to use file icon on the node with child elements.

CC: @sandy081

@bpasero bpasero assigned sandy081 and unassigned bpasero Feb 8, 2018
@bpasero bpasero added the tree-views Extension tree view issues label Feb 8, 2018
@sandy081 sandy081 added the bug Issue identified by VS Code Team member as probable bug label Feb 9, 2018
@sandy081 sandy081 added this to the February 2018 milestone Feb 9, 2018
@sandy081
Copy link
Member

sandy081 commented Feb 9, 2018

@Krzysztof-Cieslak Yes, I was assuming all resources with children as folders which is true in File explorer but not in custom views. So we need a convention to determine if a resource URI is a directory/folder or not.

One convention is to have a trailing slash to indicate if URI is for folder/directory or not.

@Krzysztof-Cieslak
Copy link
Contributor Author

Couldn't we just check whether URI points towards folder or file with FileSystem API? Or that would be too slow?

@sandy081
Copy link
Member

sandy081 commented Feb 9, 2018

I do not think that is a good idea, because some of the URIs could be pointing to remote locations and it will make tree much slower.

@vbfox
Copy link
Contributor

vbfox commented Feb 9, 2018

I need to check a few things before reopening my pr but what i did essentially was to keep the current behavior by default and allow extension developers to be explicit about folder/file

@sandy081 sandy081 added the api label Feb 14, 2018
vbfox added a commit to vbfox/vscode that referenced this issue Feb 23, 2018
The FileKind was previously guessed from the collapsability of the item,
extensions now have the capability to set it manually.

Fixes microsoft#43216
sandy081 added a commit that referenced this issue Feb 26, 2018
sandy081 added a commit that referenced this issue Feb 26, 2018
@sandy081 sandy081 added the verification-needed Verification of issue is requested label Feb 28, 2018
@sandy081
Copy link
Member

sandy081 commented Feb 28, 2018

To verify:

  • Contribute a tree view. Refer to documentation and samples.

  • If you specify ThemeIcon.Folder to iconPath in your TreeItem, then a folder icon will be provided to your node based on current file icon theme.

  • If you specify ThemeIcon.File to iconPath in your TreeItem, then a file icon will be provided to your node based on current file icon theme.

  • If you provide a resourceUri and no ThemeIcon to iconPath then the node will get folder icon if it has children otherwise file icon from current file icon theme

@chrmarti chrmarti added the verified Verification succeeded label Mar 1, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api bug Issue identified by VS Code Team member as probable bug tree-views Extension tree view issues verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants