Skip to content

Commit

Permalink
Issue #4016 AddComponentCommand should use the active project name as…
Browse files Browse the repository at this point in the history
… a default folder name
  • Loading branch information
Imh0t3b committed Jul 10, 2018
1 parent 362918e commit 6ce76af
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Rubberduck.Core/UI/CodeExplorer/Commands/AddComponentCommand.cs
Expand Up @@ -9,7 +9,6 @@ namespace Rubberduck.UI.CodeExplorer.Commands
public class AddComponentCommand
{
private readonly IVBE _vbe;
private const string DefaultFolder = "VBAProject";

public AddComponentCommand(IVBE vbe)
{
Expand Down Expand Up @@ -69,16 +68,22 @@ private Declaration GetDeclaration(CodeExplorerItemViewModel node)

return (node as ICodeExplorerDeclarationViewModel)?.Declaration;
}

private string GetActiveProjectName()
{
using (var activeProject = _vbe.ActiveVBProject)
{
return activeProject.Name;
}
}
private string GetFolder(CodeExplorerItemViewModel node)
{
switch (node)
{
case null:
return DefaultFolder;
return GetActiveProjectName();
case ICodeExplorerDeclarationViewModel declarationNode:
return string.IsNullOrEmpty(declarationNode.Declaration.CustomFolder)
? DefaultFolder
? GetActiveProjectName()
: declarationNode.Declaration.CustomFolder.Replace("\"", string.Empty);
default:
return ((CodeExplorerCustomFolderViewModel)node).FullPath;
Expand Down

0 comments on commit 6ce76af

Please sign in to comment.