IDEA-246368 Weird behavior when cursor is inside rendered Doc
authorDmitry Batrak <Dmitry.Batrak@jetbrains.com>
Thu, 13 Aug 2020 12:35:58 +0000 (15:35 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Thu, 13 Aug 2020 13:07:20 +0000 (13:07 +0000)
GitOrigin-RevId: 348bd6cc3fa17461b10c728177989ced8d78b92e

java/java-tests/testSrc/com/intellij/codeInsight/documentation/render/JavaDocRenderTest.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/FoldingModelImpl.java

index 78a7b1e8875705339b8e15ccc3a9f3b4b1d0e525..d0b839be74c76e343a6816c03b12225b0c1b75c5 100644 (file)
@@ -160,6 +160,19 @@ public class JavaDocRenderTest extends AbstractEditorTest {
     }
   }
 
+  public void testTypingAfterCollapse() {
+    configure("/**\n" +
+              " * doc<caret>\n" +
+              " */\n" +
+              "class C {}", false);
+    toggleItem();
+    type("  ");
+    checkResultByText("/**\n" +
+                      " * doc\n" +
+                      " */\n" +
+                      "  <caret>class C {}");
+  }
+
   private void configure(@NotNull String text, boolean enableRendering) {
     EditorSettingsExternalizable.getInstance().setDocCommentRenderingEnabled(enableRendering);
     init(text, TestFileType.JAVA);
index 1a2e0930316609c5cd767c944a6b9cd47e58d7c2..3918ce9b066545a6cc560eb9ab6526ec1ec83e41 100644 (file)
@@ -402,7 +402,8 @@ public final class FoldingModelImpl extends InlayModel.SimpleAdapter
             positionToUse = savedPosition.position;
           }
           else {
-            offsetToUse = collapsedAtSaved.getStartOffset();
+            offsetToUse = collapsedAtSaved.getPlaceholderText().isEmpty() ? collapsedAtSaved.getEndOffset() // rendered docs
+                                                                          : collapsedAtSaved.getStartOffset();
           }
         }