Skip to content

Commit bfc582b

Browse files
committed
Close #977
1 parent dbbb414 commit bfc582b

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

RetailCoder.VBE/UI/Command/MenuItems/ParentMenus/ParentMenuItemBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private CommandBarControl InitializeChildControl(ICommandMenuItem item)
117117
SetButtonImage(child, item.Image, item.Mask);
118118

119119
child.BeginGroup = item.BeginGroup;
120-
child.Tag = item.Key;
120+
child.Tag = item.GetType().FullName;
121121
child.Caption = item.Caption.Invoke();
122122

123123
Debug.WriteLine("Menu item '{0}' created; hash code: {1} (command hash code {2})", child.Caption, child.GetHashCode(), item.Command.GetHashCode());
@@ -131,7 +131,7 @@ private CommandBarControl InitializeChildControl(ICommandMenuItem item)
131131

132132
private void child_Click(CommandBarButton Ctrl, ref bool CancelDefault)
133133
{
134-
var item = _items.Select(kvp => kvp.Key).SingleOrDefault(menu => menu.Key == Ctrl.Tag) as ICommandMenuItem;
134+
var item = _items.Select(kvp => kvp.Key).SingleOrDefault(menu => menu.GetType().FullName == Ctrl.Tag) as ICommandMenuItem;
135135
if (item == null || Ctrl.GetHashCode() == _lastHashCode)
136136
{
137137
return;

RetailCoder.VBE/UI/Command/Refactorings/CodePaneRefactorRenameCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public CodePaneRefactorRenameCommand(VBE vbe, RubberduckParserState state, IActi
2424

2525
public override void Execute(object parameter)
2626
{
27+
if (Vbe.ActiveCodePane == null) { return; }
28+
2729
using (var view = new RenameDialog())
2830
{
2931
var factory = new RenamePresenterFactory(Vbe, view, _state, new MessageBox(), _wrapperWrapperFactory);

RetailCoder.VBE/UI/Command/Refactorings/ProjectExplorerRefactorRenameCommand.cs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,16 @@ private Declaration GetTarget()
4848
d.DeclarationType == DeclarationType.Project && d.IdentifierName == Vbe.ActiveVBProject.Name);
4949
}
5050

51-
if (Vbe.ActiveCodePane == null || Vbe.ActiveCodePane.CodeModule != Vbe.SelectedVBComponent.CodeModule)
52-
{
53-
return _state.AllUserDeclarations.SingleOrDefault(
54-
t => t.IdentifierName == Vbe.SelectedVBComponent.Name &&
55-
t.Project == Vbe.ActiveVBProject &&
56-
new[]
57-
{
58-
DeclarationType.Class,
59-
DeclarationType.Document,
60-
DeclarationType.Module,
61-
DeclarationType.UserForm
62-
}.Contains(t.DeclarationType));
63-
}
64-
65-
return null;
51+
return _state.AllUserDeclarations.SingleOrDefault(
52+
t => t.IdentifierName == Vbe.SelectedVBComponent.Name &&
53+
t.Project == Vbe.ActiveVBProject &&
54+
new[]
55+
{
56+
DeclarationType.Class,
57+
DeclarationType.Document,
58+
DeclarationType.Module,
59+
DeclarationType.UserForm
60+
}.Contains(t.DeclarationType));
6661
}
6762
}
6863
}

0 commit comments

Comments
 (0)