IDEA-186444 Pasting whole line doesn't work properly in Javadoc comments

This commit is contained in:
Dmitry Batrak
2018-02-12 14:25:13 +03:00
parent 6378f19331
commit 58faa5208a
@@ -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);