Skip to content

Commit

Permalink
Add IfMsgBox command to one command code list (#307)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Wiemer <7833360+mark-wiemer@users.noreply.github.com>
Closes #290
  • Loading branch information
kyklish authored Jan 19, 2023
1 parent 4bf32cf commit 0485455
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/providers/formattingProvider.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,15 @@ export function purify(original: string): string {
export function nextLineIsOneCommandCode(text: string): boolean {
/** Special keywords that can trigger one-line commands */
const oneCommandList = [
'ifnotexist',
'ifexist',
'ifinstring',
'ifmsgbox',
'ifnotexist',
'ifnotinstring',
'ifwinactive',
'ifwinnotactive',
'ifwinexist',
'ifwinnotactive',
'ifwinnotexist',
'ifinstring',
'ifnotinstring',
'if',
'else',
'loop',
Expand Down
1 change: 1 addition & 0 deletions src/test/suite/format/format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const formatTests: FormatTest[] = [
{ filenameRoot: '255-style-k-and-r' },
{ filenameRoot: '255-style-mix' },
{ filenameRoot: '255-style-one-true-brace' },
{ filenameRoot: '290-ifmsgbox' },
{ filenameRoot: '291-single-line-comment' },
{ filenameRoot: '316-if-object-continuation-section' },
{ filenameRoot: 'ahk-explorer' },
Expand Down
7 changes: 7 additions & 0 deletions src/test/suite/format/samples/290-ifmsgbox.in.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; [Issue #255](https://github.com/vscode-autohotkey/ahkpp/issues/290)
MsgBox, 4, , Would you like to continue?, 5 ; 5-second timeout.
IfMsgBox, No
Return ; User pressed the "No" button.
IfMsgBox, Timeout
Return ; i.e. Assume "No" if it timed out.
; Otherwise, continue
7 changes: 7 additions & 0 deletions src/test/suite/format/samples/290-ifmsgbox.out.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; [Issue #255](https://github.com/vscode-autohotkey/ahkpp/issues/290)
MsgBox, 4, , Would you like to continue?, 5 ; 5-second timeout.
IfMsgBox, No
Return ; User pressed the "No" button.
IfMsgBox, Timeout
Return ; i.e. Assume "No" if it timed out.
; Otherwise, continue

0 comments on commit 0485455

Please sign in to comment.