prompt-toolkit / ptpython

A better Python REPL
BSD 3-Clause "New" or "Revised" License
5.23k stars 281 forks source link

Recently added cursor shape customization pollutes some old(?) terminal output #540

Open mguijarr opened 1 year ago

mguijarr commented 1 year ago

Seen on Debian 8 with Gnome terminal:

$ ptpython
>>> [2 q

Commenting cursor= in Application constructor call fixes the problem:

def _create_application(
        self, input: Input | None, output: Output | None
    ) -> Application[str]:
        """
        Create an `Application` instance.
        """
        return Application(
            layout=self.ptpython_layout.layout,
            key_bindings=merge_key_bindings(
                [
                    load_python_bindings(self),
                    load_auto_suggest_bindings(),
                    load_sidebar_bindings(self),
                    load_confirm_exit_bindings(self),
                    ConditionalKeyBindings(
                        load_open_in_editor_bindings(),
                        Condition(lambda: self.enable_open_in_editor),
                    ),
                    # Extra key bindings should not be active when the sidebar is visible.
                    ConditionalKeyBindings(
                        self.extra_key_bindings,
                        Condition(lambda: not self.show_sidebar),
                    ),
                ]
            ),
            color_depth=lambda: self.color_depth,
            paste_mode=Condition(lambda: self.paste_mode),
            mouse_support=Condition(lambda: self.enable_mouse_support),
            style=DynamicStyle(lambda: self._current_style),
            style_transformation=self.style_transformation,
            include_default_pygments_style=False,
            reverse_vi_search_direction=True,
            #### COMMENTING THE NEXT LINES FIXES THE PROBLEM
            #cursor=DynamicCursorShapeConfig(
            #    lambda: self.all_cursor_shape_configs[self.cursor_shape_config]
            #),
            ####
            input=input,
            output=output,
        )