Skip to content

Commit 7f97098

Browse files
committed
Changes following PR comments
1 parent ae447f5 commit 7f97098

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ private bool SpecialEvaluateCanExecute(object parameter)
3333
{
3434
return _exportCommand.CanExecute(parameter) &&
3535
parameter is CodeExplorerComponentViewModel viewModel &&
36-
viewModel.Declaration.QualifiedName.QualifiedModuleName.ComponentType != ComponentType.Document;
36+
viewModel.Declaration.QualifiedModuleName.ComponentType != ComponentType.Document;
3737
}
3838

3939
protected override void OnExecute(object parameter)
4040
{
4141
if (!(parameter is CodeExplorerComponentViewModel node) ||
4242
node.Declaration == null ||
43-
node.Declaration.QualifiedName.QualifiedModuleName.ComponentType == ComponentType.Document)
43+
node.Declaration.QualifiedModuleName.ComponentType == ComponentType.Document)
4444
{
4545
return;
4646
}
@@ -71,15 +71,18 @@ public bool RemoveComponent(QualifiedModuleName qualifiedModuleName, bool prompt
7171

7272
private bool TryExport(QualifiedModuleName qualifiedModuleName)
7373
{
74-
var projectId = qualifiedModuleName.ProjectId;
75-
var projectType = _projectsRepository.Project(projectId).Type;
7674
var component = _projectsRepository.Component(qualifiedModuleName);
75+
if (component is null)
76+
{
77+
return false; // Edge-case, component already gone.
78+
}
7779

78-
if (projectType == ProjectType.HostProject && component.IsSaved)
80+
if (_vbe.Kind == VBEKind.Standalone && component.IsSaved)
7981
{
8082
return true; // File already up-to-date
8183
}
8284

85+
// "Do you want to export '{qualifiedModuleName.Name}' before removing?" (localized)
8386
var message = string.Format(CodeExplorerUI.ExportBeforeRemove_Prompt, qualifiedModuleName.Name);
8487

8588
switch (_messageBox.Confirm(message, CodeExplorerUI.ExportBeforeRemove_Caption, ConfirmationOutcome.Yes))

0 commit comments

Comments
 (0)