public static IProjectionBuffer CreateProjectionBufferWithoutIndentation()

in src/Sarif.Viewer.VisualStudio.Core/Fixes/ProjectionBufferFactoryServiceExtensions.cs [18:77]


        public static IProjectionBuffer CreateProjectionBufferWithoutIndentation(
            this IProjectionBufferFactoryService projectionBufferFactoryService,
            IEditorOptions editorOptions,
            ITextSnapshot textSnapshot,
            string separator,
            params LineSpan[] exposedLineSpans)
        {
            var spans = new List<object>();
            if (exposedLineSpans.Length > 0)
            {
                if (exposedLineSpans[0].Start > 0 && !string.IsNullOrEmpty(separator))
                {
                    spans.Add(separator);
                    spans.Add(editorOptions.GetNewLineCharacter());
                }

                IList<IList<SnapshotSpan>> snapshotSpanRanges = CreateSnapshotSpanRanges(textSnapshot, exposedLineSpans);
                int indentColumn = DetermineIndentationColumn(editorOptions, snapshotSpanRanges.SelectMany(s => s));

                foreach (IList<SnapshotSpan> snapshotSpanRange in snapshotSpanRanges)
                {
                    foreach (SnapshotSpan snapshotSpan in snapshotSpanRange)
                    {
                        ITextSnapshotLine line = snapshotSpan.Snapshot.GetLineFromPosition(snapshotSpan.Start);
                        int indentPosition = line.GetText().GetLineOffsetFromColumn(indentColumn, editorOptions.GetTabSize()) + line.Start;
                        var mappedSpan = new SnapshotSpan(snapshotSpan.Snapshot, Span.FromBounds(indentPosition, snapshotSpan.End));

                        ITrackingSpan trackingSpan = mappedSpan.Snapshot.CreateTrackingSpan(mappedSpan, SpanTrackingMode.EdgeExclusive);

                        spans.Add(trackingSpan);

                        // Add a newline between every line.
                        if (snapshotSpan != snapshotSpanRange.Last())
                        {
                            spans.Add(editorOptions.GetNewLineCharacter());
                        }
                    }

                    // Add a separator between every set of lines.
                    if (snapshotSpanRange != snapshotSpanRanges.Last())
                    {
                        spans.Add(editorOptions.GetNewLineCharacter());
                        spans.Add(separator);
                        spans.Add(editorOptions.GetNewLineCharacter());
                    }
                }

                if (textSnapshot.GetLineNumberFromPosition(snapshotSpanRanges.Last().Last().End) < textSnapshot.LineCount - 1)
                {
                    spans.Add(editorOptions.GetNewLineCharacter());
                    spans.Add(separator);
                }
            }

            return projectionBufferFactoryService.CreateProjectionBuffer(
                projectionEditResolver: null,
                sourceSpans: spans,
                options: ProjectionBufferOptions.None,
                contentType: textSnapshot.ContentType);
        }