Skip to content

Commit fac848a

Browse files
committed
Merge pull request #1126 from SlavaRa/feature/fix_rename_package
[Critical] Fixes a bug which does not allow to rename the package
2 parents b089a0c + 989d80a commit fac848a

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

External/Plugins/CodeRefactor/Commands/Rename.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ protected override void ExecutionImplementation()
133133
if (renamePackage != null)
134134
{
135135
renamePackage.RegisterDocumentHelper(AssociatedDocumentHelper);
136+
renamePackage.OnRefactorComplete += (o, args) => FireOnRefactorComplete();
136137
renamePackage.Execute();
137138
}
138139
else

External/Plugins/CodeRefactor/PluginMain.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ private void RenameClicked(Object sender, EventArgs e)
433433
{
434434
try
435435
{
436-
RenamingHelper.AddToQueue(RefactoringHelper.GetDefaultRefactorTarget());
436+
var target = RefactoringHelper.GetDefaultRefactorTarget();
437+
if (target != null) RenamingHelper.AddToQueue(target);
437438
}
438439
catch (Exception ex)
439440
{

External/Plugins/CodeRefactor/Provider/RenamingHelper.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ public static void AddToQueue(ASResult target)
2424
}
2525
public static void AddToQueue(ASResult target, bool outputResults)
2626
{
27-
string originalName = RefactoringHelper.GetRefactorTargetName(target);
28-
string label = TextHelper.GetString("Label.NewName");
29-
string title = string.Format(TextHelper.GetString("Title.RenameDialog"), originalName);
30-
LineEntryDialog askName = new LineEntryDialog(title, label, originalName);
31-
if (askName.ShowDialog() == DialogResult.OK)
27+
if (target.IsPackage) queue.Add(new Rename(target, outputResults));
28+
else
3229
{
30+
string originalName = RefactoringHelper.GetRefactorTargetName(target);
31+
string label = TextHelper.GetString("Label.NewName");
32+
string title = string.Format(TextHelper.GetString("Title.RenameDialog"), originalName);
33+
LineEntryDialog askName = new LineEntryDialog(title, label, originalName);
34+
if (askName.ShowDialog() != DialogResult.OK) return;
3335
string newName = askName.Line.Trim();
3436
if (newName.Length == 0 || newName == originalName) return;
3537
queue.Add(new Rename(target, outputResults, newName));
@@ -40,8 +42,8 @@ public static void AddToQueue(ASResult target, bool outputResults)
4042
if (list[0].Name == "get") RenameMember(target.InClass, "get_" + originalName, "get_" + newName, outputResults);
4143
if (list[1].Name == "set") RenameMember(target.InClass, "set_" + originalName, "set_" + newName, outputResults);
4244
}
43-
if (currentCommand == null) ExecuteFirst();
4445
}
46+
if (currentCommand == null) ExecuteFirst();
4547
}
4648

4749
static void RenameMember(ClassModel inClass, string name, string newName, bool outputResults)

0 commit comments

Comments
 (0)