CPP-4964 Quick definition for user commands and macros in CMake
authorVasily Pisar <vasily.pisar@jetbrains.com>
Tue, 1 Mar 2016 16:03:23 +0000 (19:03 +0300)
committerVasily Pisar <vasily.pisar@jetbrains.com>
Tue, 1 Mar 2016 16:03:23 +0000 (19:03 +0300)
– trivial, after-review refactoring

platform/lang-impl/src/com/intellij/codeInsight/hint/ImplementationViewComponent.java

index 2d654e125d72e657e0138dd4690007b6edcfc5f9..9c2d8635501926007ea2bc51ab9439fa6c5126e2 100644 (file)
@@ -50,6 +50,7 @@ import com.intellij.ui.components.JBScrollPane;
 import com.intellij.usages.UsageView;
 import com.intellij.util.DocumentUtil;
 import com.intellij.util.PairFunction;
+import com.intellij.util.text.CharArrayUtil;
 import com.intellij.util.ui.JBUI;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -446,10 +447,10 @@ public class ImplementationViewComponent extends JPanel {
     final ImplementationTextSelectioner implementationTextSelectioner =
       LanguageImplementationTextSelectioner.INSTANCE.forLanguage(elt.getLanguage());
     int start = implementationTextSelectioner.getTextStartOffset(elt);
-    int end = implementationTextSelectioner.getTextEndOffset(elt);
-    while (end > start && StringUtil.endsWithLineBreak(doc.getCharsSequence().subSequence(start, end))) {
-      end--;
-    }
+    
+    CharSequence rawDefinition = doc.getCharsSequence().subSequence(start, 
+                                                                    implementationTextSelectioner.getTextEndOffset(elt));
+    int end = CharArrayUtil.shiftBackward(rawDefinition, rawDefinition.length(), "\r\n"); // deleting trailing EOLs
 
     final int lineStart = doc.getLineStartOffset(doc.getLineNumber(start));
     final int lineEnd = end < doc.getTextLength() ? doc.getLineEndOffset(doc.getLineNumber(end)) : doc.getTextLength();