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

Characters after " orange in StringReplace #262

Open
Martin-Milbradt opened this issue Nov 5, 2022 · 6 comments
Open

Characters after " orange in StringReplace #262

Martin-Milbradt opened this issue Nov 5, 2022 · 6 comments
Assignees
Labels
bug something isn't working syntax highlighter syntax highlighter (code coloring) issues

Comments

@Martin-Milbradt
Copy link

Code snippet

StringReplace, Clipboard, Clipboard, ", , All

Expected behavior

Characters after " should have the usual color in StringReplace.

Editor tokens and scopes

"1 char
language ahk
standard token type String
foreground #CE9178
background #1E1E1E
contrast ratio 6.31
textmate scopes punctuation.definition.string.begin.ahk
string.quoted.double.ahk
source.ahk
foreground string
{ "foreground": "#CE9178" }

Additional context

" does not start a string in this case but is a character to be replaced.

image

@fade2gray
Copy link

Incorrect syntax used; the single double-quote needs to be escaped as """".

i.e. StringReplace, Clipboard, Clipboard, """", , All

...but, StringReplace has been deprecated, and you should be using StrReplace

i.e. Clipboard := StrReplace(Clipboard, """")

@mark-wiemer
Copy link
Member

@fade2gray, when you say the syntax is incorrect, are you implying the code won't compile or work at all?

@fade2gray
Copy link

No, maybe I used the wrong terminology.

I was just trying to show that the replacement string in the given snippet is incorrectly formatted, and the resulting syntax highlighting gives you a clue that something's amiss.

Capture4

@kyklish
Copy link
Contributor

kyklish commented Nov 6, 2022

No, maybe I used the wrong terminology.

I was just trying to show that the replacement string in the given snippet is incorrectly formatted, and the resulting syntax highlighting gives you a clue that something's amiss.

Capture4

No, it's correctly formatted. Inside commands AHK uses Legacy text, not "Expression text"!
StringReplace, Clipboard, Clipboard, ", , All <-- correct default syntax
StringReplace, Clipboard, Clipboard, % """", , All <-- correct expression syntax (% sign force to use "Expression text")

@fade2gray
Copy link

Yep, my bad.

@kyklish
Copy link
Contributor

kyklish commented Nov 18, 2022

Yep, my bad.

My bad too, I edited my comment above.

Within an expression, two consecutive quotes enclosed inside a literal string resolve to a single literal quote.
For example: Var := "The color ""red"" was found.".

@mark-wiemer mark-wiemer added the formatter code formatter issues label Dec 3, 2022
@mark-wiemer mark-wiemer moved this to Todo in AHK++ Aug 18, 2024
@mark-wiemer mark-wiemer added syntax highlighter syntax highlighter (code coloring) issues and removed formatter code formatter issues labels Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something isn't working syntax highlighter syntax highlighter (code coloring) issues
Projects
Status: Todo
Development

No branches or pull requests

4 participants