ahkscript / SublimeAutoHotkey

AutoHotkey AHK language package for SublimeText including syntax highlighting, comments toggling, auto-completions, build system definitions, commands for ahkrun, ahkcompile, ahkrunpiped.
The Unlicense
207 stars 43 forks source link

block comments broken if indented #58

Closed joedf closed 4 years ago

joedf commented 4 years ago

The documentation specifies:

the /* and */ symbols can be used to comment out an entire section, but only if the symbols appear at the beginning of a line

Source: https://www.autohotkey.com/docs/Language.htm#comments

The implementation found in AutoHotkey.tmLanguage is correct: https://github.com/ahkscript/SublimeAutoHotkey/blob/951f41ab2e6c1624903538bbd4648b689389f188/AutoHotkey.tmLanguage#L36-L38

However, this is broken if comments are indented such as:

#Warn
MsgBox 1

    /*
     * indented comment line 1
       MsgBox Comment
     * indented comment line 3
     */

MsgBox 2

Running the above test script executes with no warnings or errors, and shows only two message boxes (1,2).

I have posted a new issue under Lexikos/AutoHotkey_L-Docs: https://github.com/Lexikos/AutoHotkey_L-Docs/issues/398

The implementation should instead be:

 <string>^[\t ]*/\*</string>
 <key>end</key>
 <string>^[\t ]*\*/</string>

Comments?

robertcollier4 commented 4 years ago

Wouldnt \s be more elegant in describing a whitespace char. Like follows

<string>^\s*/\*</string>
<key>end</key>
<string>^\s*\*/</string>
joedf commented 4 years ago

I think was worried about new line characters. I'll give it go later to test this.

joedf commented 4 years ago

You're right. I think I wanted to use \s, but I think I was being cautious of new lines. I realize that the ^ was there anyway, ahha Anyway, I have amended the change. 👍