/// <summary>
        /// Given a <see cref="StructureTag"/>, creates an ITextBuffer with the content to display
        /// in the tooltip.
        /// </summary>
        protected ITextBuffer CreateElisionBufferForTagTooltip(StructureTag tag)
        {
            // Remove any starting whitespace.
            var span = TrimLeadingWhitespace(new SnapshotSpan(tag.Snapshot, tag.CollapsedHintFormSpan));

            // Trim the length if it's too long.
            var shortSpan = span;

            if (span.Length > MaxPreviewText)
            {
                shortSpan = ComputeShortSpan(span);
            }

            // Create an elision buffer for that span, also trimming the
            // leading whitespace.
            var elisionBuffer = CreateElisionBufferWithoutIndentation(shortSpan);
            var finalBuffer   = elisionBuffer;

            // If we trimmed the length, then make a projection buffer that
            // has the above elision buffer and follows it with "..."
            if (span.Length != shortSpan.Length)
            {
                finalBuffer = CreateTrimmedProjectionBuffer(elisionBuffer);
            }

            return(finalBuffer);
        }
Ejemplo n.º 2
0
 internal override object?GetCollapsedHintForm(StructureTag structureTag)
 {
     return(new ViewHostingControl(
                CreateElisionBufferView,
                () => CreateElisionBufferForTagTooltip(structureTag)
                ));
 }
        private void ProcessSpans(
            TaggerContext <IStructureTag> context,
            SnapshotSpan snapshotSpan,
            BlockStructureService outliningService,
            ImmutableArray <BlockSpan> spans)
        {
            var snapshot = snapshotSpan.Snapshot;

            spans = GetMultiLineRegions(outliningService, spans, snapshot);

            foreach (var span in spans)
            {
                var tag = new StructureTag(this, span, snapshot);
                context.AddTag(new TagSpan <IStructureTag>(span.TextSpan.ToSnapshotSpan(snapshot), tag));
            }
        }
 internal abstract object?GetCollapsedHintForm(StructureTag structureTag);
Ejemplo n.º 5
0
 internal override object?GetCollapsedHintForm(StructureTag structureTag)
 {
     return(CreateElisionBufferForTagTooltip(structureTag).CurrentSnapshot.GetText());
 }