From 0078c2201662910094a032b734f77137c3f41049 Mon Sep 17 00:00:00 2001 From: Valentin Fondaratov Date: Wed, 24 Feb 2016 15:05:59 +0300 Subject: [PATCH] RUBY-17536: Fix inconsistent injected<->host conversions when default offset value is used on line indent adjustment --- .../psi/impl/source/codeStyle/CodeStyleManagerImpl.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java index e678edb57f63..4f737beef7b0 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java @@ -368,7 +368,7 @@ public class CodeStyleManagerImpl extends CodeStyleManager { } private int doAdjustLineIndentByOffset(@NotNull PsiFile file, int offset) { - return new CodeStyleManagerRunnable(this, FormattingMode.ADJUST_INDENT) { + final Integer result = new CodeStyleManagerRunnable(this, FormattingMode.ADJUST_INDENT) { @Override protected Integer doPerform(int offset, TextRange range) { return FormatterEx.getInstanceEx().adjustLineIndent(myModel, mySettings, myIndentOptions, offset, mySignificantRange); @@ -381,9 +381,12 @@ public class CodeStyleManagerImpl extends CodeStyleManager { @Override protected Integer adjustResultForInjected(Integer result, DocumentWindow documentWindow) { - return documentWindow.hostToInjected(result); + return result != null ? documentWindow.hostToInjected(result) + : null; } - }.perform(file, offset, null, offset); + }.perform(file, offset, null, null); + + return result != null ? result : offset; } @Override