Skip to content

Commit 9370a5c

Browse files
committed
Close #1787
1 parent be0a04f commit 9370a5c

File tree

2 files changed

+5
-35
lines changed

2 files changed

+5
-35
lines changed
Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
using System.Linq;
2-
using System.Runtime.InteropServices;
1+
using System.Runtime.InteropServices;
32
using Microsoft.Vbe.Interop;
4-
using Rubberduck.Parsing.Annotations;
5-
using Rubberduck.Parsing.Symbols;
6-
using Rubberduck.Parsing.VBA;
73
using Rubberduck.Settings;
84
using Rubberduck.SmartIndenter;
95

@@ -13,22 +9,17 @@ namespace Rubberduck.UI.Command
139
public class IndentCurrentModuleCommand : CommandBase
1410
{
1511
private readonly VBE _vbe;
16-
private readonly RubberduckParserState _state;
1712
private readonly IIndenter _indenter;
1813

19-
public IndentCurrentModuleCommand(VBE vbe, RubberduckParserState state, IIndenter indenter)
14+
public IndentCurrentModuleCommand(VBE vbe, IIndenter indenter)
2015
{
2116
_vbe = vbe;
22-
_state = state;
2317
_indenter = indenter;
2418
}
2519

2620
public override bool CanExecute(object parameter)
2721
{
28-
var target = FindTarget(parameter);
29-
30-
return _vbe.ActiveCodePane != null && target != null &&
31-
target.Annotations.All(a => a.AnnotationType != AnnotationType.NoIndent);
22+
return _vbe.ActiveCodePane != null;
3223
}
3324

3425
public override void Execute(object parameter)
@@ -37,23 +28,5 @@ public override void Execute(object parameter)
3728
}
3829

3930
public RubberduckHotkey Hotkey { get { return RubberduckHotkey.IndentModule; } }
40-
41-
private Declaration FindTarget(object parameter)
42-
{
43-
var declaration = parameter as Declaration;
44-
if (declaration != null)
45-
{
46-
return declaration;
47-
}
48-
49-
var selectedDeclaration = _state.FindSelectedDeclaration(_vbe.ActiveCodePane);
50-
51-
while (selectedDeclaration != null && selectedDeclaration.DeclarationType.HasFlag(DeclarationType.Module))
52-
{
53-
selectedDeclaration = selectedDeclaration.ParentDeclaration;
54-
}
55-
56-
return selectedDeclaration;
57-
}
5831
}
5932
}

RetailCoder.VBE/UI/Command/IndentCurrentProcedureCommand.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Runtime.InteropServices;
22
using Microsoft.Vbe.Interop;
3-
using Rubberduck.Parsing.VBA;
43
using Rubberduck.Settings;
54
using Rubberduck.SmartIndenter;
65

@@ -10,19 +9,17 @@ namespace Rubberduck.UI.Command
109
public class IndentCurrentProcedureCommand : CommandBase
1110
{
1211
private readonly VBE _vbe;
13-
private readonly RubberduckParserState _state;
1412
private readonly IIndenter _indenter;
1513

16-
public IndentCurrentProcedureCommand(VBE vbe, RubberduckParserState state, IIndenter indenter)
14+
public IndentCurrentProcedureCommand(VBE vbe, IIndenter indenter)
1715
{
1816
_vbe = vbe;
19-
_state = state;
2017
_indenter = indenter;
2118
}
2219

2320
public override bool CanExecute(object parameter)
2421
{
25-
return _state.FindSelectedDeclaration(_vbe.ActiveCodePane, true) != null;
22+
return _vbe.ActiveCodePane != null;
2623
}
2724

2825
public override void Execute(object parameter)

0 commit comments

Comments
 (0)