mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use correct length
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user