vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Add file icons support in the explorer

Open marzubov opened this issue 11 years ago • 75 comments

Can you please add file icons support in the tree view?

I know that access from extension to the DOM is restricted. But it will be good to add some language-id attribute to the tree-view element. For example in the render function. So it will be easy to modify view of files with different types with CSS, without modifying DOM.

And also It will be nice to add possibility to add/modify directly CSS from extension.

marzubov avatar Nov 19 '15 13:11 marzubov

I agree. Here is a screenshot of what I have in sublime.

screen shot 2015-11-21 at 1 41 13 pm

samueleaton avatar Nov 21 '15 20:11 samueleaton

+1

roddolf avatar Jan 26 '16 21:01 roddolf

+1 I can find files much faster with the icons!

bildschirmfoto 2016-01-27 um 09 09 45

philipgiuliani avatar Jan 27 '16 08:01 philipgiuliani

Any progress on this?

zippoxer avatar Jan 30 '16 17:01 zippoxer

+1

Maybe its possible to add a language and\or file-ext attributes here for themes to render icons?

pflannery avatar Jan 31 '16 04:01 pflannery

+1

I mostly have issues trying to distinguish the difference between a file and a folder quickly. There isn't even a text color difference.

TheColorRed avatar Feb 06 '16 15:02 TheColorRed

What is interesting is that there is logic in place to add icon classes: https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/files/browser/views/explorerViewer.ts

private iconClass(element: FileStat): string {
        if (element.isDirectory) {
            return 'folder-icon';
        }

        return 'text-file-icon';
}

As seen above, vscode currently adds a folder-icon css class to all folders but a style is not defined for it. So if you want to see folder icon in explorer, all you have to do is add the below styles to /resources/app/out/vs/workbench/workbench.main.css

.monaco-tree-row .content .sub-content .explorer-item.folder-icon {
    padding-left: 22px;
    background: url(./parts/files/browser/media/Folder.png) 1px 4px no-repeat;
}
.monaco-tree-row.expanded .content .sub-content .explorer-item.folder-icon {
    padding-left: 22px;
    background: url(./parts/files/browser/media/Folder_opened.png) 1px 4px no-repeat;
}
.explorer-item.text-file-icon { 
    padding-left: 22px;
    background: url(./parts/files/browser/media/Textfile.png) 1px 4px no-repeat;
 }

and copy the below icon images to /resources/app/out/vs/workbench/parts/files/browser/media folder closed Folder.png folder opened Folder_opened.png textfile Textfile.png

Here is a preview of it in action: Preview

In it's simplest form, implementing the file icon feature would require modifying the above iconClass method to return 'text-file-' + getFileExtension(element.name) and adding corresponding icon svg/font to each css classes (i.e., text-file-js, text-file-md, etc.)

san8pai avatar Feb 18 '16 12:02 san8pai

Nice find @snpai. It would be very easy if they could add another class like text-file text-file-md. So extensions could use it to just add another CSS with all the icons.

philipgiuliani avatar Feb 18 '16 12:02 philipgiuliani

This feature is sorely needed, and is trivial to implement. I was able to use @pflannery's fork and https://github.com/mrmartineau/SetiUI-Icons-Sublime to add in default icons right into the my own build.

One thing though: some files should be themed based off of more than extension. package.json, gulpfile.js, etc should be themed based off of name. I suppose adding built-in support for specific filename classes would be better (faster/less cluttering to the DOM) than adding a class for the entirety of every file's name.

While we wait, does anyone have a comprehensive, "good" looking grayscale icon pack? The icon pack I used doesn't mesh very well with the dark theme and is a little distracting.

nelsonlaquet avatar Feb 26 '16 22:02 nelsonlaquet

@nelsonlaquet you made a good point about the gulp, grunt and package.json files and thanks for linking the icons too. I've updated my PR which puts the filename in to attributes allowing special icons for specific files. I've also added support for css theming because I feel that this is the cleanest and simplest way to deliver this feature. Check out my comments here for more info https://github.com/Microsoft/vscode/pull/3200#issuecomment-194656772

pflannery avatar Mar 10 '16 04:03 pflannery

+1 I can find files much faster with the icons!

nepaul avatar Mar 24 '16 03:03 nepaul

Is the file tree exposed to extensions api? if you can expose it, i think that would allow the community to create an extension for this and for any further opinionated customizations all the while VSCode itself can remain neutral on the issue

fa7ad avatar Apr 01 '16 16:04 fa7ad

If that would be added, I'd like to port my icon extension (Brackets Icons) for Brackets to VS Code. In Brackets, an icon provider can be added, which is a function that returns an icon as a DOM element for a specified file name (docs). Since VS Code doesn't expose the DOM, there should be a layer between, but similar ideas can be used.

ivogabe avatar Apr 01 '16 17:04 ivogabe

No API atm to change the explorer.

bpasero avatar Apr 01 '16 17:04 bpasero

@bpasero is there plans for such a thing in the near future? if yes, any rough ETA?

fa7ad avatar Apr 01 '16 18:04 fa7ad

@egamma @chrisdias please chime in.

bpasero avatar Apr 01 '16 18:04 bpasero

+1

ghost avatar Apr 05 '16 00:04 ghost

@bpasero Could you list the needed acceptance criteria to get a pull request merged? Maybe I could help then.

donaldpipowitch avatar Apr 05 '16 10:04 donaldpipowitch

@donaldpipowitch I would think this feature should:

  • be configurable with a flag in settings
  • provide the necessary icons for all themes (SVG)

Still, our PM/UX might decide to veto. @chrisdias @stevencl please chime in.

bpasero avatar Apr 05 '16 10:04 bpasero

@bpasero Thank you. Could you define "be configurable with a flag in settings" a little bit more? What do you want to configure?

  • show/hide icons
  • match existing (built in) icons to file patterns
  • change existing (built in) icons to custom icons
  • ...?

donaldpipowitch avatar Apr 05 '16 10:04 donaldpipowitch