-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Probably bug in any word hint demo #6653
Comments
Do you have an example where it behaves incorrectly? |
Sorry I was not testing your code maybe it magically work but you can see the same code in my project: https://codepen.io/jcubic/pen/abpqXvO?editors=0010 If you type |
Maybe it just need a comment that explain what the while loop do, if it suppose to match only one letter. |
|
But demo have https://github.com/codemirror/CodeMirror/blob/master/demo/anywordhint.html#L32 |
Ah, that's just filler content for the editor, which appears to contain an old implementation of the addon. Attached patch updates it to the current code. |
I was just writing hint in my code based on any anywordhint.html and it seem that the code is not correct. The regex using global flag and according to MDN test function change lastIndex of the regex test function. I'm not 100% sure if the implementation have bug, but in my code that use almost the same while loop it matched only first character of the word because lastIndex on next call was 1 and it din't much for second character. So the start while loop ended after first iteration. To fix this just remove
g
flag from the regex.TL;DR here is the bug:
The text was updated successfully, but these errors were encountered: