Skip to content

Commit 1b68ce2

Browse files
committed
Merge pull request #1321 from retailcoder/next
mousehook and current selection fixes ...still not perfect though
2 parents 92841d6 + 3b4d686 commit 1b68ce2

File tree

9 files changed

+16
-9
lines changed

9 files changed

+16
-9
lines changed

RetailCoder.VBE/App.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,10 @@ public void Startup()
142142
UiDispatcher.Invoke(() =>
143143
{
144144
_parser.State.OnParseRequested(this);
145-
_hooks.HookHotkeys();
146145
});
147146
}, new StaTaskScheduler()).ConfigureAwait(false);
147+
148+
_hooks.HookHotkeys();
148149
}
149150

150151
#region sink handlers. todo: move to another class

RetailCoder.VBE/UI/Command/FindAllImplementationsCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private Declaration FindTarget(object parameter)
115115
return declaration;
116116
}
117117

118-
return _state.FindSelecteDeclaration(_vbe.ActiveCodePane);
118+
return _state.FindSelectedDeclaration(_vbe.ActiveCodePane);
119119
}
120120

121121
private IEnumerable<Declaration> FindImplementations(Declaration target)

RetailCoder.VBE/UI/Command/FindAllReferencesCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private Declaration FindTarget(object parameter)
110110
return declaration;
111111
}
112112

113-
return _state.FindSelecteDeclaration(_vbe.ActiveCodePane);
113+
return _state.FindSelectedDeclaration(_vbe.ActiveCodePane);
114114
}
115115
}
116116
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public override bool CanExecute(object parameter)
3232
return false;
3333
}
3434

35-
var target = _state.FindSelecteDeclaration(Vbe.ActiveCodePane);
35+
var target = _state.FindSelectedDeclaration(Vbe.ActiveCodePane);
3636
return _state.Status == ParserState.Ready && target != null;
3737
}
3838

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public override bool CanExecute(object parameter)
2828
return false;
2929
}
3030

31-
var target = _state.FindSelecteDeclaration(pane);
31+
var target = _state.FindSelectedDeclaration(pane);
3232

3333
var canExecute = target != null
3434
&& target.DeclarationType == DeclarationType.Variable

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public override bool CanExecute(object parameter)
2929
return false;
3030
}
3131

32-
//var target = _state.FindSelecteDeclaration(Vbe.ActiveCodePane); // nope. logic is a bit more complex here.
32+
//var target = _state.FindSelectedDeclaration(Vbe.ActiveCodePane); // nope. logic is a bit more complex here.
3333

3434
var selection = Vbe.ActiveCodePane.GetSelection();
3535
var targetInterface = _state.AllUserDeclarations.FindInterface(selection);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public override bool CanExecute(object parameter)
2929
return false;
3030
}
3131

32-
var target = _state.FindSelecteDeclaration(Vbe.ActiveCodePane);
32+
var target = _state.FindSelectedDeclaration(Vbe.ActiveCodePane);
3333
var canExecute = target != null
3434
&& (target.DeclarationType == DeclarationType.Variable || target.DeclarationType == DeclarationType.Constant)
3535
&& target.References.Any();

Rubberduck.Parsing/VBA/RubberduckParserState.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ public bool IsModified(QualifiedModuleName key)
474474
private QualifiedSelection _lastSelection;
475475
private Declaration _selectedDeclaration;
476476

477-
public Declaration FindSelecteDeclaration(CodePane activeCodePane)
477+
public Declaration FindSelectedDeclaration(CodePane activeCodePane)
478478
{
479479
var selection = activeCodePane.GetSelection();
480480
if (selection.Equals(_lastSelection))
@@ -493,6 +493,12 @@ public Declaration FindSelecteDeclaration(CodePane activeCodePane)
493493
(IsSelectedDeclaration(selection, item) ||
494494
item.References.Any(reference => IsSelectedReference(selection, reference))));
495495
}
496+
497+
if (_selectedDeclaration != null)
498+
{
499+
Debug.WriteLine("Current selection ({0}) is '{1}' ({2})", selection, _selectedDeclaration.IdentifierName, _selectedDeclaration.DeclarationType);
500+
}
501+
496502
return _selectedDeclaration;
497503
}
498504

Rubberduck.SmartIndenter/Indenter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void IndentCurrentProcedure()
5555

5656
if (string.IsNullOrEmpty(procName))
5757
{
58-
procName = null;
58+
return;
5959
}
6060

6161
var startLine = pane.CodeModule.get_ProcStartLine(procName, procKind);

0 commit comments

Comments
 (0)