public RestoreCaretAndSelectionUndoAction(TextEditor editor) { textAreaReference = new WeakReference(editor); // Just save the old caret position, no need to validate here. // If we restore it, we'll validate it anyways. caretPosition = editor.CaretIndex; selectionStart = editor.SelectionStart; selectionEnd = editor.SelectionEnd; }