diff --git a/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs b/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs index fcdda52c..665256de 100644 --- a/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs +++ b/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs @@ -279,7 +279,7 @@ static void CanDelete(object target, CanExecuteRoutedEventArgs args) // HasSomethingSelected for delete command TextArea textArea = GetTextArea(target); if (textArea != null && textArea.Document != null) { - args.CanExecute = !textArea.Selection.IsEmpty; + args.CanExecute = !textArea.Selection.IsEmpty && textArea.ReadOnlySectionProvider.CanInsert(textArea.Caret.Offset); args.Handled = true; } } @@ -291,7 +291,7 @@ static void CanCutOrCopy(object target, CanExecuteRoutedEventArgs args) // HasSomethingSelected for copy and cut commands TextArea textArea = GetTextArea(target); if (textArea != null && textArea.Document != null) { - args.CanExecute = textArea.Options.CutCopyWholeLine || !textArea.Selection.IsEmpty; + args.CanExecute = (textArea.Options.CutCopyWholeLine || !textArea.Selection.IsEmpty) && (args.Command != ApplicationCommands.Cut || textArea.ReadOnlySectionProvider.CanInsert(textArea.Caret.Offset)); args.Handled = true; } }