Unexpected Behavior with AutoCaseCorrection

SyntaxEditor for Windows Forms Forum

Posted 19 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
I'm currently working on a project to use SyntaxEditor with a VBScript language. I have AutoCaseCorrection enabled so that my VBScript keywords are shown in the standard case.

I've implemented XML-style comments for my functions, subs, properties, and classes to later build documentation. When the user is entering XML comments and presses the Enter key, I'm automatically indenting the line to the appropriate tab stop and inserting the leading XML Comment Indicator characters in front of the new line (just like Visual Studio does). I've been handling this through the TextChanged event where Modification.Type == DocumentModificationType.Enter. Basically, everything works great as far as getting the effect I want.

Here's the problem. If the user presses return in the middle of a line, the text after the caret position when the user pressed return will be moved to the next line. At this point, the XML Comment Indicator characters are not on this new line so all the tokens are seen as IdentifierTokens. As part of the change, the line is also processed for case correction so all the words in my comments (like "for", "in", etc) are case-corrected (to "For", "In", etc.) because they're now in a different pattern group. This happens before the TextChanged event is fired and I have the chance to prepend this new line with the XML Comment Indicator characters.

In other words, my XMLCommentDefaultTokens are becoming IdentifierTokens just long enough for AutoCaseCorrection to be applied. Since the event is fired after the change, I'm not able to prevent this from happening.

I can't remember if you were planning a 'BeforeTextChanged' event for version 3.0 or not, but I think it would solve my scenario.

If the 'BeforeTextChanged' event is fired and indicates the DocumentModificationType, I'd need to either modify/cancel the "modification" that was about to take place OR insert text before/after the modification (or perhaps a combination of these).

Let me know if this doesn't make any sense <IMG SRC="biggrin.gif" border="0">

Comments (2)

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
There is a TextChanging event right now. Although it can't be cancelled.

We do plan on enhancing this for 3.0.

Actipro Software Support

Posted 19 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Great. Keep this scenario in mind when you're thinking about the new version. Thanks!
The latest build of this product (v24.1.0) was released 4 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.