EDU-218 String index out of range: -1 on course reload when reloading a course
authorLiana Bakradze <liana.bakradze@jetbrains.com>
Mon, 20 Oct 2014 10:28:22 +0000 (14:28 +0400)
committerLiana Bakradze <liana.bakradze@jetbrains.com>
Mon, 20 Oct 2014 10:28:22 +0000 (14:28 +0400)
python/edu/learn-python/src/com/jetbrains/python/edu/actions/StudyRefreshTaskFileAction.java

index a379ccf18239240cd04cc01cdd232b1230b1962f..b1ff29b58270d14fb9a387d1bd83e001fc390d04 100644 (file)
@@ -125,10 +125,12 @@ public class StudyRefreshTaskFileAction extends DumbAwareAction {
         patternText.append("\n");
       }
       int patternLength = patternText.length();
-      if (patternText.charAt(patternLength - 1) == '\n') {
-        patternText.delete(patternLength - 1, patternLength);
+      if (patternLength != 0) {
+        if (patternText.charAt(patternLength - 1) == '\n') {
+          patternText.delete(patternLength - 1, patternLength);
+        }
+        document.setText(patternText);
       }
-      document.setText(patternText);
     }
     catch (FileNotFoundException e) {
       LOG.error(e);