Fix empty input movement

This commit is contained in:
Andrea Cavalli 2023-08-23 16:54:06 +02:00
parent 7ae4315837
commit d288e0d96c
2 changed files with 8 additions and 24 deletions

View File

@ -133,12 +133,7 @@ public final class BlockPosition {
var it = innerContainers.listIterator(innerContainers.indexOf(container));
if (it.hasPrevious()) {
var prevContainer = it.previous();
var prevContainerLastBlock = prevContainer.getLastBlock();
if (prevContainerLastBlock != null) {
return new BlockPosition(prevContainerLastBlock);
} else {
return new BlockPosition(prevContainer);
}
return prevContainer.getLastPosition();
} else {
var parentContainer = parentBlock.getParentContainer();
var blocks = parentContainer.getContentUnsafe();
@ -160,12 +155,7 @@ public final class BlockPosition {
var innerContainers = block.getInnerContainers();
if (innerContainers != null) {
var lastContainer = innerContainers.get(innerContainers.size() - 1);
var lastBlock = lastContainer.getLastBlock();
if (lastBlock != null) {
return new BlockPosition(lastBlock);
} else {
return new BlockPosition(lastContainer);
}
return lastContainer.getLastPosition();
}
var ref = block.getReference();
var prevBlock = ref.getPreviousBlock();

View File

@ -126,17 +126,11 @@ public abstract class InputContainer implements GraphicalElement, InputLayout {
}
}
if (prevContainer != null) {
var lastBlock = prevContainer.getLastBlock();
if (lastBlock != null) {
caret.setPosition(new BlockPosition(lastBlock));
currentElementToRecompute = null;
removed = false;
} else {
caret.setPosition(new BlockPosition(prevContainer));
currentElementToRecompute = null;
removed = false;
}
} else {
var lastPosition = prevContainer.getLastPosition();
caret.setPosition(lastPosition);
currentElementToRecompute = null;
removed = false;
} else {
caret.setPosition(pos.getPrevious());
var parentContainer = block.getParentContainer();
parentContainer.removeBlockUnsafe(block);
@ -177,7 +171,7 @@ public abstract class InputContainer implements GraphicalElement, InputLayout {
if (prev != null) {
caret.setPosition(prev);
} else {
caret.setPosition(new BlockPosition(root.getLastBlock()));
caret.setPosition(root.getLastPosition());
}
caret.turnOn();
caretTime = 0;