-
Notifications
You must be signed in to change notification settings - Fork 752
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
Add support for escape() vim function #1038
Conversation
// Test consecutive characters that need escaping | ||
typeText(commandToKeys("""echo escape('$$$$', '$')""")) | ||
assertExOutput("""\$\$\$\$""") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to extract this to a separate test class, perhaps under a builtin
folder, so we can have separate files for each function, and allow splitting the test into more logical tests/asserts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably worth adding a couple of tests for invalid method calls - too many parameters, not enough parameters, what happens with invalid data types, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@citizenmatt I've added a couple of tests with errors.
I also agree that it'd be nice to separate these buitlin functions out to separate class, but maybe this should be done in bulk in a separate PR?
Thank you for your PR! Can you please take a look and write a test on how this would work with multicharacter symbols like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the comments
I've improved the implementation to support unicodes, emojis, etc. and added multiple other tests. However, maybe this is overachieving? For example, standard vim appears to ignore escaping of emojis: Standard vim: :echo escape("😀🎉✨", "😀✨")
😀🎉✨ This implementation: typeText(commandToKeys("""echo escape("😀🎉✨", "😀✨")"""))
assertExOutput("\\😀🎉\\✨") Let me know if you're ok with this or if you'd like to scale back to the standard behavior. |
Oh, sorry, I didn't mean THAT accurate :D |
Note: I closed & reopened the PR by accident |
e36e2ee
to
ba47cf4
Compare
@AlexPl292 I've reverted to my original, simpler implementation. I also added some tests for unicode, and verified that the results are the same in standard Vim. |
Great, thank you! |
No description provided.