From 73593d0d3559b810c7fe7db948b2e33df1373322 Mon Sep 17 00:00:00 2001 From: "liana.bakradze" Date: Thu, 3 Sep 2015 15:23:20 +0300 Subject: [PATCH] use correct length --- python/educational/src/com/jetbrains/edu/EduUtils.java | 4 ++-- .../src/com/jetbrains/edu/courseFormat/AnswerPlaceholder.java | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/python/educational/src/com/jetbrains/edu/EduUtils.java b/python/educational/src/com/jetbrains/edu/EduUtils.java index 08b54340f3fc..bb472b22c444 100644 --- a/python/educational/src/com/jetbrains/edu/EduUtils.java +++ b/python/educational/src/com/jetbrains/edu/EduUtils.java @@ -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); } diff --git a/python/educational/src/com/jetbrains/edu/courseFormat/AnswerPlaceholder.java b/python/educational/src/com/jetbrains/edu/courseFormat/AnswerPlaceholder.java index a2ffd42ef345..ae3230b5e980 100644 --- a/python/educational/src/com/jetbrains/edu/courseFormat/AnswerPlaceholder.java +++ b/python/educational/src/com/jetbrains/edu/courseFormat/AnswerPlaceholder.java @@ -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);