Saved Position in variable before doing adjustments.

This commit is contained in:
Michael Uhl 2019-11-27 21:39:00 +01:00
parent 951c8cbdf6
commit 82efea69b6

View File

@ -246,35 +246,38 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
typeReplaceMarkers.removeIf(trm -> !trm.isConsistent(typeReplaceMarker)); typeReplaceMarkers.removeIf(trm -> !trm.isConsistent(typeReplaceMarker));
int lengthOfInsert = typeReplaceMarker.getInsertPoint().getInsertString().length(); int lengthOfInsert = typeReplaceMarker.getInsertPoint().getInsertString().length();
int postitionOfInsert = typeReplaceMarker.getPositionInCode();
for (TypeReplaceMarker toCheck : typeReplaceMarkers) { for (TypeReplaceMarker toCheck : typeReplaceMarkers) {
if (toCheck.getPoint().getPositionInCode() > typeReplaceMarker.getPoint().getPositionInCode() + lengthOfInsert) { if (toCheck.getPoint().getPositionInCode() > postitionOfInsert) {
toCheck.getInsertPoint().point.addExtraOffset(lengthOfInsert); toCheck.getInsertPoint().point.addExtraOffset(lengthOfInsert);
} }
// Add extra offset for the additional insert points of "typeReplaceMarker" // Add extra offset for the additional insert points of "typeReplaceMarker"
// to "toCheck" // to "toCheck"
// ... // ...
/*
for (TypeInsertPoint additionalPoint : typeReplaceMarker.getInsertPoint().getAdditionalPointsUnsorted()) { for (TypeInsertPoint additionalPoint : typeReplaceMarker.getInsertPoint().getAdditionalPointsUnsorted()) {
int lengthAdditionalInsert = additionalPoint.getInsertString().length(); int lengthAdditionalInsert = additionalPoint.getInsertString().length();
int positionAdditionalInsert = additionalPoint.getPositionInCode(); int positionAdditionalInsert = additionalPoint.getPositionInCode();
if (additionalIdentityElimination.add(additionalPoint) && toCheck.getPositionInCode() > positionAdditionalInsert + lengthAdditionalInsert) { if (additionalIdentityElimination.add(additionalPoint) && postitionOfInsert > positionAdditionalInsert) {
toCheck.getInsertPoint().point.addExtraOffset(lengthAdditionalInsert); toCheck.getInsertPoint().point.addExtraOffset(lengthAdditionalInsert);
} }
} }
*/
for (TypeInsertPoint tip : typeReplaceMarker.getInsertPoint().getAdditionalPointsUnsorted()) { for (TypeInsertPoint tip : typeReplaceMarker.getInsertPoint().getAdditionalPointsUnsorted()) {
// Add to all other type replace markers the extra offsets of the additional // Add to all other type replace markers the extra offsets of the additional
// points of this type replace marker. // points of this type replace marker.
// ... // ...
if (toCheck.getPoint().getPositionInCode() > tip.getPositionInCode() - tip.getInsertString().length()) { if (toCheck.getPoint().getPositionInCode() > postitionOfInsert - tip.getInsertString().length()) {
toCheck.getInsertPoint().point.addExtraOffset(tip.getInsertString().length()); toCheck.getInsertPoint().point.addExtraOffset(tip.getInsertString().length());
} }
} }
for (TypeInsertPoint toCheckAddi : toCheck.getInsertPoint().getAdditionalPointsUnsorted()) { for (TypeInsertPoint toCheckAddi : toCheck.getInsertPoint().getAdditionalPointsUnsorted()) {
if (toCheckAddi.getPositionInCode() > typeReplaceMarker.getPoint().getPositionInCode() + lengthOfInsert) { if (toCheckAddi.getPositionInCode() > postitionOfInsert) {
toCheckAddi.addExtraOffset(lengthOfInsert); toCheckAddi.addExtraOffset(lengthOfInsert);
} }