Skip to content

Commit 6ce76af

Browse files
committed
Issue #4016 AddComponentCommand should use the active project name as a default folder name
1 parent 362918e commit 6ce76af

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Rubberduck.Core/UI/CodeExplorer/Commands/AddComponentCommand.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ namespace Rubberduck.UI.CodeExplorer.Commands
99
public class AddComponentCommand
1010
{
1111
private readonly IVBE _vbe;
12-
private const string DefaultFolder = "VBAProject";
1312

1413
public AddComponentCommand(IVBE vbe)
1514
{
@@ -69,16 +68,22 @@ private Declaration GetDeclaration(CodeExplorerItemViewModel node)
6968

7069
return (node as ICodeExplorerDeclarationViewModel)?.Declaration;
7170
}
72-
71+
private string GetActiveProjectName()
72+
{
73+
using (var activeProject = _vbe.ActiveVBProject)
74+
{
75+
return activeProject.Name;
76+
}
77+
}
7378
private string GetFolder(CodeExplorerItemViewModel node)
7479
{
7580
switch (node)
7681
{
7782
case null:
78-
return DefaultFolder;
83+
return GetActiveProjectName();
7984
case ICodeExplorerDeclarationViewModel declarationNode:
8085
return string.IsNullOrEmpty(declarationNode.Declaration.CustomFolder)
81-
? DefaultFolder
86+
? GetActiveProjectName()
8287
: declarationNode.Declaration.CustomFolder.Replace("\"", string.Empty);
8388
default:
8489
return ((CodeExplorerCustomFolderViewModel)node).FullPath;

0 commit comments

Comments
 (0)