Hi James,
We've had some other customers ask this too, so we're going to modify the Adornments Squiggles Intro QuickStart for the next maintenance release. If you want to change it now, you can do these steps:
First, in CustomSquiggleTagger, change it to inherit CollectionTagger<ISquiggleTag> instead and remove the existing GetTags method.
Second, add this service registration to CustomSyntaxLanguage so quick info can show for the tags:
// Register a squiggle tag quick info provider
this.RegisterService(new SquiggleTagQuickInfoProvider());
Finally, add some code-behind to MainControl.xaml and add a constructor call to this new method after InitializeComponent:
/// <summary>
/// Rescan the document and look for instances of the word 'Actipro' to mark with squiggle tags.
/// </summary>
private void RefreshSquiggleTags() {
// Get the tagger that was created by the language and has been persisted in the document's properties
// while the language is active on the document
CustomSquiggleTagger tagger = null;
if (editor.Document.Properties.TryGetValue(typeof(CustomSquiggleTagger), out tagger)) {
using (var batch = tagger.CreateBatch()) {
// Clear existing tags
tagger.Clear();
// Look for regex pattern matches
var snapshot = editor.ActiveView.CurrentSnapshot;
var matches = Regex.Matches(snapshot.GetText(LineTerminator.Newline), @"\bActipro\b", RegexOptions.IgnoreCase);
for (var matchIndex = 0; matchIndex < matches.Count; matchIndex++) {
var match = matches[matchIndex];
// Create a version range for the match
var snapshotRange = new TextSnapshotRange(snapshot, TextRange.FromSpan(match.Index, match.Length));
var versionRange = snapshotRange.ToVersionRange(TextRangeTrackingModes.DeleteWhenZeroLength);
// Create a tag, and include a quick info tip if specified
var tag = new SquiggleTag();
tag.ClassificationType = ClassificationTypes.Warning;
tag.ContentProvider = new PlainTextContentProvider(String.Format("Instance number {0}", matchIndex + 1));
// Add the tag to the tagger
tagger.Add(new TagVersionRange<ISquiggleTag>(versionRange, tag));
}
}
}
}
After that, you should be able to open the sample and still see the text Actipro marked with squiggles. Mouse hover over the squiggles to see related quick info.
In a production app, you wouldn't generally want to get the full snapshot text like we do here since that can affect performance if done for a large document in the UI thread. But you can see in this example how any collection of text ranges (like those from some some external error scan) can be tagged with squiggles.