summaryrefslogtreecommitdiff
path: root/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java')
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java
index 50942cb06c6b..4966a9466a26 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java
@@ -174,7 +174,8 @@ public class ReformatCodeAction extends AnAction implements DumbAware {
}
final TextRange range;
- if (!processWholeFile && editor != null && editor.getSelectionModel().hasSelection()){
+ final boolean processSelectedText = !processWholeFile && hasSelection;
+ if (processSelectedText) {
range = TextRange.create(editor.getSelectionModel().getSelectionStart(), editor.getSelectionModel().getSelectionEnd());
}
else{
@@ -185,7 +186,7 @@ public class ReformatCodeAction extends AnAction implements DumbAware {
new OptimizeImportsProcessor(new ReformatCodeProcessor(project, file, null, processChangedTextOnly)).run();
}
else {
- new ReformatCodeProcessor(project, file, range, processChangedTextOnly).run();
+ new ReformatCodeProcessor(project, file, range, !processSelectedText && processChangedTextOnly).run();
}
if (rearrangeEntries && file != null && editor != null) {