@@ -139,13 +139,21 @@ sub disambiguate-f-search( $docee, %data ) {
139
139
for % found . keys -> $ key {
140
140
% options {$ key }. push : % found {$ key }>>. subst (/^ 'Type::' /, ' ' );
141
141
}
142
- say " \t " ~ % options . values . map ({ @ ($ ^ a ) }). join (" \n\t " ) ~ " \n " ;
143
142
144
143
# 's' => Type::Supply.grep, ... | and we specifically want the %found values,
145
144
# | not the presentation-versions in %options
146
145
if INTERACT {
146
+ my $ idx = 0 ;
147
+ my $ total-elems = [+ ] % found . values . map ({ + @ ^ o });
148
+ if + % found . keys < $ total-elems {
149
+ my @ prefixes = (1 .. $ total-elems ) X ~ " ) " ;
150
+ say " \t " ~ ( @ prefixes Z ~ % options . values . map ({ @ ($ ^ a ) }) ). join (" \n\t " ) ~ " \n " ;
151
+ } else {
152
+ say " \t " ~ % options . values . map ({ @ ($ ^ a ) }). join (" \n\t " ) ~ " \n " ;
153
+ }
147
154
$ final-docee = prompt-with-options( % options , % found );
148
155
} else {
156
+ say " \t " ~ % options . values . map ({ @ ($ ^ a ) }). join (" \n\t " ) ~ " \n " ;
149
157
exit 1 ;
150
158
}
151
159
}
@@ -156,7 +164,17 @@ sub prompt-with-options( %options, %found ) {
156
164
my $ final-docee ;
157
165
158
166
my % prefixes = do for % options . kv -> $ k ,@ o { @ o . map (*. comb [0 ]. lc ) X => % found {$ k } };
159
- my $ prompt-text = " Narrow your choice? ({ % prefixes . keys . join (' , ' ) } , or !{ ' /' ~ ' q' if ! % prefixes <q >} to quit): " ;
167
+
168
+ if % prefixes . values . grep ( -> @ o { + @ o > 1 }) {
169
+ my (% indexes ,$ base-idx );
170
+ $ base-idx = 0 ;
171
+ for % options . kv -> $ k ,@ o {
172
+ % indexes . push : @ o >>. map ({ ++ $ base-idx }) Z => @ (% found {$ k });
173
+ }
174
+ % prefixes = % indexes ;
175
+ }
176
+
177
+ my $ prompt-text = " Narrow your choice? ({ % prefixes . keys . sort . join (' , ' ) } , or !{ ' /' ~ ' q' if ! % prefixes <q >} to quit): " ;
160
178
161
179
while prompt( $ prompt-text ). words -> $ word {
162
180
if $ word ~~ ' !' or ($ word ~~ ' q' and ! % prefixes <q >) {
0 commit comments