Do not erase a modified line when moving in the Python console history (#16654)
Closes #16653
Summary of the issue:
Unexecuted commands are lost when moving in the python console history.
Description of user facing changes
If a command has been written or modified in the console but not executed, it will not be lost. In case the modified command is not the last in the history, the original history item will not be overriden (as it was before #15794), but it will be copied in last position in the history so that it can be edited.
Description of development approach
Tracked text modification with an appropriate event to react accordingly.