From f49921e67d08cbc1d3f354c57caa2f06ecb74d9e Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Wed, 30 Nov 2016 17:27:18 +0300 Subject: [PATCH] Copyright: do not add double \n for languages with not merged whitespace tokens --- .../idea/copyright/psi/UpdatePsiFileCopyright.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdatePsiFileCopyright.java b/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdatePsiFileCopyright.java index 77827b278585..1307f5a06bad 100644 --- a/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdatePsiFileCopyright.java +++ b/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdatePsiFileCopyright.java @@ -159,12 +159,17 @@ public abstract class UpdatePsiFileCopyright extends AbstractUpdateCopyright { // TODO - do we need option to remove blank line after? return; // Nothing to do since the comment is the same } + int totalNewline = 0; PsiElement next = getNextSibling(range.getLast()); - if (next != null) { + while (next != null && totalNewline <= 1) { final String text = next.getText(); - if (StringUtil.isEmptyOrSpaces(text) && countNewline(text) > 1) { - return; + if (!StringUtil.isEmptyOrSpaces(text)) { + break; } + totalNewline += countNewline(text); + } + if (totalNewline > 1) { + return; } point = range.getFirst(); }