ivogabe / Brackets-Icons

File icons in Brackets' file tree
251 stars 59 forks source link

User icon double ups (primary and secondary are the same icon) #97

Closed HookyQR closed 8 years ago

HookyQR commented 9 years ago

I wanted to change the javascript icon to the nodejs_small icon and discovered that this caused the icon to show up as the main and the secondary icon when secondaries were turned on. I've tracked down the problem. The UserDIctionary,findFIleName function ignores the fileName parameter. This can be fixed by changing the body to the following code:

if (!this.settings[fileName]) return undefined;
if (!this.settings[fileName].ext) return this.settings[fileName];
if (this.settings[fileName].ext.indexOf(extension)===-1) return undefined;
return this.settings[fileName];

This has the handy side effect that you can specify secondary icons for specific files, just as are done in the presets, such as:

{ "gruntfile":
    { "ext"  : ["js","coffee"],
      "icon" : "devicons devicons-grunt",
      "color": "#fba919",
      "size" : 12
    }
}

With the second line as it is, any filename (of any extension) will be 'seconded' if the ext element isn't provided. Change to return undefined if this is undesireable.

Love the extension by the way, makes things much nicer to look at.

HookyQR commented 9 years ago

Of course, return would do. Think I was being a little over explicit there.

ivogabe commented 8 years ago

Thanks for reporting, that was indeed a bug. I've only changed the extension to the fileName. Limiting the icon to certain extensions sounds useful, though I'm not yet sure what the best design would be. I might implement such feature later.