Untracked directories shown as dirty.
hgaiser opened this issue · comments
OS
Arch Linux.
Neovim version
v0.6.0
Nvim-tree version
0aec64d56c9448a039408228d410a01c41125d48
Describe the bug
Directories that only have untracked files in them are incorrectly shown as dirty (NvimTreeGitDirty
).
To Reproduce
Take the following example:
mkdir /tmp/foo
cd /tmp/foo
git init
mkdir bar
touch bar/foobar
git status --porcelain=v1 --untracked-files=all
This outputs:
?? bar/foobar
Which means the file foobar
will (correctly) show as untracked. The directory bar
however will show as dirty because it doesn't appear in this list (and the default behavior is to visualize it as dirty then), even if it's entire content is untracked. Running the following:
git status --porcelain=v1
Gives:
?? bar/
Which would mean the directory would (correctly) be shown as untracked. But this doesn't tell us anything about the files inside bar
so we can't determine their icons.
A proposed solution is to merge the outputs of --untracked-files=all
and --untracked-files=normal
, which would produce:
git status --porcelain=v1 && git status --porcelain=v1 --untracked-files=all
Which outputs:
?? bar/
?? bar/foobar
When throwing a dirty file in that directory the output would be:
touch bar/foobaz
git add bar/foobaz
echo "dirt" > bar/foobaz
{git status --porcelain=v1 && git status --porcelain=v1 --untracked-files=all} | sort | uniq
Will output:
AM bar/foobaz
?? bar/foobar
Which means the directory bar
is again not mentioned, but this time it is correct because it means it will show as dirty, following default behavior.
indeed, there is another issue referencing this, but this is not managed by nvim-tree yet :)
EDIT: my bad i forgot to reimplement it during the rewrite, it should work now.
Seems to work well for me :) thanks!