◐ Shell
clean mode source ↗

Message 363457 - Python tracker

This is much clearer.  To expand on what I said before, inserting *anything*, such as by hitting a key, replaces a selection.  I verified that this is normal behavior, at least on Windows, with Notepad, Notepad++, and this Firefox entry box I am typing in.  So either of your steps 6 or 7 delete the still selected line, after the goto.  (And so a click is needed before 6 to stop the deletion.)  I see the continued selection as the problem.  Both Notepad and Notepad++ unselect any selection upon goto, the same as if one moved the cursor by clicking instead of goto.

I will try adding text.selection_clear() to the goto code.