EDU-130 fixed

This commit is contained in:
Liana Bakradze
2014-08-27 16:41:43 +04:00
parent f930ecc0aa
commit 22bcaaa907
2 changed files with 15 additions and 1 deletions
@@ -52,6 +52,9 @@ public class StudyDocumentListener extends DocumentAdapter {
if (myTaskWindow != null) {
int newLength = myTaskWindow.getLength() + change;
myTaskWindow.setLength(newLength <= 0 ? 0 : newLength);
if (e.getNewFragment().equals("\n")) {
myTaskWindow.setLength(myTaskWindow.getLength() + 1);
}
}
int newEnd = offset + event.getNewLength();
int newLine = document.getLineNumber(newEnd);
@@ -173,7 +173,18 @@ public class TaskFile implements Stateful {
for (TaskWindow w : taskWindows) {
if ((w.getLine() == line) && (w.getStart() >= oldEndOffsetInLine)) {
int distance = w.getStart() - oldEndOffsetInLine;
if (lineChange != 0 || newEndOffsetInLine <= w.getStart()) {
boolean coveredByPrevTW = false;
int prevIndex = w.getIndex() - 1;
if (StudyUtils.indexIsValid(prevIndex, taskWindows)) {
TaskWindow prevTW = taskWindows.get(prevIndex);
if (prevTW.getLine() == line) {
int endOffset = prevTW.getStart() + prevTW.getLength();
if (endOffset >= newEndOffsetInLine) {
coveredByPrevTW = true;
}
}
}
if (lineChange != 0 || newEndOffsetInLine <= w.getStart() || coveredByPrevTW) {
w.setStart(distance + newEndOffsetInLine);
w.setLine(line + lineChange);
}