Sublime Forum

SyntaxFold Question Re Pattern Match

#1

I apologize if this question is a duplicate or asked in the wrong forum.

I’m using the SyntaxFold package to code fold PIC Assembly. The folding should occur on specific tags within comments. Here is an example:

;------------------------------------------------------------------------------
;<editor-fold defaultstate="collapsed" desc="_serialTXWait">
; Macro:    _serialTXWait
; Purpose
_serialTXWait macro
      banksel     TXSTA             ;Select bank
      btfss       TXSTA,TRMT        ;Skip when TSR is clear and TX finished
         goto       _serialTXWait   ; Block waiting to send
   endm
;</editor-fold>

So it’s essentially XML embedded within a comment (following a semicolon). I’ve tried

{
    "scope":        "source.asm.gpasm",
    "startMarker":  "^;<editor-fold.*$",
    "endMarker":    "^;</editor-fold.*$"
}

as well as more specific regex patterns that would include XML attributes, etc. This doesn’t seem to have any affect on how the editor chooses where to fold code. In fact, as a second question, how would I disable the default code folding and just use the SyntaxFold package matches?

Thank you in advance,
James

0 Likes

#2

ST’s built in code folding operates only based on indentation, nothing more. It is currently not possible to change the way the built in folding markers in the gutter operate, nor the built in “fold by level” commands.

What https://packagecontrol.io/packages/SyntaxFold seems to offer is keybindings and entries in the Command Palette that will use it’s custom folding. i.e. try SyntaxFold: Fold All

0 Likes

#3

Thank you for the prompt reply. Adding

"SyntaxFold": "Fold All"

Didn’t seem to make any difference, but I appreciate your advice.

I’ve seen some examples of regex matching for SyntaxFold, but I can’t seem to get this to work. Since the editor doesn’t seem to fold by default, I guess I can just ignore indent folds.They don’t work well with assembly where labels within a “function” or macro are not indented, but this doesn’t signify the end of the logical block.

Thanks again!

0 Likes