From 5a4dbaf08d5e64bfa677091dfbd199ffcfae1637 Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Mon, 16 Oct 2023 11:16:38 +0530 Subject: [PATCH] Access ws tab length through options --- .../formatter/core/FormattingTreeModifier.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java index 8a6fd3c209f3..185d1094f875 100644 --- a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java +++ b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java @@ -4482,13 +4482,14 @@ private void preserveIndentation(boolean value) { */ private int getPreservedIndentation(Token token) { int position = token.lineRange().startLine().offset(); - int offset = position % 4; - if (env.currentIndentation % 4 == 0 && env.currentIndentation > position) { + int tabSize = options.getTabSize(); + int offset = position % tabSize; + if (env.currentIndentation % tabSize == 0 && env.currentIndentation > position) { return env.currentIndentation; } if (offset != 0) { if (offset > 2) { - position = position + 4 - offset; + position = position + tabSize - offset; } else { position = position - offset; }