Skip to content

pdb completion menu not honouring prompt_toolkit style #10478

Closed

Description

@memeplex

The menu colors look different when inside pdb (after %debug) than when outside it.
In particular, neither of:

Token.Menu.Completions
Token.Menu.Completions.Completion
Token.Menu.Completions.Completion.Current
Token.Menu.Completions.Meta
Token.Menu.Completions.Meta.Current
Token.Menu.Completions.MultiColumnMeta

is taken into account.

Activity

  1. memeplex commented on Apr 22, 2017

    @memeplex
    ContributorAuthor

    Well create_prompt_application in debugger.py is not using the style at all, I will try to fix this and let you know.

  2. memeplex commented on Apr 22, 2017

    @memeplex
    ContributorAuthor

    Well, this was easier than I thought, here is a simple fix:

    @@ -17,6 +17,7 @@ from prompt_toolkit.token import Token
     from prompt_toolkit.shortcuts import create_prompt_application
     from prompt_toolkit.interface import CommandLineInterface
     from prompt_toolkit.enums import EditingMode
    +from prompt_toolkit.styles import DynamicStyle
     
     
     class TerminalPdb(Pdb):
    @@ -63,6 +64,7 @@ class TerminalPdb(Pdb):
                                 mouse_support=self.shell.mouse_support,
                                 get_prompt_tokens=get_prompt_tokens,
                                 display_completions_in_columns=multicolumn,
    +                            style=DynamicStyle(lambda: self.shell._style)
             )
             self.pt_cli = CommandLineInterface(self._pt_app, eventloop=self.shell._eventloop)
    

    Problem is shell._style is "private", so wouldn't it be desirable to expose shell.style as DynamicStyle(lambda:...)? I mean, first:

    --- /tmp/interactiveshell.py	2017-04-22 20:50:30.740261882 -0300
    +++ terminal/interactiveshell.py	2017-04-22 20:50:38.807746481 -0300
    @@ -235,7 +235,7 @@ class TerminalInteractiveShell(Interacti
                     last_cell = cell
     
             self._style = self._make_style_from_name_or_cls(self.highlighting_style)
    -        style = DynamicStyle(lambda: self._style)
    +        self.style = DynamicStyle(lambda: self._style)
     
             editing_mode = getattr(EditingMode, self.editing_mode.upper())
     
    @@ -249,7 +249,7 @@ class TerminalInteractiveShell(Interacti
                                 completer=IPythonPTCompleter(shell=self,
                                                         patch_stdout=patch_stdout),
                                 enable_history_search=True,
    -                            style=style,
    +                            style=self.style,
                                 mouse_support=self.mouse_support,
                                 **self._layout_options()
    

    and then just

    --- /tmp/debugger.py	2017-04-22 20:45:05.810699332 -0300
    +++ terminal/debugger.py	2017-04-22 20:49:32.444350980 -0300
    @@ -63,6 +63,7 @@ class TerminalPdb(Pdb):
                                 mouse_support=self.shell.mouse_support,
                                 get_prompt_tokens=get_prompt_tokens,
                                 display_completions_in_columns=multicolumn,
    +                            style=self.shell.style
             )
             self.pt_cli = CommandLineInterface(self._pt_app, eventloop=self.shell._eventloop)
    

    This looks much cleaner to me. Which one do you prefer? Do you want me to submit a PR or is it ok?

  3. Carreau commented on Apr 22, 2017

    @Carreau
    Member

    I don't have particular preference. Feel free to send a PR :-)

  4. memeplex commented on Apr 22, 2017

    @memeplex
    ContributorAuthor

    Also, I'm not really sure keeping shell._style as an attribute has any point.

  5. Carreau commented on Apr 23, 2017

    @Carreau
    Member

    lso, I'm not really sure keeping shell._style as an attribute has any point.

    Maybe not, there've been a lot of refactor. It's still half a mess and need a lot of cleaning.

  6. memeplex commented on Apr 23, 2017

    @memeplex
    ContributorAuthor

    It still might be useful as a cache, I guess.

  7. added a commit that references this issue on Apr 24, 2017
    075c197
  8. added a commit that references this issue on Apr 24, 2017
    220ad48
  9. modified the milestone: no action on May 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions