Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.vs

# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
[Bb]in/
[Oo]bj/
Expand Down Expand Up @@ -59,7 +61,7 @@ _ReSharper*
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
# Installshield output folder
[Ee]xpress

# DocProject is a documentation generator add-in
Expand Down
15 changes: 12 additions & 3 deletions FindReplace/FindReplace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,16 @@ public Window OwnerWindow
public static readonly DependencyProperty OwnerWindowProperty =
DependencyProperty.Register("OwnerWindow", typeof(Window), typeof(FindReplaceMgr), new UIPropertyMetadata(null));


/// <summary>
/// Determines whether to display the confirmation Prompt when pressing replace all
/// </summary>
public bool ShowReplaceAllConfirmationPrompt
{
get { return (bool)GetValue(ShowReplaceAllConfirmationPromptProperty); }
set { SetValue(ShowReplaceAllConfirmationPromptProperty, value); }
}
public static readonly DependencyProperty ShowReplaceAllConfirmationPromptProperty =
DependencyProperty.Register("ShowReplaceAllPrompt", typeof(bool), typeof(FindReplaceMgr), new UIPropertyMetadata(true));

#endregion

Expand Down Expand Up @@ -274,12 +283,12 @@ public Regex GetRegEx(bool ForceLeftToRight = false)
return r;
}

public void ReplaceAll(bool AskBefore = true)
public void ReplaceAll()
{
IEditor CE = GetCurrentEditor();
if (CE == null) return;

if (!AskBefore || MessageBox.Show("Do you really want to replace all occurences of '" + TextToFind + "' with '" + ReplacementText + "'?",
if (!ShowReplaceAllConfirmationPrompt || MessageBox.Show("Do you really want to replace all occurences of '" + TextToFind + "' with '" + ReplacementText + "'?",
"Replace all", MessageBoxButton.YesNoCancel, MessageBoxImage.Exclamation) == MessageBoxResult.Yes)
{
object InitialEditor = CurrentEditor;
Expand Down
9 changes: 6 additions & 3 deletions FindReplaceUnitTests/FindReplaceVMTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,15 @@ public void ReplaceAllTest()
bool AskBefore = false;

// test basic replacement
target.ReplaceAll(AskBefore);
target.ShowReplaceAllConfirmationPrompt = AskBefore;
target.ReplaceAll();
Assert.AreEqual(Editors[0].Text, @"Hallo 1 bla bla Hallo2 Hallo 3. xxx test tesssst");

// test wrapping through all open files
target.SearchIn = FindReplaceMgr.SearchScope.AllDocuments;
target.TextToFind = "bla";
target.ReplaceAll(AskBefore);
target.ShowReplaceAllConfirmationPrompt = AskBefore;
target.ReplaceAll();
Assert.AreEqual(Editors[2].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. Testen testen test tesssst");
Assert.AreEqual(Editors[1].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. Testen testen test tesssst");
Assert.AreEqual(Editors[0].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. xxx test tesssst");
Expand All @@ -197,7 +199,8 @@ public void ReplaceAllTest()
target.UseWildcards = true;
target.CaseSensitive = true;
target.TextToFind = "tes*st";
target.ReplaceAll(AskBefore);
target.ShowReplaceAllConfirmationPrompt = AskBefore;
target.ReplaceAll();
Assert.AreEqual(Editors[2].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. Testen xxx");
Assert.AreEqual(Editors[1].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. Testen xxx");
Assert.AreEqual(Editors[0].Text, @"Hallo 1 xxx xxx Hallo2 Hallo 3. xxx xxx");
Expand Down