Squiggle tags + quick info provider in specific situation

SyntaxEditor for WPF Forum

Posted 7 years ago by Evgeny
Version: 13.1.0583
Avatar

I have implemented custom tagger, inheriting from TaggerBase<ISquiggleTag>. It performs relatively heavy work (spell check of the whole text range passed in, usually it's a sentence or paragrahp), so instead of doing that inside tagger directly, I first check if I have a cached set of tags for given text range. If not - I perform work asynchronously and return no tags for this range. When asynchronous work is done (I calculated tags for given range) - I call OnTagsChanged for this range, so GetTags are called again, but this time I certainly have text range in cache. All this works fine (or at least it looks like it).

Next I want to show quick info for those squiggle tags. I add default SquiggleTagQuickInfoProvider, but it does not work, because it calls GetTags with text range of length 0 (so, with empty text range). So suppose I have text "one two three" and pointing my mouse to letter "t" in word "two". Then SquiggleTagQuickInfoProvider will call GetTags with text range with offset 4 and length 0.

My questions are:

1. Is it reasonable to implement asynchronous GetTags the way I did, or there are better ways?

2. How can I get information about which tags are related to the given offset in text range? My GetTags calculate tags for the whole sentences\parahraphs and I cannot recalculate them for given position (offset). I need this info for quick info provider and also to display some information when user right-clicks something in the view (so, for context menu). So if I see my squiggle tags in view - I assume there is some way to get some kind of reference to them given offset. Alternatively, I can cache my tags myself in the tagger itself. But then - how can I remove items from that cache? So, how would I know if given tag\range are no longer used by the view.

[Modified 7 years ago]

Comments (1)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Yes I believe what you are doing is ok.

We do pass a single offset for the range with quick info because it's meant to query what is at that specific offset.  I'm not sure about your particular scenario but in general, tagged ranges are offset ranges that are tied to a certain snapshot version.  Thus as long as that tagged range is in the same version (or translated to the same version as the requested offset's snapshot), they can be compared.  For instance if you had three tags on your line "one two three" where you had tagged each word, you'd see the first tag was range 0-3 and didn't contain offset 4.  Then you'd see range 4-7 does contain offset 4 (since 4, 5, and 6 are considered contained) and thus would know that is a valid result.  The final tag for "three" is past offset 4 too.

Now to get the actual squiggle tagged ranges, you would create a tag aggregator (like var tagAggregator = view.CreateTagAggregator<ISquiggleTag>()) then call tagAggregator.GetTags to get all the tags that intersect with the passed snapshot range.  That's what we do in the quick info provider.  We look for squiggle tags at that offset using this logic, and see if a located tag has a ContentProvider.  If so, we use it to get the quick info content.

Hope that helps!


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.