GetVordText Version Difference

SyntaxEditor for WPF Forum

Posted 1 year ago by SPF - Appeon
Version: 22.1.4
Platform: .NET 6.0
Environment: Windows 11 (64-bit)
Avatar

Different versions get different keywords in some cases.

Please run the two projects under the solution and observe the different behaviors.

Project example : https://github.com/spf-oss/Actiprosoft/blob/main/VersionDifference.rar

This problem has a great impact because it has been widely used in our projects.

[Modified 1 year ago]

Comments (3)

Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Thank you for the sample project that clearly shows the different behavior. It appears this change was introduced in v22.1.3 as part of a change to address the behavior you previously posted about.

In your sample you show that calling GetWordText for the offset between the "e" and "." in "Console." returns "." as the word text in v22.1.1 and "Console" as the word text in v22.1.4. The word break finder for "Console." is finding two words ("Console" and ".") and the given offset is positioned equally between both words.

So which word is the current word? The change made in v22.1.3 looks for the more significant character on either side of the offset and returns the word associated with the more signficant character. Technically this change was made to a GetWordTextRange method, but does inadvertently affect GetWordText.

While we believe the current logic is more accurate, we do see how the change has impacted the GetWordText method and should have been delayed until a more significant release.

To help us better understand your scenario, can you explain if you prefer "." to be the current word in this scenario or is the issue simply that the change has negatively impacted application behavior? Perhaps you could provide some specific examples from your application with an explanation on why one word is preferred over another?


Actipro Software Support

Posted 1 year ago by Sunshine - Appeon
Avatar

Is the positioning of the GetWordText method just to get the text?

We use this method to obtain the text at the specified position in the automatic completion grammar service.

For example:

Console.|WriteLine


Our cursor is at the position of offset 8. At this time, we want to get the content "." in front of the cursor to determine whether the auto-complete list needs to pop up.
But currently this method returns "WriteLine" at offset 8 and "Console" at offset 7.

Answer - Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

We are adding an ITextSnapshot.GetWordText method overload for the next maintenance release that accepts an affinity argument.  You will be able to pass TextOffsetAffinity.Far to get the original behavior you want, which always scans forward for a word.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.