@Override
 public void fileCreated(@NotNull VirtualFileEvent event) {
   final VirtualFile createdFile = event.getFile();
   final VirtualFile taskDir = createdFile.getParent();
   if (taskDir != null && taskDir.getName().contains(Task.TASK_DIR)) {
     int taskIndex = StudyUtils.getIndex(taskDir.getName(), Task.TASK_DIR);
     final VirtualFile lessonDir = taskDir.getParent();
     if (lessonDir != null && lessonDir.getName().contains(StudyNames.LESSON_DIR)) {
       int lessonIndex = StudyUtils.getIndex(lessonDir.getName(), StudyNames.LESSON_DIR);
       if (myCourse != null) {
         List<Lesson> lessons = myCourse.getLessons();
         if (StudyUtils.indexIsValid(lessonIndex, lessons)) {
           final Lesson lesson = lessons.get(lessonIndex);
           final List<Task> tasks = lesson.getTaskList();
           if (StudyUtils.indexIsValid(taskIndex, tasks)) {
             final Task task = tasks.get(taskIndex);
             final TaskFile taskFile = new TaskFile();
             taskFile.init(task, false);
             taskFile.setUserCreated(true);
             task.getTaskFiles().put(createdFile.getName(), taskFile);
           }
         }
       }
     }
   }
 }
 // remembering old end before document change because of problems
 // with fragments containing "\n"
 @Override
 public void beforeDocumentChange(DocumentEvent e) {
   if (!myTaskFile.isTrackChanges()) {
     return;
   }
   myTaskFile.setHighlightErrors(true);
   final Document document = e.getDocument();
   myTaskWindows.clear();
   for (AnswerPlaceholder answerPlaceholder : myTaskFile.getAnswerPlaceholders()) {
     int twStart = answerPlaceholder.getRealStartOffset(document);
     int twEnd = twStart + answerPlaceholder.getLength();
     myTaskWindows.add(new TaskWindowWrapper(answerPlaceholder, twStart, twEnd));
   }
 }
 @Override
 public void documentChanged(DocumentEvent e) {
   if (!myTaskFile.isTrackChanges()) {
     return;
   }
   if (e instanceof DocumentEventImpl) {
     final DocumentEventImpl event = (DocumentEventImpl) e;
     final Document document = e.getDocument();
     int offset = e.getOffset();
     int change = event.getNewLength() - event.getOldLength();
     for (TaskWindowWrapper taskWindowWrapper : myTaskWindows) {
       int twStart = taskWindowWrapper.getTwStart();
       if (twStart > offset) {
         twStart += change;
       }
       int twEnd = taskWindowWrapper.getTwEnd();
       if (twEnd >= offset) {
         twEnd += change;
       }
       final AnswerPlaceholder answerPlaceholder = taskWindowWrapper.getAnswerPlaceholder();
       int line = document.getLineNumber(twStart);
       int start = twStart - document.getLineStartOffset(line);
       int length = twEnd - twStart;
       answerPlaceholder.setLine(line);
       answerPlaceholder.setStart(start);
       answerPlaceholder.setLength(length);
     }
   }
 }