@@ -31,7 +31,6 @@ public class RenameRefactoring : IRefactoring
3131 private readonly IProjectsProvider _projectsProvider ;
3232 private readonly IRewritingManager _rewritingManager ;
3333 private RenameModel _model ;
34- private QualifiedSelection ? _initialSelection ;
3534 private readonly IDictionary < DeclarationType , Action < IRewriteSession > > _renameActions ;
3635 private readonly List < string > _neverRenameIdentifiers ;
3736
@@ -47,10 +46,7 @@ public RenameRefactoring(IVBE vbe, IRefactoringPresenterFactory factory, IMessag
4746 _projectsProvider = projectsProvider ;
4847 _rewritingManager = rewritingManager ;
4948 _model = null ;
50- using ( var activeCodePane = _vbe . ActiveCodePane )
51- {
52- _initialSelection = activeCodePane . GetQualifiedSelection ( ) ;
53- }
49+
5450 _renameActions = new Dictionary < DeclarationType , Action < IRewriteSession > >
5551 {
5652 { DeclarationType . Member , RenameMember } ,
@@ -73,7 +69,6 @@ private RenameModel InitializeModel(Declaration target)
7369
7470 public void Refactor ( QualifiedSelection qualifiedSelection )
7571 {
76- CacheInitialSelection ( qualifiedSelection ) ;
7772 Refactor ( ) ;
7873 }
7974
@@ -91,7 +86,6 @@ public void Refactor()
9186 if ( presenter != null )
9287 {
9388 RefactorImpl ( presenter . Model . Target , presenter ) ;
94- RestoreInitialSelection ( ) ;
9589 }
9690 }
9791 }
@@ -109,7 +103,6 @@ public void Refactor(Declaration target)
109103 var presenter = container . Value ;
110104
111105 RefactorImpl ( target , presenter ) ;
112- RestoreInitialSelection ( ) ;
113106 }
114107 }
115108
@@ -585,40 +578,6 @@ private IEnumerable<Declaration> FindEventHandlersForControl(Declaration control
585578 return Enumerable . Empty < Declaration > ( ) ;
586579 }
587580
588- private void CacheInitialSelection ( QualifiedSelection qSelection )
589- {
590- var component = _projectsProvider . Component ( qSelection . QualifiedName ) ;
591- using ( var codeModule = component . CodeModule )
592- using ( var codePane = codeModule . CodePane )
593- {
594- if ( ! codePane . IsWrappingNullReference )
595- {
596- _initialSelection = codePane . GetQualifiedSelection ( ) ;
597- }
598- }
599- }
600-
601- private void RestoreInitialSelection ( )
602- {
603- if ( ! _initialSelection . HasValue )
604- {
605- return ;
606- }
607-
608- var qualifiedSelection = _initialSelection . Value ;
609- var component = _projectsProvider . Component ( qualifiedSelection . QualifiedName ) ;
610- using ( var codeModule = component . CodeModule )
611- {
612- using ( var codePane = codeModule . CodePane )
613- {
614- if ( ! codePane . IsWrappingNullReference )
615- {
616- codePane . Selection = qualifiedSelection . Selection ;
617- }
618- }
619- }
620- }
621-
622581 private void PresentRenameErrorMessage ( string errorMsg )
623582 {
624583 _messageBox ? . NotifyWarn ( errorMsg , RubberduckUI . RenameDialog_Caption ) ;
0 commit comments