-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix syntax colouring when inline comments contain multi-byte characters + numerical constants/punctuation #451
Conversation
1fda72c
to
556cf61
Compare
Hi Alexander, |
Hi Sebastian, |
We don't need a separate issue for this. Comments in the PR are fine. |
Do you think you could add some tests that cover this bug+fix? I'm afraid it's too easy to introduce a regression later without a test. |
cd539f4
to
556cf61
Compare
You're right, I've had the same thought that in current state it may be easily reintroduced. P.S. Please sorry me for my mistake: forced-pushed squashed commits to the wrong pull request inadvertently, hope it's fixed now... |
Fix finding the end of the regexp in a multi-byte string and incorrect use of bytesCount instead of the string length in multi-byte characters. In C/C++ grammars the bug is triggered by strings/comments containing multi-byte characters and numeric constants/punctuation. Additional comment: lineTokens.produce() takes length of the string in multi-byte characters as a second parameter and captureIndices of OnigCaptureIndex are also counted as characters (see OnigNextMatchResult.captureIndicesOfMatch()).
556cf61
to
782ea94
Compare
Added some test cases. Have checked they all fail for the current master branch. P.S. I had to add surefire-junit-platform to the top-level pom.xml for internal tests to return. Were they skipped by intention? |
The PR looks good to me. Thanks for adding the test cases. The internal tests were not skipped by intention. Thanks for the fix. |
Sorry, can't comment inline at the moment so shall try to explain it here. |
I removed my inline comments again. All good. Thanks again for the PR. Identifying this issue and fixing it was very good work! |
Thank you much very much for your warm reception! I am very glad I could be of any help to you. |
When you type something like the following code in C/C++:
the syntax colouring of a line below the triggering string will be broken. I've managed to reproduce this behaviour with the latest build of Eclipse Corrosion and the most current TM4E snapshot, you can see it in the animated gif below.
EDIT: Double-checked this today with the provided example: in my case (Eclipse CDT with a small patch to connect the extension point of the generic editor to the TMPresentationReconciler of TM4E) without this fix I also had the following exception:
And so debugging this one had lead me to the LineTokenizer trying to handle the captured token of negative length.