From 44f831119aceaaf9a2bb365bf2f056012e150b20 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Wed, 18 Apr 2012 13:20:28 +0400 Subject: [PATCH] OC-3672 Comment line doesn't move cursor on the next line if it is located next to a argument placeholder --- .../generation/CommentByLineCommentHandler.java | 8 +++++++- .../com/intellij/openapi/editor/impl/CaretModelImpl.java | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java index 95058b4fba54..5fb421a74221 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java @@ -97,6 +97,12 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler { myStartOffset = selectionModel.getSelectionStart(); myEndOffset = selectionModel.getSelectionEnd(); + FoldRegion fold = myEditor.getFoldingModel().getCollapsedRegionAtOffset(myStartOffset); + if (fold != null && fold.shouldNeverExpand() && fold.getStartOffset() == myStartOffset && fold.getEndOffset() == myEndOffset) { + // Foldings that never expand are automatically selected, so the fact it is selected must not interfer with commenter's logic + hasSelection = false; + } + if (myDocument.getTextLength() == 0) return; while (true) { @@ -648,4 +654,4 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler { } } } -} \ No newline at end of file +} diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java index 7550c73112b6..7344d2b74d15 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java @@ -196,6 +196,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener, for (CaretListener listener : myCaretListeners) { listener.caretPositionChanged(event); } + EditorActionUtil.selectNonexpandableFold(myEditor); } } @@ -237,6 +238,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener, for (CaretListener listener : myCaretListeners) { listener.caretPositionChanged(event); } + EditorActionUtil.selectNonexpandableFold(myEditor); } } @@ -593,6 +595,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener, listener.caretPositionChanged(event); } } + EditorActionUtil.selectNonexpandableFold(myEditor); } return null; }