@@ -238,7 +238,7 @@ def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None,
238238 try :
239239 import readline
240240 # remove some common file name delimiters
241- readline .set_completer_delims (' \t \n `@#$ %^&*()=+[{]}\\ |;:\' ",<>?' )
241+ readline .set_completer_delims (' \t \n `@#%^&*()=+[{]}\\ |;:\' ",<>?' )
242242 except ImportError :
243243 pass
244244 self .allow_kbdint = False
@@ -686,6 +686,18 @@ def set_convenience_variable(self, frame, name, value):
686686 # Generic completion functions. Individual complete_foo methods can be
687687 # assigned below to one of these functions.
688688
689+ def completenames (self , text , line , begidx , endidx ):
690+ # Overwrite completenames() of cmd so for the command completion,
691+ # if no current command matches, check for expressions as well
692+ commands = super ().completenames (text , line , begidx , endidx )
693+ for alias in self .aliases :
694+ if alias .startswith (text ):
695+ commands .append (alias )
696+ if commands :
697+ return commands
698+ else :
699+ return self ._complete_expression (text , line , begidx , endidx )
700+
689701 def _complete_location (self , text , line , begidx , endidx ):
690702 # Complete a file/module/function location for break/tbreak/clear.
691703 if line .strip ().endswith ((':' , ',' )):
@@ -720,6 +732,10 @@ def _complete_expression(self, text, line, begidx, endidx):
720732 # complete builtins, and they clutter the namespace quite heavily, so we
721733 # leave them out.
722734 ns = {** self .curframe .f_globals , ** self .curframe_locals }
735+ if text .startswith ("$" ):
736+ # Complete convenience variables
737+ conv_vars = self .curframe .f_globals .get ('__pdb_convenience_variables' , {})
738+ return [f"${ name } " for name in conv_vars if name .startswith (text [1 :])]
723739 if '.' in text :
724740 # Walk an attribute chain up to the last part, similar to what
725741 # rlcompleter does. This will bail if any of the parts are not
0 commit comments