Skip to content
This repository has been archived by the owner on Oct 6, 2024. It is now read-only.

Add support for folding region-marker comments. #43

Merged
merged 1 commit into from
Sep 27, 2020
Merged

Add support for folding region-marker comments. #43

merged 1 commit into from
Sep 27, 2020

Conversation

Hicsy
Copy link
Contributor

@Hicsy Hicsy commented Sep 26, 2020

Similar to how other languages use regions in VSCode, accept a comment marker ; followed by the Keyword region (whitespace is ignored). Any other text can follow this word like a normal comment.
VS Code will then naturally support folding up that region until the next ; endregion comment.
Example Used

Example:

/*
 * My AHK Script
 * It does nothing
 */

; region ==================== Initialisation ====================
#Persistent
#SingleInstance, Force
myVar := 0
; endregion ==============================================

;region ===================== Main ========================
#IfWinNotActive, ahk_exe chrome.exe
return
#IfWinNotActive
;endregion

Similar to how other languages use regions in VSCode, accept a comment marker `;` followed by the Keyword `region` (whitespace is ignored). Any other text can follow this word like a normal comment.
VS Code will then naturally support folding up that region until the next `;` `endregion` comment.
[Example Used](https://github.com/microsoft/vscode-extension-samples/blob/master/language-configuration-sample/language-configuration.json)

Example:
```autohotkey
/*
 * My AHK Script
 * It does nothing
 */

; region ==================== Initialisation ====================
#Persistent
#SingleInstance, Force
myVar := 0
; endregion ==============================================

;region ===================== Main ========================
#IfWinNotActive, ahk_exe chrome.exe
return
#IfWinNotActive
;endregion
```
@Hicsy
Copy link
Contributor Author

Hicsy commented Sep 26, 2020

Proposal: Add region-folding.
Gday, I tested this on my PC and it worked fine. If you deliberately left out region markers or added others elsewhere, please advise.
I provided an example above which shows:

  1. Follows same keyword format as most other languages.
  2. The Regex accounts for various whitespace (as per linked Microsoft Example).
  3. Allows comments or no comments on same line.

As is standard in VSCode, regions can also be layered such as my typical H1/H2 comments:

;region ========== Main ==========
#Persistent
#SingleInstance, Force


;region ---------- bind: spacebar ----------
space::
return
;endregion ---------------------------------


;region ---------- bind: control ------------
ctrl::
return
;endregion ---------------------------------
;endregion ====== End: Main ==========

ps sorry about the formatting, the start of the file uses tabs, the end of the file uses spaces, and I am currently trying out the new "propose change" flow from the GitHub web site so no idea which one it will use 😉

Cheers,
Hicsy

@cweijan cweijan merged commit 70afe6d into cweijan:master Sep 27, 2020
@Hicsy Hicsy deleted the patch-1 branch September 27, 2020 15:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants