diff --git a/src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchReplaceManager.cs b/src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchReplaceManager.cs index 220b34878b..06dabb4059 100644 --- a/src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchReplaceManager.cs +++ b/src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchReplaceManager.cs @@ -102,11 +102,7 @@ namespace SearchAndReplace public static void MarkAll() { SetSearchOptions(); - TextEditorControl textArea = null; - if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null) { - textArea = ((ITextEditorControlProvider)WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent).TextEditorControl; - textArea.ActiveTextAreaControl.TextArea.SelectionManager.ClearSelection(); - } + ClearSelection(); find.Reset(); if (!find.SearchStrategy.CompilePattern()) return; @@ -190,12 +186,7 @@ namespace SearchAndReplace public static void ReplaceAll() { SetSearchOptions(); - if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null) { - ITextEditorControlProvider provider = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent as ITextEditorControlProvider; - if (provider != null) { - provider.TextEditorControl.ActiveTextAreaControl.TextArea.SelectionManager.ClearSelection(); - } - } + ClearSelection(); find.Reset(); if (!find.SearchStrategy.CompilePattern()) return; @@ -285,7 +276,7 @@ namespace SearchAndReplace return; } - TextEditorControl textArea = null;; + TextEditorControl textArea = null; while (textArea == null) { SearchResult result = find.FindNext(); if (result == null) { @@ -387,5 +378,15 @@ namespace SearchAndReplace } return null; } + + static void ClearSelection() + { + if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null) { + ITextEditorControlProvider provider = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent as ITextEditorControlProvider; + if (provider != null) { + provider.TextEditorControl.ActiveTextAreaControl.TextArea.SelectionManager.ClearSelection(); + } + } + } } }