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

Wildcard files.association rules do not override specific keys #241

Closed
Tyriar opened this issue Apr 26, 2018 · 14 comments
Closed

Wildcard files.association rules do not override specific keys #241

Tyriar opened this issue Apr 26, 2018 · 14 comments

Comments

@Tyriar
Copy link

Tyriar commented Apr 26, 2018

I want to make the explorer look less like a Christmas tree and one of the ways I want to do this is by using a single icon for all txt/md files. However, when I do this:

  "material-icon-theme.files.associations": {
    "*.md": "document",
    "*.txt": "document"
  },

Icons with specific icons are not overridden:

screen shot 2018-04-26 at 6 55 38 am

I would expect a wildcard to override all of them. I also don't really want to pollute my settings file with what I think is the only workaround:

"material-icon-theme.files.associations": {
    "CODE_OF_CONDUCT.md": "document",
    "CODE_OF_CONDUCT.txt": "document",
    "CONTRIBUTING.md": "document",
    "CONTRIBUTING.txt": "document",
    "README.md": "document",
    "README.txt": "document",
    // more...?
}
@PKief
Copy link
Owner

PKief commented Apr 26, 2018

At first, I like the comparison with a Christmas tree very much 🎄 😉


Problem:

If you use the following line in the "material-icon-theme.files.associations" config:

"*.md": "document",

then only the following part is changed in the material-icons.json file in your extension folder:

"fileExtensions": {
    "md": "document",
}

But the fileNames property (with e.g. "Readme.md") has more power than the fileExtensions property and so it overwrites the extensions every time. This is configured in the VS Code API by default and it also makes sense. Because otherwise I could not provide specific icons for "License.md" etc.


Solution:

At the moment your "workaround" is the only way to overwrite these file icons.

But I could add the option that the wildcard will overwrite all files. The implementation of this is not a big deal but I was wondering how I could add this option without adding some breaking changes or a complete new settings entry.

My idea to solve it, would be an additional character or syntax in the wildcard like an exclamation mark before the asterisk. The exclamation mark would flag this particular file extension to remove all related file names:

"!*.md": "document",

What do you think about this concept? Does the exclamation mark represent it well?

@PKief
Copy link
Owner

PKief commented Apr 26, 2018

Maybe this wildcard with two asterisks would be better than the exclamation mark:

"**.md": "document"

I already did some adjustments in the code and it works fine.

@Tyriar
Copy link
Author

Tyriar commented Apr 27, 2018

Hmm, well ! in a file path like this often means negation, and ** often means "any folder". Not sure what is most intuitive.

@PKief
Copy link
Owner

PKief commented May 3, 2018

@Tyriar I slept on it for a few nights, but I couldn't find another solution that was more intuitive. In my opinion the two asterisks are good enough at the moment. If there could be some issues with this in the future, then we can see further. But for now it should be fine for this kind of purpose.
I plan to update the extension this weekend!

@Tyriar
Copy link
Author

Tyriar commented May 6, 2018

@PKief works great 👍

@PCASME
Copy link

PCASME commented Mar 8, 2019

I have a related issue with wildcards in the filename.
Seems that the wildcards only works after a dot in the filename so if I need override filenames with a specific pattern (e.g.: **-routing.module.ts) actually doesn't works.

I don't know if I am doing something wrong or I misspelled something. Any help will be appreciated.

On the other hand, don't would be better if in the custom filename extenssions we can set a regular expression pattern, and if that pattern matches make the icon override?

@PKief
Copy link
Owner

PKief commented Mar 8, 2019

@PCASME Unfortunately this feature is not supported by the VS Code extension API yet (microsoft/vscode#12493). It was already requested for this extension, so I'll keep track of this in issue #198.

@PCASME
Copy link

PCASME commented Mar 8, 2019

@PKief thanks for your quickly answer.
I had no knowledge about that, sorry.
I'll also keep track the issue and wait for a future resolution though it was opened in 2016 and the last comments seems that there is no intention to implement regexp in file associations.
We will see...
Thanks again.

@PKief
Copy link
Owner

PKief commented Mar 24, 2019

@Tyriar With the latest update you can also turn off the lights of the Christmas tree 😉

"material-icon-theme.saturation": 0

Preview:

icons without saturation

Or just "dim" the lights:

Saturation 1 Saturation 0.5 Saturation 0.3 Saturation 0
saturation 1 saturation 0.5 saturation 0.5 saturation 0

Happy styling and coding 👍

@gusbemacbe
Copy link

Hello @PKief !

The file name which contains space does not catch icon association:

    "material-icon-theme.files.associations": 
    {
        "Journal des Modifications.md": "changelog",
        "Registro de Cambios.md": "changelog"
    },

I think @Tyriar should review again, making compatible with regex matching and file namespaces.

@gusbemacbe
Copy link

Hello @PKief, will there be support for file name which spaces? If not, I will request on @Tyriar's Microsoft's repository.

@PKief
Copy link
Owner

PKief commented Jan 26, 2020

@gusbemacbe Currently, there's no support for this! Please check at VS Code if there is already an issue or open one there.

@gusbemacbe
Copy link

@PKief

There are not similar issues, but I decided to leave the new issue there: microsoft/vscode#35350.

@zm-cttae
Copy link

zm-cttae commented Jan 29, 2023

I saw 🎄 lights at the stage of 5-6 Markdown metafiles.
!! works in globs generally speaking, and is a construct most JS developers are familiar with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants