madskristensen / FileNesting

Nest files in Solution Explorer
Other
119 stars 59 forks source link

Items in folders are not auto-nested #78

Closed tom-englert closed 7 years ago

tom-englert commented 7 years ago

Installed product versions

Description

Auto-nesting does not work if the items are inside a folder

Steps to recreate

  1. Put some files that are subject to auto-nesting inside a project folder (not nested yet)
  2. Rename the file that should be auto-nested until it matches the auto-nesting criteria
  3. => Auto-nesting does not happen
  4. Repeat the same when the items are direct children of the project
  5. => Auto-nesting works

Current behavior

Auto-nesting does not nest items in folders

Expected behavior

Auto-nesting does nest items in folders

Analysis

I think the root cause is here:

class FileNestingFactory
{
    private static void ItemAdded(ProjectItem item)
    {
...
            if (parent == null || parent.Kind.Equals(VSConstants.ItemTypeGuid.PhysicalFile_string, StringComparison.OrdinalIgnoreCase))
                RunNesting(item);
...
    }

Looks like the intended behavior was: if the parent is a file, it's already nested, so skip auto-nesting. However it checks the opposite, so auto-nesting does only run if the parent is a file.