Unexpected undo results can occur when Autoindent and Undolinebyline are both enabled in Advmemo.
To produce one such example, enable Autoindent and Undolinebyline
Run the program and do the following in the memo:
Press tab key
1<return>
2
position cursor to the left of the "2" and press backspace until 2 is in column 1
At this point you should see:
1
2
press ctrl z 6 times
press ctrl y 6 times
Result: 1 2 (both on the same line)