Skip to content

Commit

Permalink
Merge pull request #262 from BalticAmadeus/258-wrong-formatting-with-…
Browse files Browse the repository at this point in the history
…label

fixed issue with label
  • Loading branch information
PauliusKu authored Nov 8, 2024
2 parents a5e0f03 + 2be694e commit f1f9cc1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
10 changes: 10 additions & 0 deletions resources/functionalTests/for/8each-label/input.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* formatterSettingsOverride */
/* { "AblFormatter.forFormatting": true}*/


define variable i as integer no-undo.

Label:
for each Customer:
message Customer.Id.
end.
10 changes: 10 additions & 0 deletions resources/functionalTests/for/8each-label/target.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* formatterSettingsOverride */
/* { "AblFormatter.forFormatting": true}*/


define variable i as integer no-undo.

Label:
for each Customer:
message Customer.Id.
end.
1 change: 1 addition & 0 deletions src/model/SyntaxNodeType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export enum SyntaxNodeType {
Setter = "setter",
LeftParenthesis = "(",
RightParenthesis = ")",
Label = "label",

// keywords
WhenKeyword = "WHEN",
Expand Down
14 changes: 9 additions & 5 deletions src/v2/formatters/for/ForFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit f1f9cc1

Please sign in to comment.