diff --git a/resources/functionalTests/for/8each-label/input.p b/resources/functionalTests/for/8each-label/input.p new file mode 100644 index 0000000..43c0aba --- /dev/null +++ b/resources/functionalTests/for/8each-label/input.p @@ -0,0 +1,10 @@ +/* formatterSettingsOverride */ +/* { "AblFormatter.forFormatting": true}*/ + + +define variable i as integer no-undo. + +Label: +for each Customer: + message Customer.Id. + end. \ No newline at end of file diff --git a/resources/functionalTests/for/8each-label/target.p b/resources/functionalTests/for/8each-label/target.p new file mode 100644 index 0000000..0af7159 --- /dev/null +++ b/resources/functionalTests/for/8each-label/target.p @@ -0,0 +1,10 @@ +/* formatterSettingsOverride */ +/* { "AblFormatter.forFormatting": true}*/ + + +define variable i as integer no-undo. + +Label: +for each Customer: + message Customer.Id. +end. \ No newline at end of file diff --git a/src/model/SyntaxNodeType.ts b/src/model/SyntaxNodeType.ts index 3eb4f61..8ba4d95 100644 --- a/src/model/SyntaxNodeType.ts +++ b/src/model/SyntaxNodeType.ts @@ -64,6 +64,7 @@ export enum SyntaxNodeType { Setter = "setter", LeftParenthesis = "(", RightParenthesis = ")", + Label = "label", // keywords WhenKeyword = "WHEN", diff --git a/src/v2/formatters/for/ForFormatter.ts b/src/v2/formatters/for/ForFormatter.ts index 9b5346a..1051f51 100644 --- a/src/v2/formatters/for/ForFormatter.ts +++ b/src/v2/formatters/for/ForFormatter.ts @@ -83,9 +83,16 @@ export class ForFormatter extends AFormatter implements IFormatter { switch (node.type) { case SyntaxNodeType.ForKeyword: + newString = FormatterHelper.getCurrentText( + node, + fullText + ).trimEnd(); + break; case SyntaxNodeType.DotKeyword: case SyntaxNodeType.ColonKeyword: case SyntaxNodeType.CommaKeyword: + case SyntaxNodeType.Body: + case SyntaxNodeType.Label: newString = FormatterHelper.getCurrentText( node, fullText @@ -117,11 +124,8 @@ export class ForFormatter extends AFormatter implements IFormatter { alignColumn ); break; - case SyntaxNodeType.Body: - newString = FormatterHelper.getCurrentText( - node, - fullText - ).trim(); + case SyntaxNodeType.Error: + newString = FormatterHelper.getCurrentText(node, fullText); break; default: const text = FormatterHelper.getCurrentText(