From 441fd154889c8bc0fa9befecdb18539fcbdc3934 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 8 Mar 2011 01:34:46 +0100 Subject: [PATCH] Fixed bug in EditingCommandHandler.Cut that allowed deleting read-only text. --- .../ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs index e5d383273d..15a9e9c37c 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs @@ -300,7 +300,10 @@ namespace ICSharpCode.AvalonEdit.Editing if (textArea.Selection.IsEmpty && textArea.Options.CutCopyWholeLine) { DocumentLine currentLine = textArea.Document.GetLineByNumber(textArea.Caret.Line); CopyWholeLine(textArea, currentLine); - textArea.Document.Remove(currentLine.Offset, currentLine.TotalLength); + ISegment[] segmentsToDelete = textArea.GetDeletableSegments(new SimpleSegment(currentLine.Offset, currentLine.TotalLength)); + for (int i = segmentsToDelete.Length - 1; i >= 0; i--) { + textArea.Document.Remove(segmentsToDelete[i]); + } } else { CopySelectedText(textArea); textArea.RemoveSelectedText();