Does this only happen when you add a pgn that already has comments? Or are you adding the comment yourself in the pgn insert tool?
Comments in wrong place after promotion of variation in analysis
No pgns involved at all. These are diagrams usually created with a FEN from the current board in the vote chess game, and with multiple lines of analysis.
@Elroch Do you mean in a situation such as this:
that if you promote the variation with 1…c5, the comment at the beginning of the variation can end up in the wrong place?
If so, it's because we don't keep track of both a before-comment and an after-comment per move, but comments are more closely associated with the move before them.
But it's still possible to have a comment at the beginning of a variation, so when you promote a variation with a comment at the beginning, the comment gets merged into the mainline like this:
It's a bit unfortunate, but the alternative would be to have two separate comments in between 1.e4 and 1…c5, one after 1.e4 and one before 1…c5. It's doable but has a couple of disadvantages: 1) in many cases it isn't obvious that there are two different comments when you're looking at them, and 2) if you export the PGN, many applications will ignore one of the comments. (Comments in PGN aren't really attached to any particular move or position, and there isn't any real standard on how to read them.)
This is still a problem.
I should add that annotation can switche from one move to the opponent's as well as comments. Not desirable! Just now I was editing a vote chess diagram and added a ?! to an opponents move and a comment that this seems to be an error, then promoted the line and the annotation and the comment were added to our following move!
If it is not possible to attach pre and post comments to each move when re-ordering lines (perhaps some trick like an added character to indicate if it is pre- or post- would do it without a bespoke data structure?), the best solution might be to only permit post-move comments and keep them firmly attached to a specific move.
In diagrams in vote chess games it is often useful to promote variations as assessments change. I have discovered that a comment placed before the first move of a variation can end up in the wrong place when this is done. The comments should be firmly attached to the move to which they were added, whether before or after it!
WIndows 10 PC, Chrome (but I doubt those are factors).