From 9503fc37af56793ee2705fee65c6ecdb00aef0f9 Mon Sep 17 00:00:00 2001 From: Rustam Vishnyakov Date: Wed, 3 Aug 2016 17:31:06 +0300 Subject: [PATCH] FIXED IDEA-159285 Editor doesn't auto-indent within switch-case correctly --- .../lineIndent/JavaLikeLangLineIndentProvider.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/lineIndent/JavaLikeLangLineIndentProvider.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/lineIndent/JavaLikeLangLineIndentProvider.java index c5cd1618a426..923696368c7d 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/lineIndent/JavaLikeLangLineIndentProvider.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/lineIndent/JavaLikeLangLineIndentProvider.java @@ -172,6 +172,12 @@ public abstract class JavaLikeLangLineIndentProvider extends FormatterBasedLineI } while (!position.isAtEnd()) { if (currLanguage == Language.ANY || currLanguage == null) currLanguage = position.getLanguage(); + if (position.isAt(Colon)) { + SemanticEditorPosition afterColon = getPosition(position.getEditor(), position.getStartOffset()).after().afterOptional(Whitespace); + if (position.isAfterOnSameLine(SwitchCase, SwitchDefault)) { + return afterColon.getStartOffset(); + } + } if (position.isAtAnyOf(Semicolon, BlockOpeningBrace, BlockClosingBrace, BlockComment, DocBlockEnd, LineComment, LeftParenthesis) || (position.getLanguage() != Language.ANY) && !position.isAtLanguage(currLanguage)) { SemanticEditorPosition statementStart = getPosition(position.getEditor(), position.getStartOffset());