Example #1
0
            public bool Insert(int position, string text)
            {
                var initialSnapshot = (StringTextSnapshot)_textBuffer.CurrentSnapshot;
                var newText         = initialSnapshot.Content.Insert(position, text);
                var changedSnapshot = new StringTextSnapshot(newText);
                var edit            = new TestEdit(position, 0, initialSnapshot, text.Length, changedSnapshot, text);

                _edits.Add(edit);

                return(true);
            }
            public bool Insert(int position, string text)
            {
                var initialSnapshot      = _editSnapshot;
                var newText              = initialSnapshot.Content.Insert(position, text);
                var initialVersionNumber = initialSnapshot.Version.VersionNumber;
                var changedSnapshot      = new StringTextSnapshot(newText, initialVersionNumber + 1);
                var edit = new TestEdit(position, 0, initialSnapshot, changedSnapshot, text);

                _edits.Add(edit);

                _editSnapshot = changedSnapshot;

                return(true);
            }
Example #3
0
            public bool Replace(int startPosition, int charsToReplace, string replaceWith)
            {
                var initialSnapshot = _editSnapshot;
                var preText         = initialSnapshot.Content.Substring(0, startPosition);
                var postText        = initialSnapshot.Content.Substring(startPosition + charsToReplace);
                var newText         = preText + replaceWith + postText;
                var changedSnapshot = new StringTextSnapshot(newText);
                var edit            = new TestEdit(startPosition, charsToReplace, initialSnapshot, changedSnapshot, replaceWith);

                _edits.Add(edit);

                _editSnapshot = changedSnapshot;

                return(true);
            }
 public TestTextChange(TestEdit edit) : this(edit.Change)
 {
 }
 public void ApplyEdit(TestEdit edit)
 {
     ApplyEdits(edit);
 }