Cannot figure out intra-line adornment problem.

SyntaxEditor for WPF Forum

The latest build of this product (v2019.1 build 0684) was released 1 month ago, which was before this thread was created.
Posted 13 days ago by Peter Yurkosky
Version: 19.1.0684
Platform: .NET 4.8
Environment: Windows 10 (64-bit)

I use SyntaxEditor for a SQL editor that we offer in our application. I use adornments to show a custom, inline editor for certain special variable types, directly underneath the variable name in the code. I used to use "intra-text" adornments, because they were all that were available when I wrote the functionality. But these broke badly when I moved to verson 2019. It was difficult to figure out why, but instead of fixing it, I moved to "intra-line" adornments because they seemed to fit my requirements better anyway.

These work fine - usually. I've got a CollectionTagger that I add tags to, whenever a user clicks a small button that appears next to the variable name. Sometimes, though, when I edit code ahead of the variable, the TagVersionRange that I've stored in my tagger does not seem to 'adjust' correctly to the edits. I know this because when I click the little button to show my adornment, my GetTags override returns nothing, because the updated snapshot ranges don't intersect my tag. It's like it's been "left behind" somehow. Here's how I create my TagVersionRange, when the user clicks the little variable button to bring up the editor:

var snapshotRange = new TextSnapshotRange(_syntaxEditor.Document.CurrentSnapshot, tokenTuple.Item3.TextRange);
tagger.Add(snapshotRange, tag);

Does all this sound right? Do you have a sample that combines a CollectionTagger with an intra-line adornment? I've read the CodeLens sample, but it seems different enough from my case, that I can't get useful wisdom from it. I can't figure out what I'm doing wrong.

[Modified 13 days ago]

Comments (3)

Posted 13 days ago by Actipro Software Support - Cleveland, OH, USA

Hi Peter,

We don't have a sample for intra-line adornments that use a CollectionTagger.  It sounds like the CodeLens one would be closest to what you're trying to do.  Perhaps make a new sample project that clones that sample but change the tagger to be a CollectionTagger instead and reproduce the problem in that sample project.  Then send it (with the bin/obj folders excluded) in a ZIP to our support address and reference this thread.  Also rename the .zip file extension to help prevent it from being spam blocked.  We'll debug it and will have a look to see what's going on.

Actipro Software Support

Posted 9 days ago by Peter Yurkosky

Thanks for responding.

I wish your suggestion would work, but the CodeLens example is different enough that I can't adapt it to my purposes. I don't even know if my use of the CollectionTagger is really the problem.

This is a hail-mary, but maybe it will help: here's what I see in the debugger when I reproduce a simple version of the problem. I add a newline in front of my variable name, and then delete that newline.

  1. Before any edits, if I click the variable button: Tag is added to Tagger at 248-262, version 2. GetTags returns it as intersecting 240-263, version 2, AddAdornment called for line at range 240-263. This is fine.
  2. Add a newline before our variable name.
  3. Click the button again. Tag is added to Tagger at 252-266, version 3. GetTags returns it as intersecting 244-267, version 3, AddAdornment called for an ITextViewLine at range 244-267. This seems fine, too: my variable's range was advanced by 4 characters (a newline and three tabs, I think)
  4. Hit undo (the newline goes away).
  5. Click the button: Tag is added to Tagger at 252-266, version 4. GetTags returns it as intersecting 240-263, version 4, AddAdornment not called at all. This is weird. Why, when I hit "undo" did the text range associated with my variable not seem to update?

I'm really just looking for ideas here. I've spent several days on this problem now, and I'm not making progress, just kind of blindly stabbing at different solutions, hoping they'll work.

Posted 8 days ago by Actipro Software Support - Cleveland, OH, USA

Hi Peter,

I would expect undo edits to follow through with the same tagging/adornment sequence in general since they are text changes themselves.

It's hard for us to say what's happening without being able to debug a simple example showing it.  Per our previous reply, it would be most time efficient if you can send us a sample that we can work with to see the issue.  Then we can report back where things may be going wrong and can make any required code changes if some are needed.

Actipro Software Support

Add Comment

Please log in to a validated account to post comments.