Copy constructor of CodeEditor::Position doesn't copy maintenance state. Why?


#1

Title says it all. What’s the design decision behind this? (I assume there is one because the comment of the copy constructor explicitely states this behaviour).

It makes usage of containers that use the copy constructor very unintuitive:

Array<CodeDocument::Position> positionList;
CodeDocument::Position pos(whatever);
pos.setPositionMaintained(true);

positionList.add(pos);
positionList.getLast().isPositionMaintained(); // <- false.

I can imagine it has something to do with not cluttering the ListenerList of the CodeDocument, but can we at least have move semantics that allow this?

positions.add(std::move(pos));
positions.getReference(0).isPositionMaintained(); // <- true

The other option I see here is to use a OwnedArray<CodeDocument::Position> and create them on the heap to prevent copying, but this is rather ugly.