diff --git a/src/AvaloniaEdit/Search/SearchPanel.cs b/src/AvaloniaEdit/Search/SearchPanel.cs index e92474c..c29c2d4 100644 --- a/src/AvaloniaEdit/Search/SearchPanel.cs +++ b/src/AvaloniaEdit/Search/SearchPanel.cs @@ -110,17 +110,6 @@ namespace AvaloniaEdit.Search public static readonly StyledProperty IsReplaceModeProperty = AvaloniaProperty.Register(nameof(IsReplaceMode)); - - /// - /// Checks if replacemode is allowed - /// - /// False if editor is not null and readonly - private static bool ValidateReplaceMode(SearchPanel panel, bool v1) - { - if (panel._textEditor == null || !v1) return v1; - return !panel._textEditor.IsReadOnly; - } - public bool IsReplaceMode { get => GetValue(IsReplaceModeProperty); diff --git a/src/AvaloniaEdit/TextEditor.cs b/src/AvaloniaEdit/TextEditor.cs index 34cbb98..e1c44f8 100644 --- a/src/AvaloniaEdit/TextEditor.cs +++ b/src/AvaloniaEdit/TextEditor.cs @@ -436,10 +436,15 @@ namespace AvaloniaEdit { if (e.Sender is TextEditor editor) { - if ((bool)e.NewValue) - editor.TextArea.ReadOnlySectionProvider = ReadOnlySectionDocument.Instance; - else - editor.TextArea.ReadOnlySectionProvider = NoReadOnlySections.Instance; + bool isReadonly = e.GetNewValue(); + + editor.TextArea.ReadOnlySectionProvider = isReadonly ? + ReadOnlySectionDocument.Instance : + NoReadOnlySections.Instance; + + if (editor.SearchPanel != null) + editor.SearchPanel.IsReplaceMode = isReadonly ? + false : editor.SearchPanel.IsReplaceMode; } } #endregion