use correct length
authorliana.bakradze <liana.bakradze@jetbrains.com>
Thu, 3 Sep 2015 12:23:20 +0000 (15:23 +0300)
committerliana.bakradze <liana.bakradze@jetbrains.com>
Thu, 3 Sep 2015 12:25:23 +0000 (15:25 +0300)
python/educational/src/com/jetbrains/edu/EduUtils.java
python/educational/src/com/jetbrains/edu/courseFormat/AnswerPlaceholder.java

index 08b54340f3fccc46c7741ec21e5c788531061c09..bb472b22c444cf28cf1f5d2bd90a79a06d1e5e25 100644 (file)
@@ -94,12 +94,12 @@ public class EduUtils {
         fileWindows = taskDir.createChildData(taskFile, name);
         printWriter = new PrintWriter(new FileOutputStream(fileWindows.getPath()));
         for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
-          if (!answerPlaceholder.isValid(document)) {
+          int length = useLength ? answerPlaceholder.getLength() : answerPlaceholder.getPossibleAnswerLength();
+          if (!answerPlaceholder.isValid(document, length)) {
             printWriter.println("#educational_plugin_window = ");
             continue;
           }
           int start = answerPlaceholder.getRealStartOffset(document);
-          int length = useLength ? answerPlaceholder.getLength() : answerPlaceholder.getPossibleAnswerLength();
           final String windowDescription = document.getText(new TextRange(start, start + length));
           printWriter.println("#educational_plugin_window = " + windowDescription);
         }
index a2ffd42ef345fd1a0b0de73e0107b43d9ddb50e1..ae3230b5e980c452951076e34538b458f83942bf 100644 (file)
@@ -116,6 +116,10 @@ public class AnswerPlaceholder {
   }
 
   public boolean isValid(@NotNull final Document document) {
+    return isValid(document, length);
+  }
+
+  public boolean isValid(@NotNull final Document document, int length) {
     boolean isLineValid = line < document.getLineCount() && line >= 0;
     if (!isLineValid) return false;
     boolean isStartValid = start >= 0 && start < document.getLineEndOffset(line);