diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavadocCopyPastePreProcessor.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavadocCopyPastePreProcessor.java index caa6b7efa133..270fcfe8c145 100644 --- a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavadocCopyPastePreProcessor.java +++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavadocCopyPastePreProcessor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.editorActions; import com.intellij.application.options.CodeStyle; @@ -39,7 +39,7 @@ public class JavadocCopyPastePreProcessor implements CopyPastePreProcessor { int lineStartOffset = DocumentUtil.getLineStartOffset(offset, document); CharSequence chars = document.getImmutableCharSequence(); int firstNonWsLineOffset = CharArrayUtil.shiftForward(chars, lineStartOffset, " \t"); - if (firstNonWsLineOffset >= chars.length() || chars.charAt(firstNonWsLineOffset) != '*') return text; + if (firstNonWsLineOffset >= offset || chars.charAt(firstNonWsLineOffset) != '*') return text; String lineStartReplacement = "\n" + chars.subSequence(lineStartOffset, firstNonWsLineOffset + 1) + " "; return StringUtil.trimTrailing(text, '\n').replace("\n", lineStartReplacement);