Exemplo n.º 1
0
        public void TextRangeCollection_ReflectTextChangeTest1()
        {
            TextRangeCollection <TextRange> target = MakeCollection();

            target.ReflectTextChange(0, 0, 1);
            AssertEquals(target, 2, 3, 4, 6, 6, 8);

            target.ReflectTextChange(0, 1, 0);
            AssertEquals(target, 1, 2, 3, 5, 5, 7);

            target.Start.Should().Be(1);
            target.End.Should().Be(7);
        }
Exemplo n.º 2
0
        public void TextRangeCollection_ReflectTextChangeTest3()
        {
            TextRangeCollection <TextRange> target = MakeCollection();

            target.ReflectTextChange(3, 1, 4);
            AssertEquals(target, 1, 2, 3, 8, 8, 10);

            target.ReflectTextChange(0, 15, 20);
            AssertEquals(target);

            target.Count.Should().Be(0);
            target.Start.Should().Be(0);
            target.End.Should().Be(0);
        }
Exemplo n.º 3
0
        public void ReflectTextChange(int start, int oldLength, int newLength, bool trivialChange)
        {
            lock (_lockObj) {
                // Remove items first. This is different from default ReflectTextChange
                // implementation since ReflectTextChange does not remove item
                // that fully contains the change and rather expands it. We don't
                // want this behavior since changed elementneeds to be revalidated
                // and hence expanding squiggle does not make sense.
                ICollection <EditorErrorTag> removed = null;
                if (!trivialChange)
                {
                    removed = _tags.RemoveInRange(new TextRange(start, oldLength), true);
                }

                _tags.ReflectTextChange(start, oldLength, newLength);

                if (!trivialChange)
                {
                    foreach (var tag in removed)
                    {
                        RemovedTags.Enqueue(tag);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void TextRangeCollection_ReflectTextChangeTest2()
        {
            TextRangeCollection <TextRange> target = MakeCollection();

            target.ReflectTextChange(3, 0, 3);
            AssertEquals(target, 1, 2, 6, 8, 8, 10);

            target.ReflectTextChange(8, 1, 0);
            AssertEquals(target, 1, 2, 6, 8, 8, 9);

            target.ReflectTextChange(8, 1, 0);
            AssertEquals(target, 1, 2, 6, 8);

            target.ReflectTextChange(7, 1, 0);
            AssertEquals(target, 1, 2, 6, 7);

            target.Start.Should().Be(1);
            target.End.Should().Be(7);
        }