/// <summary>
        /// Executes command.
        /// </summary>
        /// <param name="document">Document to run command.</param>
        public void Execute(ITextEditorDocument document)
        {
            if (document == null)
            {
                return;
            }

            this.line = document.LineNumberByIndex(this.caretIndex);
            this.position = document.CaretPositionInLineByIndex(this.caretIndex);
            this.changedDocument = document;

            int endCaretIndex = this.caretIndex + this.length;
            if (endCaretIndex > document.Text.Length)
            {
                endCaretIndex = document.Text.Length;
            }

            int endPosition = document.CaretPositionInLineByIndex(endCaretIndex);
            int endLineIndex = document.LineNumberByIndex(endCaretIndex);
            this.removedLines = document.AllLines.GetRange(this.line, endLineIndex - this.line + 1);

            string paragraph = document.AllLines[this.line];
            string lineToMove = document.AllLines[endLineIndex].Substring(endPosition);
            if (paragraph.Length > this.position)
            {
                paragraph = paragraph.Remove(this.position);
            }

            document.ChangeLineAtIndex(this.line, paragraph + lineToMove);
            document.RemoveLines(this.line + 1, endLineIndex - this.line);
        }