Skip to content

Commit 7d2c790

Browse files
committed
undo 6a5bcfe: there IS actually a good reason to sort the words in advance, let's add a comment to explain why
1 parent 6a5bcfe commit 7d2c790

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Lib/_pyrepl/fancycompleter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ def attr_matches(self, text):
100100
noprefix = '__'
101101
else:
102102
noprefix = None
103+
104+
# sort the words now to make sure to return completions in
105+
# alphabetical order. It's easier to do it now, else we would need to
106+
# sort 'names' later but make sure that 'values' in kept in sync,
107+
# which is annoying.
108+
words = sorted(words)
103109
while True:
104110
for word in words:
105111
if (
@@ -130,7 +136,6 @@ def attr_matches(self, text):
130136
if prefix and prefix != attr:
131137
return [f'{expr}.{prefix}'] # autocomplete prefix
132138

133-
names.sort()
134139
if self.use_colors:
135140
return self.colorize_matches(names, values)
136141

0 commit comments

Comments
 (0)