// Add anchors at the conflict regions' boundaries, so their position/size
// gets adjusted automatically as the user enters text in and around them.
startLineAnchor = doc.addAnchor(
CONFLICT_CHUNK_START_LINE, chunk.getStartLine(), AnchorManager.IGNORE_COLUMN);
startLineAnchor.setRemovalStrategy(Anchor.RemovalStrategy.SHIFT);
startLineAnchor.getShiftListenerRegistrar().add(new ShiftListener() {
@Override
public void onAnchorShifted(Anchor anchor) {
setStartLine(anchor.getLineNumber());
}
});
endLineAnchor =
doc.addAnchor(CONFLICT_CHUNK_END_LINE, chunk.getEndLine(), AnchorManager.IGNORE_COLUMN);
endLineAnchor.setInsertionPlacementStrategy(InsertionPlacementStrategy.LATER);
endLineAnchor.setRemovalStrategy(Anchor.RemovalStrategy.SHIFT);
endLineAnchor.getShiftListenerRegistrar().add(new ShiftListener() {
@Override
public void onAnchorShifted(Anchor anchor) {
setEndLine(anchor.getLineNumber());
}
});