Merge pull request #316 from AvaloniaUI/fix-is-replace-mode

Fix is replace mode
This commit is contained in:
Daniel Peñalba 2023-03-06 17:49:19 +01:00 коммит произвёл GitHub
Родитель ae083624ad f5a885adf2
Коммит d9469b653c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 9 добавлений и 15 удалений

Просмотреть файл

@ -110,17 +110,6 @@ namespace AvaloniaEdit.Search
public static readonly StyledProperty<bool> IsReplaceModeProperty =
AvaloniaProperty.Register<SearchPanel, bool>(nameof(IsReplaceMode));
/// <summary>
/// Checks if replacemode is allowed
/// </summary>
/// <returns>False if editor is not null and readonly</returns>
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);

Просмотреть файл

@ -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<bool>();
editor.TextArea.ReadOnlySectionProvider = isReadonly ?
ReadOnlySectionDocument.Instance :
NoReadOnlySections.Instance;
if (editor.SearchPanel != null)
editor.SearchPanel.IsReplaceMode = isReadonly ?
false : editor.SearchPanel.IsReplaceMode;
}
}
#endregion