Skip to content
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

Auto-Escape String Delimiters in String Literals #5009

Open
retailcoder opened this issue Jun 14, 2019 · 3 comments
Open

Auto-Escape String Delimiters in String Literals #5009

retailcoder opened this issue Jun 14, 2019 · 3 comments
Labels
enhancement Feature requests, or enhancements to existing features. Ideas. Anything within the project's scope. feature-autocomplete feature-self-closing-pairs AC issues specific to the handling of self-closing pairs

Comments

@retailcoder
Copy link
Member

Justification
SCP is currently bailing out when it determines that the caret is inside a string literal. There's an opportunity to handle double-quote escaping here - something that is still very frequently being asked about on SO.

Description
Instead of bailing out, handle " keypress inside a string literal by doubling the character and placing the caret after the escaped quotes:

MsgBox "foo|bar" ~> MsgBox "foo""|bar"

One consideration is the closing character - SCP behavior needs to remain consistent, so if the caret is just before the string-closing quote, auto-escape should not happen (i.e. preserve current behavior):

MsgBox "foobar|" ~> MsgBox "foobar"|

Adding escaped double-quotes at the end of a string literal would need to be done by adding a temporary space, that can then be removed:

MsgBox "foobar| " ~> MsgBox "foobar"" "
@retailcoder retailcoder added enhancement Feature requests, or enhancements to existing features. Ideas. Anything within the project's scope. feature-autocomplete feature-self-closing-pairs AC issues specific to the handling of self-closing pairs labels Jun 14, 2019
@Vogel612
Copy link
Member

Suggestion: instead of the temporary space workaround, why not have the following behaviour?

MsgBox "foobar|" ~> MsgBox "foobar"| ~> MsgBox "foobar""|"

This seems a bit more intuitive.

@retailcoder
Copy link
Member Author

@Vogel612 first to second is the current behavior; first to third would be the new one? I don't think second to third is intuitive at all (caret moving back?)... or I'm misreading the example?

@retailcoder
Copy link
Member Author

Yeah I misread it: I think we'd get MsgBox "foobar"| ~> MsgBox "foobar""|" for free, without any changes to the current logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests, or enhancements to existing features. Ideas. Anything within the project's scope. feature-autocomplete feature-self-closing-pairs AC issues specific to the handling of self-closing pairs
Projects
None yet
Development

No branches or pull requests

2 participants