From 15f7bdf88299514bf2c003eb0b1c043d4bf2ffa3 Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Sun, 3 Jul 2016 01:54:09 +0300 Subject: [PATCH] Diagnostic for EA-54980 --- .../intellij/codeInsight/template/impl/TemplateState.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java index 708eb139e39c..58be21ddd588 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java @@ -856,7 +856,12 @@ public class TemplateState implements Disposable { } private void replaceString(String newValue, int start, int end, int segmentNumber) { - String oldText = myDocument.getCharsSequence().subSequence(start, end).toString(); + TextRange range = TextRange.create(start, end); + if (!TextRange.from(0, myDocument.getCharsSequence().length()).contains(range)) { + LOG.error("Diagnostic for EA-54980. Can't extract " + range + " range. " + presentTemplate(myTemplate), + AttachmentFactory.createAttachment(myDocument)); + } + String oldText = range.subSequence(myDocument.getCharsSequence()).toString(); if (!oldText.equals(newValue)) { mySegments.setNeighboursGreedy(segmentNumber, false);