Alexander-Miller / treemacs

GNU General Public License v3.0
2.09k stars 152 forks source link

Some git-ignored directories and files not being hidden #962

Open sammorley-short opened 2 years ago

sammorley-short commented 2 years ago

Perhaps a dupe of https://github.com/Alexander-Miller/treemacs/issues/935, but not quite sure.

I have both __pycache__ and *.pyc added to my project's .gitignore, which are properly causing those files to be ignored by git. However, none of the project's __pycache__ directories, nor the enclosed .pyc files are hidden, despite other git-ignored files (such as TAGS) being hidden correctly. Similarly, although dot-prefixed directories which are in my .gitignore (such as .mypy_cache) are hidden correctly via treemacs-toggle-show-dotfiles, these are not hidden via treemacs-hide-gitignored-files-mode.

Hence, I think the problem seems to be that directories and their contents are not being hidden correctly by the treemacs-hide-gitignored-files-mode command specifically.

Thanks!

Alexander-Miller commented 2 years ago

The basic setup works on my end:

hideshow

Can you give me an example of the directory structure for when it doesn't?

tx46 commented 2 years ago

I have /node_modules/ .gitignored but it's displayed anyway in treemacs. 👀

sammorley-short commented 2 years ago

@Alexander-Miller Not sure if this is something wrong with my local version (I am using Doom Emacs and have ran doom upgrade), but here's what I see before and after toggling the setting:

Before: Screenshot 2022-09-06 at 22 22 29

After: Screenshot 2022-09-06 at 22 22 35

As you can see, I am not able to reproduce your behaviour above 😞.

I don't think this should be something to do with my Treemacs config either, which is as follows:

(setq
 treemacs-tag-follow-delay 0.5
 treemacs-recenter-after-tag-follow 'always
 )
(defun turn-on-treemacs-tag-follow-mode ()
  (treemacs-tag-follow-mode 't)
)
(add-hook 'treemacs-mode-hook 'turn-on-treemacs-tag-follow-mode)

Any idea what's going on?

Alexander-Miller commented 2 years ago

Any idea what's going on?

No, and that means we need to do some digging. Basics first:

Same questions for you @philiparvidsson. First we need to determine that treemacs recognizes the ignored files, then we can look into its rendering decisions.

(add-hook 'treemacs-mode-hook 'turn-on-treemacs-tag-follow-mode)

You shouldn't need that wrapper. If you want tag-follow-mode always active in doom you can do (after! treemacs (treemacs-tag-follow-mode)). t shouldn't be quoted either.

sammorley-short commented 1 year ago

Thanks for you help. Let's dig.

Is git-mode on, does it actually highlight changes correctly?

Yep, changes are highlighted correctly in the sidebar and magit works without issue.

What does git status --porcelain --ignored=matching . output for you?

?? .gitignore
!! .DS_Store
!! .cask/
!! __pycache__/
!! foo/
!! setup.py

What about python /treemacs/install/location/treemacs-git-status.py /your/repo/root 9999 "" when run in your examplre repository?

#s(hash-table size 6 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("./.gitignore"treemacs-git-untracked-face"./.DS_Store"treemacs-git-ignored-face"./.cask"treemacs-git-ignored-face"./__pycache__"treemacs-git-ignored-face"./foo"treemacs-git-ignored-face"./setup.py"treemacs-git-ignored-face))%
Alexander-Miller commented 1 year ago

Yep, changes are highlighted correctly in the sidebar and magit works without issue.

Does that include the ignored files, if treemacs-hide-gitignored-files-mode is disabled?

Btw, how do you enable hide-gitignored-files-mode? It has to be via (treemacs-hide-gitignored-files-mode t). Depending on you elisp knowledge that might be pretty obvious, but I've had a non-trivial number of issues where inexperienced users just changed the variable value.

s(hash-table size 6 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("./.gitignore"treemacs-git-untracked-face"./.DS_Store"treemacs-git-ignored-face"./.cask"treemacs-git-ignored-face"./pycache"treemacs-git-ignored-face"./foo"treemacs-git-ignored-face"./setup.py"treemacs-git-ignored-face))%

That % at the end is a typo, right?

Otherwise the script output looks correct, assuming you used . for your directory root instead of the absolute path.

Assuming that's all correct we'll next look into the information treemacs saves about your files. First you need to run this line (ht-clear! treemacs--annotation-store). Then head over to your project and hit refresh once. Then run this code and tell me the output:

(treemacs--maphash treemacs--annotation-store (key value)
 (message "Annotation %s -> %s" key value))
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity.

Alexander-Miller commented 1 year ago

:eyes:

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity.

colawithsauce commented 1 year ago

Today I also met this issue, but after turn off treemacs-tree-mode and re-enable it with Extended or Deferred mode solve this problem. Hope this message can help others.

I am running on Emacs 30 master branch and Doom Emacs.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity.