I've answered this question in real-time.
The code published in question had multiple bugs, so I edited my answer multiple times. The author updated the question's code with the fixed code after every edit I posted.
The last bug had been found by another user and I mentioned him in my answer.
But, after the final update another user posted an answer with only the last fix, which I had already included in my answer, and the asker accepted that answer.
This doesn't seem fair to me. What I should do? Flag the answer asking for a moderator intervention? Or am I missing the point?
Update
In the suggested post How to deal with constant changing questions the accepted answer point out some ways to deal with those questions. One of those ways is to "Delete my answer and move on."
But a comment describes a much better approach for me.
You should never delete your answer for such a reason. Rollback OPs question to the most suitable revision and explain they shouldn't change it drastically. If they won't listen and keep editing the question, flag it for moderator attention - the mods can then choose the correct path of action to take, such as locking the question in extreme cases.
From my point of view this is the best and most constructive way to deal with constant changing questions. Isn't it?
Allowing users to change their question constantly, aren't we discouraging ourself to spend time answering?