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

[Batch File] Fix comment scope around newlines #3992

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Batch File/Batch File.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ contexts:
comment-body:
- meta_scope: comment.line.colon.dosbatch
- include: line-continuations
- match: \n
- match: $\n?
pop: 1

ignored-tail-inner:
Expand Down Expand Up @@ -843,7 +843,7 @@ contexts:
# meta_content_scope is used since rem should not be
# highlighted as a comment, but a command
- meta_content_scope: comment.line.rem.dosbatch
- match: \n
- match: $\n?
scope: comment.line.rem.dosbatch
pop: 1

Expand Down
95 changes: 81 additions & 14 deletions Batch File/tests/syntax_test_batch_file.bat
Original file line number Diff line number Diff line change
Expand Up @@ -37,63 +37,130 @@
I'm a (com|ment)
:: ^^^^^^^^^^^^^^^^^ comment.line.rem.dosbatch

REM ^

I'm a (com|ment)
:: ^^^^^^^^^^^^^^^^^ comment.line.rem.dosbatch

REM ^
I'm a (com|ment) ^
not a comment
:: ^^^^^^^^^^^^^ - comment
:: ^^^^^^^^^^^^^^ - comment

REM
not a comment
:: ^^^^^^^^^^^^^ - comment
:: ^^^^^^^^^^^^^^ - comment

REM This follows a REM command
:: <- keyword.declaration.rem.dosbatch - comment
:: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.rem.dosbatch

REM This & and | echo "is commented out" ^
:: <- keyword.declaration.rem.dosbatch
:: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.command.rem.dosbatch comment.line.rem.dosbatch
:: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.command.rem.dosbatch comment.line.rem.dosbatch

REM No line ^
continuation
:: <- - comment
:: ^^^^^^^^^ - comment
:: ^^^^^^^^^^ - comment

::: Me too!
:: ^^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^^ comment.line.colon.dosbatch
:: ^^^^^^^^^^^^ comment.line.colon.dosbatch

:::
Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

:: Me too!
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^ comment.line.colon.dosbatch
:: ^^^^^^^^^^^ comment.line.colon.dosbatch

::
Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

:+ Me too!
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^^ comment.line.colon.dosbatch

:+
Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

:= Me too!
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^^ comment.line.colon.dosbatch

:=
Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

:, Me too!
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^^ comment.line.colon.dosbatch

:,
Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

:; Me too!
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^^ comment.line.colon.dosbatch

:;
Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

: Me too!
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^ comment.line.colon.dosbatch

:
Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

:::^
Me too!
:: ^^^^^^^^ comment.line.colon.dosbatch

:::^

Me too!
:: ^^^^^^^^ comment.line.colon.dosbatch

::: ^
A continued comment.^
Me too!
:: ^^^^^^^^ comment.line.colon.dosbatch

::^
Me too!
:: ^^^^^^^ comment.line.colon.dosbatch
:: ^^^^^^^^ comment.line.colon.dosbatch

::^

Me too!
:: ^^^^^^^^ comment.line.colon.dosbatch

:: ^
A continued comment.^
Me too!
:: ^^^^^^^^ comment.line.colon.dosbatch

: ^
Me too!
:: ^^^^^^^ comment.line.colon.dosbatch
:: ^^^^^^^^ comment.line.colon.dosbatch

: ^

Me too!
:: ^^^^^^^^ comment.line.colon.dosbatch

: ^
A continued comment.^
Me too!
:: ^^^^^^^ comment.line.colon.dosbatch
:: ^^^^^^^^ comment.line.colon.dosbatch

:> ignored content ( & | )
:: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.colon.dosbatch
Expand All @@ -114,30 +181,30 @@ continuation
ECHO &&:: A comment
:: ^^ keyword.operator.logical.dosbatch
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^^^ comment.line.colon.dosbatch
:: ^^^^^^^^^^^^^ comment.line.colon.dosbatch

ECHO &:: A comment
:: ^ keyword.operator.logical.dosbatch
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^^^ comment.line.colon.dosbatch
:: ^^^^^^^^^^^^^ comment.line.colon.dosbatch

ECHO ||:: A comment
:: ^^ keyword.operator.logical.dosbatch
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^^^ comment.line.colon.dosbatch
:: ^^^^^^^^^^^^^ comment.line.colon.dosbatch

ECHO |:: Not a comment
:: ^ keyword.operator.assignment.pipe.dosbatch
:: ^^^^^^^^^^^^^^^^ invalid.illegal.unexpected.dosbatch

ECHO : Not a comment ^
:: ^^^^^^^^^^^^^^^ - comment
:: ^^^^^^^^^^^^^^^^^^ - comment
:: ^^ punctuation.separator.continuation.line.dosbatch

ECHO : Not a comment ^
:: Me not, too
:: <- - comment
::^^^^^^^^^^^^ - comment
::^^^^^^^^^^^^^ - comment

:::: [ @ Operator ] :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Expand Down
Loading