Skip to content

Commit 08bc86e

Browse files
committed
Check for the initial declaration in usedBeforeSelection, usedInSelection, and usedAfterSelection
1 parent b0232a0 commit 08bc86e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@ public ExtractMethodModel(IActiveCodePaneEditor editor, IEnumerable<Declaration>
3333
.ToList();
3434

3535
var usedInSelection = new HashSet<Declaration>(inScopeDeclarations.Where(item =>
36+
selection.Selection.Contains(item.Selection) &&
3637
item.References.Any(reference => inSelection.Contains(reference))));
3738

3839
var usedBeforeSelection = new HashSet<Declaration>(inScopeDeclarations.Where(item =>
40+
item.Selection.StartLine < selection.Selection.StartLine ||
3941
item.References.Any(reference => reference.Selection.StartLine < selection.Selection.StartLine)));
4042

4143
var usedAfterSelection = new HashSet<Declaration>(inScopeDeclarations.Where(item =>
44+
item.Selection.StartLine > selection.Selection.StartLine ||
4245
item.References.Any(reference => reference.Selection.StartLine > selection.Selection.EndLine)));
4346

4447
// identifiers used inside selection and before selection (or if it's a parameter) are candidates for parameters:

0 commit comments

Comments
 (0)