From 58faa5208aa74e56c65abf5ba809dcab6f154b8c Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Mon, 12 Feb 2018 14:23:54 +0300 Subject: [PATCH] IDEA-186444 Pasting whole line doesn't work properly in Javadoc comments --- .../editorActions/JavadocCopyPastePreProcessor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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);