How to best implement the CodeLens function of C#?

SyntaxEditor for WPF Forum

Posted 3 years ago by Sunshine - Appeon
Version: 21.1.2
Avatar

I want to implement the CodeLens function of C#. I have tried many ways and the effect is not very satisfactory.

The recommended approach in the case is to implement this function by inheriting IntraLine Adornment ManagerBase. But in this way, any changes on the interface will trigger the redrawing of CodeLens.

This causes the CodeLens in the visible area to be continuously redrawn during the encoding process. When redrawing takes a certain amount of time, the CodeLens in the row will continue to flash.

What is even more troublesome is that I need to update the code coloring during the coding process. The solution we took is to update the IClassificationTag of the current view. This causes the CodeLens of the entire view to be flickering during the coding process.

The Codelen application scenario provided in the case is too simple. Although it keeps redrawing, its CodeLens acquisition is not time-consuming, so it is invisible to the naked eye.

Do you have any good suggestions?

Comments (3)

Posted 3 years ago by Sunshine - Appeon
Avatar

I am currently trying to rewrite the trigger logic of IntraLineAdornmentManagerBase. During this process, I encountered a problem: how to redraw when clicking the code folding button, I did not find the relevant events and judgment methods.

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

Hello,

Do you have a new simple sample project of your own that you could send over that shows the flashing behavior you are seeing?  That would help us see what you are seeing and then we could talk about options on improving the refreshing logic.  Please send that to our support address, reference this thread in your email, and remove the bin/obj folders from the .zip you send so it doesn't get spam blocked.

For the followup question, do you mean you are trying to detect when some code is collapsed?  The editor view's CollapsedRegionManager has a RegionsChanged event that fires in that scenario.  Or if you mean something else, please explain in more detail.  Thanks!


Actipro Software Support

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

Thank you for providing the sample project. We were able to observe the flicker you were describing. The issue is that when the Hyperlink is first added as an adornment, the text is empty. Later, after the task completes to get the reference count, the Hyperlink text is updated. This change in text is what is causing the flicker you described.

Adornments are constantly being removed and added as you modify the text. To avoid the flicker, you will need to limit changes to the Hyperlink text.

A suggested way to accomplish this is to cache data about the reference count for a declaration so that, when you add the adornment with the Hyperlink, you can initialize the Hyperlink text with the previously cached reference count. This will ensure the adornment is added with the most up-to-date information and will only be redrawn if the reference count changes.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.