From 12503c054aff9b46a33bc6eb486dbc0d27d70d95 Mon Sep 17 00:00:00 2001 From: Martin Leduc <31558169+DecimalTurn@users.noreply.github.com> Date: Tue, 14 Jan 2025 22:16:16 +0000 Subject: [PATCH 1/2] Improve Rem support + tests --- client/src/syntaxes/vba.tmLanguage.yaml | 6 +-- test/textmate/unit/module/comments.vba | 63 +++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 test/textmate/unit/module/comments.vba diff --git a/client/src/syntaxes/vba.tmLanguage.yaml b/client/src/syntaxes/vba.tmLanguage.yaml index a2e8a88..9026f98 100644 --- a/client/src/syntaxes/vba.tmLanguage.yaml +++ b/client/src/syntaxes/vba.tmLanguage.yaml @@ -415,15 +415,15 @@ repository: comments: patterns: - - include: "#remarkComments" - include: "#blockComments" - include: "#apostropheComments" + - include: "#remarkComments" repository: blockComments: # The sub-pattern consumes the \n if preceded by line continuation. # Capturing it there prevents the end pattern being matched. name: comment.block.vba - begin: (?i)\s*'.*\s_\s* + begin: (?i)(\s*'|(?<=^|:)\s*Rem\b).*\s_\s* end: \n patterns: - include: "#lineContinuation" @@ -432,7 +432,7 @@ repository: match: (?i)\s*'.* remarkComments: name: comment.line.remark.vba - match: (?i)(?<=^|:)\s*Rem\b.* + match: (?i)(?<=^\d*?|:)\s*Rem\b.* attribute: name: meta.attribute.vba diff --git a/test/textmate/unit/module/comments.vba b/test/textmate/unit/module/comments.vba new file mode 100644 index 0000000..10443fb --- /dev/null +++ b/test/textmate/unit/module/comments.vba @@ -0,0 +1,63 @@ +' SYNTAX TEST "source.vba" "comments" + +' This is a comment with without indentation +' <-------------------------------------------- comment.line.apostrophe.vba + + ' This is a comment with indentation +' ^^^^^^^^^^^^^^^^^^^ comment.line.apostrophe.vba + +10 ' Comment with line number +' <-- constant.numeric.vba +' ^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.apostrophe.vba + +Label1: ' Comment with label +' ^^^^^^^^^^^^^^^^^^^^ comment.line.apostrophe.vba + +Dim x as Long 'Comment at the end of a line +' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.apostrophe.vba + +Dim x As Long: 'Comment with colon +' ^^^^^^^^^^^^^^^^^^^ comment.line.apostrophe.vba + +' This is the start of a comment block _ +' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.vba + +' This is a comment _ + continued on the next line +' ^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.vba + +' This is a comment _ + continued on the next line _ + and another line +' ^^^^^^^^^^^^^^^^ comment.block.vba + +Rem This is a remark without indentation +' <-------------------------------------- comment.line.remark.vba + + Rem This is a remark with indentation +' ^^^^^^^^^^^^^^^^^^^^ comment.line.remark.vba + +10 Rem Comment with line number +' <-- constant.numeric.vba +' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.remark.vba + +Label1: Rem Comment with label +' ^^^^^^^^^^^^^^^^^^^^^^ comment.line.remark.vba + +Dim x as Long Rem Comment at the end of a line +' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - comment.line.remark.vba + +Dim x As Long: Rem Comment with colon +' ^^^^^^^^^^^^^^^^^^^^^^ comment.line.remark.vba + + Rem This is the start of a comment block _ +' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.vba + +Rem This is a comment _ + continued on the next line +' ^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.vba + +Rem This is a comment _ + continued on the next line _ + and another line +' ^^^^^^^^^^^^^^^^ comment.block.vba \ No newline at end of file From 395f2138e540f756f18f5b9dfca37000fa112487 Mon Sep 17 00:00:00 2001 From: Martin Leduc <31558169+DecimalTurn@users.noreply.github.com> Date: Tue, 14 Jan 2025 22:34:10 +0000 Subject: [PATCH 2/2] Include optional line number in Rem comment block --- client/src/syntaxes/vba.tmLanguage.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/syntaxes/vba.tmLanguage.yaml b/client/src/syntaxes/vba.tmLanguage.yaml index 9026f98..49465bc 100644 --- a/client/src/syntaxes/vba.tmLanguage.yaml +++ b/client/src/syntaxes/vba.tmLanguage.yaml @@ -423,7 +423,7 @@ repository: # The sub-pattern consumes the \n if preceded by line continuation. # Capturing it there prevents the end pattern being matched. name: comment.block.vba - begin: (?i)(\s*'|(?<=^|:)\s*Rem\b).*\s_\s* + begin: (?i)(\s*'|(?<=^\d*?|:)\s*Rem\b).*\s_\s* end: \n patterns: - include: "#lineContinuation"