示例#1
0
        private void ReplaceRegion(Span region, string replacement)
        {
            var parser = TabStopsParser.ParseContent(replacement, region.Start);

            WpfView.TextBuffer.Replace(region, parser.Content);
            if (parser.TabStops?.Length > 0)
            {
                CodeSnippet.CreateSnippetInView(this, parser.TabStops);
            }

            FormatRegion(region.Start, region.Start + parser.Content.Length);
        }
        public void ParseContent_GivenContentWithTabStops_RemovesThem()
        {
            // Arrange
            string content = GetSourceFromResource(DataHelper.TabStops);

            // Act
            TabStopsParser parser = TabStopsParser.ParseContent(content);

            // Assert
            string gold   = GetSourceFromResource(DataHelper.TabStopsGold);
            string result = NormalizeWhiteSpace(parser.Content);

            gold.Should().BeEquivalentTo(result);
        }
        public void ParseContent_GivenContentWithTabStops_CalculatesTabStopsPositions()
        {
            // Arrange
            string content = "<div>{placeholder}</div><p>{}</p>";

            // Act
            TabStopsParser parser = TabStopsParser.ParseContent(content);

            // Assert
            parser.TabStops.Length.Should().Be(2);
            parser.TabStops[0].Start.Should().Be(5);
            parser.TabStops[0].Length.Should().Be(11);
            parser.TabStops[1].Start.Should().Be(25);
            parser.TabStops[1].Length.Should().Be(0);
        }