Fix index handling in change manager
All checks were successful
zdm/undo-redo/pipeline/head This commit looks good

This commit is contained in:
Kai S. K. Engelbart 2021-12-11 14:01:31 +01:00
parent 2773d360fb
commit ee6015b353
Signed by: kske
GPG Key ID: 8BEB13EC5DF7EF13

View File

@ -15,8 +15,8 @@ public final class ChangeManager<C extends Change> {
private final List<C> changes = new LinkedList<>(); private final List<C> changes = new LinkedList<>();
private int index; private int index = -1;
private int markedIndex; private int markedIndex = -1;
/** /**
* Applies the given change and appends it to the change list. * Applies the given change and appends it to the change list.
@ -27,6 +27,7 @@ public final class ChangeManager<C extends Change> {
public void addChange(C change) { public void addChange(C change) {
change.apply(); change.apply();
changes.add(change); changes.add(change);
++index;
} }
/** /**
@ -81,7 +82,7 @@ public final class ChangeManager<C extends Change> {
* @since 0.0.1 * @since 0.0.1
*/ */
public boolean isUndoAvailable() { public boolean isUndoAvailable() {
return index > 0; return index > -1;
} }
/** /**