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); }
/// <summary> /// Starts tracking the specified regions as tab stops. /// </summary> /// <param name="tabStops">The tab stops array with start and end positions.</param> /// <param name="tabStopGroups">Tab stops groups indexes array.</param> public void TrackTabStops(Range[] tabStops, int[] tabStopGroups) { if (null == tabStops || 0 == tabStops.Length) { return; } Span[] tabStopSpans = new Span[tabStops.Length]; for (int index = 0; index < tabStops.Length; index++) { Range source = tabStops[index]; tabStopSpans[index] = new Span(source.Start, source.End - source.Start); } CodeSnippet.CreateSnippetInView( new ViewContext(_wpfView, _textView), tabStopSpans, tabStopGroups); }