@@ -238,7 +238,7 @@ def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None,
238
238
try :
239
239
import readline
240
240
# remove some common file name delimiters
241
- readline .set_completer_delims (' \t \n `@#$ %^&*()=+[{]}\\ |;:\' ",<>?' )
241
+ readline .set_completer_delims (' \t \n `@#%^&*()=+[{]}\\ |;:\' ",<>?' )
242
242
except ImportError :
243
243
pass
244
244
self .allow_kbdint = False
@@ -686,6 +686,18 @@ def set_convenience_variable(self, frame, name, value):
686
686
# Generic completion functions. Individual complete_foo methods can be
687
687
# assigned below to one of these functions.
688
688
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
+
689
701
def _complete_location (self , text , line , begidx , endidx ):
690
702
# Complete a file/module/function location for break/tbreak/clear.
691
703
if line .strip ().endswith ((':' , ',' )):
@@ -720,6 +732,10 @@ def _complete_expression(self, text, line, begidx, endidx):
720
732
# complete builtins, and they clutter the namespace quite heavily, so we
721
733
# leave them out.
722
734
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 :])]
723
739
if '.' in text :
724
740
# Walk an attribute chain up to the last part, similar to what
725
741
# rlcompleter does. This will bail if any of the parts are not
0 commit comments