Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ void GetFolderContent (Project project, string folder, out List<ProjectFile> fil
{
string folderPrefix = folder + Path.DirectorySeparatorChar;

var visitedFiles = new HashSet<FilePath> ();
files = new List<ProjectFile> ();
folders = new List<string> ();

Expand All @@ -100,7 +101,8 @@ void GetFolderContent (Project project, string folder, out List<ProjectFile> fil
? project.BaseDirectory.Combine (file.ProjectVirtualPath).ParentDirectory
: file.FilePath.ParentDirectory;

if (dir == folder) {
if (dir == folder && !visitedFiles.Contains (file.FilePath)) {
visitedFiles.Add (file.FilePath);
files.Add (file);
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using System.Linq;
using System.Runtime.CompilerServices;
using Mono.Addins;
using MonoDevelop.Core;
using MonoDevelop.Projects;

namespace MonoDevelop.Ide.Projects.FileNesting
Expand Down Expand Up @@ -166,7 +167,7 @@ public ProjectFileNestingInfo (ProjectFile projectFile)
}
}

readonly ConcurrentDictionary<ProjectFile, ProjectFileNestingInfo> projectFiles = new ConcurrentDictionary<ProjectFile, ProjectFileNestingInfo> ();
readonly ConcurrentDictionary<FilePath, ProjectFileNestingInfo> projectFiles = new ConcurrentDictionary<FilePath, ProjectFileNestingInfo> ();
bool fileNestingEnabled;

public Project Project { get; }
Expand Down Expand Up @@ -195,10 +196,10 @@ void EnsureInitialized ()

ProjectFileNestingInfo AddFile (ProjectFile projectFile)
{
var tmp = projectFiles.GetOrAdd (projectFile, new ProjectFileNestingInfo (projectFile));
var tmp = projectFiles.GetOrAdd (projectFile.FilePath, new ProjectFileNestingInfo (projectFile));
tmp.Parent = FileNestingService.InternalGetParentFile (projectFile);
if (tmp.Parent != null) {
var parent = projectFiles.GetOrAdd (tmp.Parent, new ProjectFileNestingInfo (tmp.Parent));
var parent = projectFiles.GetOrAdd (tmp.Parent.FilePath, new ProjectFileNestingInfo (tmp.Parent));
if (parent.Children == null) {
parent.Children = new ProjectFileCollection ();
}
Expand All @@ -207,19 +208,19 @@ ProjectFileNestingInfo AddFile (ProjectFile projectFile)
}
}

projectFiles [projectFile] = tmp;
projectFiles [projectFile.FilePath] = tmp;
return tmp;
}

ProjectFileNestingInfo RemoveFile (ProjectFile projectFile, List<ProjectFile> originalFilesToRemove = null)
{
bool actuallyRemoveFiles = originalFilesToRemove == null;

projectFiles.TryRemove (projectFile, out var nestingInfo);
projectFiles.TryRemove (projectFile.FilePath, out var nestingInfo);

// Update parent
if (nestingInfo?.Parent != null) {
if (projectFiles.TryGetValue (nestingInfo.Parent, out var tmp)) {
if (projectFiles.TryGetValue (nestingInfo.Parent.FilePath, out var tmp)) {
tmp.Children.Remove (projectFile);
}
}
Expand Down Expand Up @@ -296,7 +297,7 @@ public ProjectFile GetParentForFile (ProjectFile inputFile)
if (!fileNestingEnabled)
return null;

return projectFiles.TryGetValue (inputFile, out var nestingInfo) ? nestingInfo.Parent : null;
return projectFiles.TryGetValue (inputFile.FilePath, out var nestingInfo) ? nestingInfo.Parent : null;
}

public ProjectFileCollection GetChildrenForFile (ProjectFile inputFile)
Expand All @@ -305,7 +306,7 @@ public ProjectFileCollection GetChildrenForFile (ProjectFile inputFile)
if (!fileNestingEnabled)
return null;

return projectFiles.TryGetValue (inputFile, out var nestingInfo) ? nestingInfo.Children : null;
return projectFiles.TryGetValue (inputFile.FilePath, out var nestingInfo) ? nestingInfo.Children : null;
}

public void Dispose ()
Expand Down