Visual Studio Extension: Change Visible Text of Collapsed Blocks
I am writing Visual Studio Extension to customize my editor. I would like to change the text that is displayed when a block of code is compensated.
I've tried the following code:
ITagAggregator<IntraTextAdornmentTag> aggregator;
[...]
aggregator.BatchedTagsChanged += OnBatchedTagsChanged;
[...]
public void OnBatchedTagsChanged(object sender, BatchedTagsChangedEventArgs e)
{
string newText;
bool textCreated;
NormalizedSnapshotSpanCollection list = new NormalizedSnapshotSpanCollection(e.Spans.SelectMany(x => x.GetSpans(textView.TextBuffer)));
if (list.Count != 0)
{
IEnumerable<IMappingTagSpan<IntraTextAdornmentTag>> tags = aggregator.GetTags(list);
foreach (IMappingTagSpan<IntraTextAdornmentTag> tag in tags)
{
if (tag.Tag.Adornment is OutliningCollapsedAdornmentControl)
{
NormalizedSnapshotSpanCollection spans = tag.Span.GetSpans(textView.TextSnapshot);
if (spans.Count == 0) continue;
OutliningCollapsedAdornmentControl adornmentControl = (OutliningCollapsedAdornmentControl)tag.Tag.Adornment;
TextBlock textBlock = adornmentControl.GetChild<TextBlock>();
textCreated = TryCreateText(spans[0], out newText);
if (textCreated)
{
adornmentControl.Content = newText;
textBlock.Text = newText;
}
}
}
}
}
I change the text, but when it scrolls out of the screen and back, the text reverts to its default.
Edit:
I have also tried passing MSDN .
I work fine if I break the blocks by pressing the "+" sign, but the blocks don't shrink when I use Ctrl + M + O.
I guess the problem is because I am creating pre-existing regions.
Can someone please tell me what can I do?
(Tested in both VS2010 and VS2013 with the same result)
+3
source to share
No one has answered this question yet
Check out similar questions: