YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
15 stars 7 forks source link

Use `$` in code snippets #5466

Open backYard321 opened 3 months ago

backYard321 commented 3 months ago

Is your feature request related to a problem?

Currently, if a code snippet includes $, GM reads that as a line break. However, there are cases where snippets NEED to include the actual dollar sign character $ (EG: struct accessors [$""] or template strings $"{}").

As of now, there's no way to incorporate $ into a code snippet, so creating these is impossible.

Describe the solution you'd like

Interpreting $$ as an actual dollar sign (since multiple line breaks must be separated with a space) would be a straightforward way to handle this on the user end, and would hold us over until user-defined snippets are implemented in Code Editor 2.

Describe alternatives you've considered

There are no ways to do this in snippets otherwise.

thennothinghappened commented 3 months ago

I've actually never used snippets before so can't really comment on how they work, but in my experience any time the solution to "we're using a special character to indicate line breaks or some special functionality and now we need that character" is "make it so putting multiple of them escapes it" never really works very nicely. (See: the hellscape that is CSV)

In my opinion it's always better to just escape stuff. Go with the standard! If $ means something special, then typing \$ should escape that functionality!

backYard321 commented 3 months ago

Likewise, I'm not familiar for CSV, so I can't really appreciate what you're talking about firsthand. While I'd probably prefer $$, I'm sure an escape character would be fine too (as long as you can escape the escape character). It would also be good to have it for | since that denotes the borders of the text to be highlighted (and replaced by the user).

thennothinghappened commented 3 months ago

\ is the generally used "escape the next character"... character. Using it here would mean that any special symbols you need to type in the snippet itself just need to be prepended with a backslash to escape their functionality. Typing a backslash literally then would be a double backslash if it would otherwise cause a following control character to be escaped.

This is the system GML itself uses in strings, as do most languages - say you wish to type a " but your string is defined by a pair of those. Prepend your " with a backslash and it will be interpreted literally rather than as a special character. Formats like JSON also work this way.

backYard321 commented 3 months ago

Yeah i understand strings and escape characters, my point was that it would also be useful for | to be escape-able, so an escape character would have that added benefit. | | is used in code snippets to bookend replaceable code.