skip to Main Content

In the explorer of VS Code I want to have the gitignored files grey.

I managed to add "gitDecoration.ignoredResourceForeground":"#CCCCCC", however I now have various files and folders where there are other decorations and it looks like explorer.decorations.colors takes precedence over this. This mechanism now destroys the coloring of the ignored resources again as it looks like this rule is checked later.

How can I fix this and have the gitignored rule applied no matter what happens otherwise?

This is for:

VSCode: Version: 1.73.1
Release: 22314
Commit: 14f2d26367b7e8f03ff2352516ba27d6302dd7b1
Date: 2022-11-10T18:37:51.314Z (2 wks ago)
Electron: 19.0.17
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin x64 19.6.0
Sandboxed: No

MacOS: Catalina 10.15.7

Git: 2.38.1

Screenshot

The screenshot shows a situation where chamaeleon/ is part of .gitignore. All files nicely are greyed out with the exception of ChameleonTemplate.php which contains a PHP error, as well as srcwhich contains a file containing an error and Components which contains another file with an editor decoration due to a type problem in PHP.

Clarification: My question is not about files which are only gitignored (they show uo correctly) but about files which are gitognored and have a further editor decoration (such as a syntax error). If these two decorations apply both then the question is which one takes precedence. That is the problem here.

My question is rather not a bug (as in "does not work as expected") but a conceptual one. If we have two different reasons for setting foreground color, and both reasons apply, which color is chosen?

A workaround would be if we were able to set other attributes such as underline, strike-through, background-color or font type and not only foreground-color, because such attributes could be combined. Foreground-color and foreground-color cannot be combined but needs a precedence rule.

4

Answers


  1. For me this happened automatically… I think you just need the high-contrast dark color theme in vscoode. You could also choose another color theme but this changes. You could also look into making you own color theme for vscode like I did, and edit the colors to your liking.
    My VSCODE

    As you can see, fort-bishop.exe is grayed out. I have ignored it in my .gitignore.

    Login or Signup to reply.
  2. Probably you should provide more information, like VS Code and git version. I am running VS Code 1.73.1 and git 2.37.1 in macOS and it works automatically.

    Possible solutions:

    • It could just be a bug in VS Code or git. Check if you are running the latest versions.
    • Restart VS Code.
    • Try to clone the project again.
    • Check that your project is not a symlinked folder.
    Login or Signup to reply.
  3. Probably, you missed workbench.colorCustomizations.
    In your settings.json:

    "workbench.colorCustomizations": {
        "gitDecoration.ignoredResourceForeground": "#ff0000"
    }
    
    Login or Signup to reply.
  4. Seems like a known issue. Yet, please add VSCode version details. Below are the possible workarounds which might help:

    1. Clear the git cache, re-add the files and re-commit. Re-save the .gitignore files once again.
    2. Make a dummy edit to the .gitignore file and try saving the file.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search