Explain the problem as you see it
The line and cursor location where each edit is undone is not necessarily focused before edits are undone.
Why is this a problem for you?
There is no way to know where, let alone what, is being edited as a result of Undo.
Suggest a solution
Focus the cursor or, at minimum, the line where Undo is editing within a panel.