Skip to content

Commit

Permalink
Merge pull request #300 from BalticAmadeus/299-define-formatter-wrong…
Browse files Browse the repository at this point in the history
…fully-impacts-other-formatters

299 define formatter wrongfully impacts other formatters
  • Loading branch information
PauliusKu authored Jan 23, 2025
2 parents d86bb62 + 8434057 commit 8a89282
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 1 addition & 7 deletions src/v2/formatters/enum/EnumFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { FormatterHelper } from "../../formatterFramework/FormatterHelper";
export class EnumFormatter extends AFormatter implements IFormatter {
public static readonly formatterLabel = "enumFormatting";
private readonly settings: EnumSettings;
private startColumn = 0;
private alignColumn = 0;

public constructor(configurationManager: IConfigurationManager) {
Expand All @@ -38,10 +37,6 @@ export class EnumFormatter extends AFormatter implements IFormatter {
node: SyntaxNode,
fullText: Readonly<FullText>
): string {
this.startColumn = FormatterHelper.getActualStatementIndentation(
node,
fullText
);
let foundFirstMember = false;
let resultString = "";
node.children.forEach((child) => {
Expand All @@ -52,8 +47,7 @@ export class EnumFormatter extends AFormatter implements IFormatter {
);
if (!foundFirstMember && child.type === SyntaxNodeType.EnumMember) {
foundFirstMember = true;
this.alignColumn =
this.startColumn + resultString.trim().length + 1; // +1 for space between member and DEFINE ENUM
this.alignColumn = resultString.trim().length + 1; // +1 for space between member and DEFINE ENUM
}
resultString = resultString.concat(childString);
});
Expand Down
5 changes: 4 additions & 1 deletion src/v2/formatters/property/PropertyFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class PropertyFormatter extends AFormatter implements IFormatter {
node,
fullText
);

this.propertyBodyValue = this.getPropertyBlock(node, fullText);
}

Expand Down Expand Up @@ -87,7 +88,9 @@ export class PropertyFormatter extends AFormatter implements IFormatter {
);
const statement = FormatterHelper.addIndentation(
FormatterHelper.getCurrentText(node, fullText).trim(),
-firstLineWhitespace + this.settings.tabSize(),
-firstLineWhitespace +
this.settings.tabSize() +
this.startColumn,
fullText.eolDelimiter
);
newString =
Expand Down

0 comments on commit 8a89282

Please sign in to comment.