pawelgrzybek / snippet-generator

Snippet generator for Visual Studio Code, Sublime Text and Atom
https://snippet-generator.app/
1.74k stars 202 forks source link

Escape dollar sign #3

Closed jakob-fuchs closed 6 years ago

jakob-fuchs commented 7 years ago

It would be a nice addition if the dollar sign ($) could be escaped automatically. This is necessary for sublime text when it is used in the actual code snippet.

\$test = 'string'

Instead of:

$test = 'string'
pawelgrzybek commented 7 years ago

Thank you for reporting an issue. Really good point! I just need to work out the regex with correct negative lookahead and I'll amend the logic for ST snippets.

jakob-fuchs commented 7 years ago

Thanks for adding this, but this introduced another problem.

$test = "test";

Will be converted to:

\$test= "test";

It looks like any character directly following the escaped token will be removed.

jakob-fuchs commented 7 years ago

Sorry to bother you again, I found another related problem.

$this->someMethod()

Gets converted to

\$this>someMethod()
pawelgrzybek commented 7 years ago

Uuuuups :)

srikat commented 6 years ago

I see that two slashes are needed to escape the $ sign.

Like this:

\\$

pawelgrzybek commented 6 years ago

I tried to review and find an issue. At this moment it works like this…

$test = 'test' -> \$test = 'test' $this->someMethod() -> \$this->someMethod()

In my opinion the current version of regex covers majority of situation. if you can help me to find some addition edge cases please list below. For the time being I'm closing the issue.