Browse Source

Add setter to TextDocument.UndoStack.

pull/14/head
Daniel Grunwald 15 years ago
parent
commit
5205d52d1f
  1. 12
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs
  2. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Deque.cs

12
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs

@ -722,13 +722,23 @@ namespace ICSharpCode.AvalonEdit.Document @@ -722,13 +722,23 @@ namespace ICSharpCode.AvalonEdit.Document
}
}
readonly UndoStack undoStack;
UndoStack undoStack;
/// <summary>
/// Gets the <see cref="UndoStack"/> of the document.
/// </summary>
/// <remarks>This property can also be used to set the undo stack, e.g. for sharing a common undo stack between multiple documents.</remarks>
public UndoStack UndoStack {
get { return undoStack; }
set {
if (value == null)
throw new ArgumentNullException();
if (value != undoStack) {
undoStack.ClearAll(); // first clear old undo stack, so that it can't be used to perform unexpected changes on this document
// ClearAll() will also throw an exception when it's not safe to replace the undo stack (e.g. update is currently in progress)
undoStack = value;
}
}
}
/// <summary>

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Deque.cs

@ -12,7 +12,7 @@ namespace ICSharpCode.AvalonEdit.Utils @@ -12,7 +12,7 @@ namespace ICSharpCode.AvalonEdit.Utils
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
[Serializable]
public class Deque<T> : ICollection<T>
public sealed class Deque<T> : ICollection<T>
{
T[] arr = Empty<T>.Array;
int size, head, tail;

Loading…
Cancel
Save