From f145eebada92c2dd5ccdfd704fb519a91c6f1def Mon Sep 17 00:00:00 2001 From: boris_i Date: Sun, 31 May 2009 12:13:37 +0000 Subject: [PATCH] Fixed a bug where selected lines were deselected when trying to find/replace Replacing can now be made undone --- .../BuilderModes/ClassicModes/FindReplaceMode.cs | 11 +++++++---- .../Plugins/BuilderModes/Interface/FindReplaceForm.cs | 8 ++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Source/Plugins/BuilderModes/ClassicModes/FindReplaceMode.cs b/Source/Plugins/BuilderModes/ClassicModes/FindReplaceMode.cs index d65e31f9..5914aaf2 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/FindReplaceMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/FindReplaceMode.cs @@ -89,10 +89,13 @@ namespace CodeImp.DoomBuilder.BuilderModes // Select linedefs by sectors foreach(Linedef ld in General.Map.Map.Linedefs) { - bool front, back; - if(ld.Front != null) front = ld.Front.Sector.Selected; else front = false; - if(ld.Back != null) back = ld.Back.Sector.Selected; else back = false; - ld.Selected = front | back; + if (ld.Selected == false) + { + bool front, back; + if (ld.Front != null) front = ld.Front.Sector.Selected; else front = false; + if (ld.Back != null) back = ld.Back.Sector.Selected; else back = false; + ld.Selected = front | back; + } } // Show toolbox window diff --git a/Source/Plugins/BuilderModes/Interface/FindReplaceForm.cs b/Source/Plugins/BuilderModes/Interface/FindReplaceForm.cs index 93a42dae..2a03356c 100644 --- a/Source/Plugins/BuilderModes/Interface/FindReplaceForm.cs +++ b/Source/Plugins/BuilderModes/Interface/FindReplaceForm.cs @@ -169,8 +169,16 @@ namespace CodeImp.DoomBuilder.BuilderModes // Perform the search / replace and show the results if(doreplace.Checked) { + int ticket = General.Map.UndoRedo.CreateUndo("Replace " + searchtypes.SelectedItem); + resultslist.Items.AddRange(finder.Find(findinput.Text, withinselection.Checked, replaceinput.Text, false)); resultscount.Text = resultslist.Items.Count + " items found and replaced."; + + // Withdraw the undo step if nothing was replaced + if (resultslist.Items.Count <= 0) + { + General.Map.UndoRedo.WithdrawUndo(ticket); + } } else {