prompt-toolkit/python-prompt-toolkit

`Renderer.reset` is called 3 times during application startup.

Opened this issue · 1 comments

This results in some output escape sequences to be produced multiple times without reason, like showing the cursor.

Renderer.reset() is called three times when we create/start an application, like ptpython for instance:

  • Once Application.__init__()-> Renderer.__init__() -> Renderer.reset().
  • Once Application.__init__() -> Application.reset() ->Renderer.reset().
  • Once Application._run_async() -> Application.__init__() -> Application.reset() ->Renderer.reset().

Each time, we call self.output.show_cursor().

Either we should keep track in the Renderer, which terminal state was changed, and only reset that (cursor shapes changed, cursor hidden/shown, alternate screen entered/left, ...) or we should create the Renderer instance only at the point that the application actually starts in Application._run_async(), so that we only reset once.

Partially fixed by this: #1968