From 3b19b93a846629b03e1f745f621379a3b2666dbe Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 6 Mar 2023 16:07:47 +0100 Subject: [PATCH 1/2] Update SearchPanel.IsReplaceMode when TextEditor.IsReadonly changes --- src/AvaloniaEdit/TextEditor.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 From f5a885adf2f48f05207a5290d83143bc7dc283ca Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 6 Mar 2023 16:08:54 +0100 Subject: [PATCH 2/2] Remove unused method --- src/AvaloniaEdit/Search/SearchPanel.cs | 11 ----------- 1 file changed, 11 deletions(-) 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);