-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
enh(nsis) Update variables pattern #3416
Conversation
Also adding some |
Please add |
@joshgoebel I've committed two simple test cases. However, writing them revealed some bugs I'm not sure how to fix. The following tests will fail because they're in conflict with existing rules: LiteralsVar Custom.Variable
StrCpy $Custom.Variable "Hello World"
MessageBox MB_OK "$$Custom.Variable is: $Custom.Variable" This test will fail since <span class="hljs-keyword">Var</span> <span class="hljs-literal">Custom</span>.Variable<span class="hljs-keyword">StrCpy</span> <span class="hljs-variable">$Custom.Variable</span> <span class="hljs-string">"Hello World"</span>
<span class="hljs-keyword">MessageBox</span> <span class="hljs-params">MB_OK</span> <span class="hljs-string">"<span class="hljs-meta">$$</span>Custom.Variable is: <span class="hljs-variable">$Custom.Variable</span>"</span> NumbersStrCpy $0 "Hello World"
MessageBox MB_OK "$$0 is: $0" Again, this will fail since 0 is detected as a number <span class="hljs-keyword">StrCpy</span> $<span class="hljs-number">0</span> <span class="hljs-string">"Hello World"</span>
<span class="hljs-keyword">MessageBox</span> <span class="hljs-params">MB_OK</span> <span class="hljs-string">"<span class="hljs-meta">$$</span>0 is: $0"</span> These bugs should have existed before this PR was opened. |
I think I fixed your first two issues: For
We can do that with a multi-matcher now: {
match: [
/Var/,
/\s+/,
VARIABLE_NAME_RE
],
scope: { 1: "keyword", 3: "variable" }
} If we wanted to highlight the definition as |
I think that would be awesome
There's an optional parameter for # This can be declared at top-level only
Var MyVariable
# This can be declared at block-level only
Var /GLOBAL MyVariable I don't think that highlight.js currently supports any parameters in the style of Discourse In both cases the variable will be global! When you try to declare a variable with the former syntax at block-level, the compiler will throw an error:
I suspect that block-level variable have been on the TODO list but were never implemented. |
Updates pattern for NSIS variable to allow
.
-characters. The bundled MUI2 header has been making use of this for years.Changes
Allow
.
in variables regex patternChecklist
CHANGES.md