Skip to content

Commit 4022c06

Browse files
committed
Stop prematurely disposing of Project in AddTestModuleCommand, see #3877
1 parent 6fbffb1 commit 4022c06

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Rubberduck.Core/UI/Command/AddTestModuleCommand.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,16 @@ private string DeclarationFormatFor(string declarationFormat, string type, IUnit
121121

122122
private IVBProject GetProject()
123123
{
124-
using (var activeProject = _vbe.ActiveVBProject)
124+
var activeProject = _vbe.ActiveVBProject;
125+
if (!activeProject.IsWrappingNullReference)
125126
{
126-
if (!activeProject.IsWrappingNullReference)
127-
{
128-
return activeProject;
129-
}
127+
return activeProject;
130128
}
131129

132130
using (var projects = _vbe.VBProjects)
133131
{
134132
return projects.Count == 1
135-
? projects[1]
133+
? projects[1] // because VBA-Side indexing
136134
: new VBProject(null);
137135
}
138136
}

0 commit comments

Comments
 (0)